You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by jg...@apache.org on 2018/03/24 19:20:14 UTC
[kafka] branch trunk updated: MINOR: Fix potential resource leak in
FileOffsetBackingStore (#4739)
This is an automated email from the ASF dual-hosted git repository.
jgus pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 549a5ce MINOR: Fix potential resource leak in FileOffsetBackingStore (#4739)
549a5ce is described below
commit 549a5cec1ee82eb86e5b8bcb3886bf2d2dde2b39
Author: Attila Sasvari <as...@apache.org>
AuthorDate: Sat Mar 24 20:20:11 2018 +0100
MINOR: Fix potential resource leak in FileOffsetBackingStore (#4739)
Reviewers: Sandor Murakozi <sm...@gmail.com>, Jason Gustafson <ja...@confluent.io>
---
.../java/org/apache/kafka/connect/storage/FileOffsetBackingStore.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/storage/FileOffsetBackingStore.java b/connect/runtime/src/main/java/org/apache/kafka/connect/storage/FileOffsetBackingStore.java
index d868f62..9961a7c 100644
--- a/connect/runtime/src/main/java/org/apache/kafka/connect/storage/FileOffsetBackingStore.java
+++ b/connect/runtime/src/main/java/org/apache/kafka/connect/storage/FileOffsetBackingStore.java
@@ -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);
}
--
To stop receiving notification emails like this one, please contact
jgus@apache.org.