mirror of https://github.com/apache/kafka.git
MINOR: Fix potential resource leak in FileOffsetBackingStore (#4739)
Reviewers: Sandor Murakozi <smurakozi@gmail.com>, Jason Gustafson <jason@confluent.io>
This commit is contained in:
parent
3c05c44f22
commit
3e14caa7d2
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue