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:27:09 UTC

[kafka] branch 1.0 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 1.0
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/1.0 by this push:
     new 355a8d8  MINOR: Fix potential resource leak in FileOffsetBackingStore (#4739)
355a8d8 is described below

commit 355a8d8ce4b61efdc42aca609c38c8c9512e17b7
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.