MINOR: Fix potential resource leak in FileOffsetBackingStore (#4739)

Reviewers: Sandor Murakozi <smurakozi@gmail.com>, Jason Gustafson <jason@confluent.io>
This commit is contained in:
Attila Sasvari 2018-03-24 20:20:11 +01:00 committed by Jason Gustafson
parent 3c05c44f22
commit 3e14caa7d2
1 changed files with 1 additions and 3 deletions

View File

@ -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);
}