Skip to content

Commit

Permalink
up freeobjects
Browse files Browse the repository at this point in the history
  • Loading branch information
RockyLOMO committed Nov 18, 2023
1 parent ddaa8a3 commit aa7ebf5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions rxlib/src/main/java/org/rx/core/Disposable.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public synchronized void close() {
if (closed) {
return;
}
//todo fields may be null
freeObjects();
closed = true;
}
Expand Down
5 changes: 4 additions & 1 deletion rxlib/src/main/java/org/rx/io/FileStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.extern.slf4j.Slf4j;
import org.rx.bean.FlagsEnum;
import org.rx.core.Constants;
import org.rx.core.Extends;
import org.rx.util.Lazy;
import org.rx.util.Snowflake;
import org.rx.util.function.TripleFunc;
Expand All @@ -17,6 +18,8 @@
import java.nio.file.Paths;
import java.nio.file.attribute.UserDefinedFileAttributeView;

import static org.rx.core.Extends.tryClose;

@Slf4j
public class FileStream extends IOStream implements Serializable {
private static final long serialVersionUID = 8857792573177348449L;
Expand Down Expand Up @@ -211,7 +214,7 @@ public FileStream(@NonNull File file, FileMode mode, int bufSize, @NonNull Flags

@Override
protected void freeObjects() throws Throwable {
randomAccessFile.close();
tryClose(randomAccessFile);
}

@Override
Expand Down
5 changes: 4 additions & 1 deletion rxlib/src/main/java/org/rx/io/HybridStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.rx.core.Constants;
import org.rx.core.Extends;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;

import static org.rx.core.Extends.tryClose;

@Slf4j
public final class HybridStream extends IOStream implements Serializable {
private static final long serialVersionUID = 2137331266386948293L;
Expand Down Expand Up @@ -76,7 +79,7 @@ public HybridStream(int maxMemorySize, boolean directMemory, String tempFilePath

@Override
protected void freeObjects() {
stream.close();
tryClose(stream);
}

FileStream newFileStream() {
Expand Down

0 comments on commit aa7ebf5

Please sign in to comment.