MINOR: Fix potential resource leak in FileOffsetBackingStore
Reviewers: Sandor Murakozi Jason Gustafson
@@ -89,8 +89,7 @@ public class FileOffsetBackingStore extends MemoryOffsetBackingStore {
}
protected void save() {
- try {
- ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(file));
+ try (ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(file))) {
Map<byte[], byte[]> raw = new HashMap<>();
for (Map.Entry<ByteBuffer, ByteBuffer> mapEntry : data.entrySet()) {
byte[] key = (mapEntry.getKey() != null) ? mapEntry.getKey().array() : null;
@@ -98,7 +97,6 @@ public class FileOffsetBackingStore extends MemoryOffsetBackingStore {
raw.put(key, value);
}
os.writeObject(raw);
- os.close();
} catch (IOException e) {
throw new ConnectException(e);
}
