kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [kafka] branch 1.1 updated: MINOR: Fix potential resource leak in FileOffsetBackingStore (#4739)
Date Sat, 24 Mar 2018 19:24:43 GMT
This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch 1.1
in repository https://gitbox.apache.org/repos/asf/kafka.git


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

commit 3e14caa7d2b52c20d5e4c8467de7578195c89dd4
Author: Attila Sasvari <asasvari@apache.org>
AuthorDate: Sat Mar 24 20:20:11 2018 +0100

    MINOR: Fix potential resource leak in FileOffsetBackingStore (#4739)
    
    Reviewers: Sandor Murakozi <smurakozi@gmail.com>, Jason Gustafson <jason@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.

Mime
View raw message