kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwens...@apache.org
Subject kafka git commit: KAFKA-3235: Unclosed stream in AppInfoParser static block
Date Mon, 22 Feb 2016 06:54:44 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 6ebb2363b -> 49fd0ceb0


KAFKA-3235: Unclosed stream in AppInfoParser static block

Always close the stream

Author: Kim Christensen <kich@mvno.dk>

Reviewers: Ismael Juma, Grant Henke

Closes #914 from kichristensen/KAFKA-3235


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/49fd0ceb
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/49fd0ceb
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/49fd0ceb

Branch: refs/heads/trunk
Commit: 49fd0ceb09daf1d981d5a631342a8e3478db68ab
Parents: 6ebb236
Author: Kim Christensen <kich@mvno.dk>
Authored: Sun Feb 21 22:54:40 2016 -0800
Committer: Gwen Shapira <cshapi@gmail.com>
Committed: Sun Feb 21 22:54:40 2016 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/kafka/common/utils/AppInfoParser.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/49fd0ceb/clients/src/main/java/org/apache/kafka/common/utils/AppInfoParser.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/utils/AppInfoParser.java b/clients/src/main/java/org/apache/kafka/common/utils/AppInfoParser.java
index d0fd12a..415ef2e 100644
--- a/clients/src/main/java/org/apache/kafka/common/utils/AppInfoParser.java
+++ b/clients/src/main/java/org/apache/kafka/common/utils/AppInfoParser.java
@@ -16,6 +16,7 @@
  */
 package org.apache.kafka.common.utils;
 
+import java.io.InputStream;
 import java.lang.management.ManagementFactory;
 import java.util.Properties;
 
@@ -32,9 +33,9 @@ public class AppInfoParser {
     private static String commitId = "unknown";
 
     static {
-        try {
+        try (InputStream resourceStream = AppInfoParser.class.getResourceAsStream("/kafka/kafka-version.properties"))
{
             Properties props = new Properties();
-            props.load(AppInfoParser.class.getResourceAsStream("/kafka/kafka-version.properties"));
+            props.load(resourceStream);
             version = props.getProperty("version", version).trim();
             commitId = props.getProperty("commitId", commitId).trim();
         } catch (Exception e) {


Mime
View raw message