kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkr...@apache.org
Subject git commit: KAFKA-1428 Ensure we close the file handle when reading the config.
Date Mon, 28 Apr 2014 22:43:29 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 2f5666408 -> bbb357c17


KAFKA-1428 Ensure we close the file handle when reading the config.


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

Branch: refs/heads/trunk
Commit: bbb357c174ffe4ead1229301847c08c3879c6723
Parents: 2f56664
Author: Jay Kreps <jay.kreps@gmail.com>
Authored: Mon Apr 28 15:37:29 2014 -0700
Committer: Jay Kreps <jay.kreps@gmail.com>
Committed: Mon Apr 28 15:37:29 2014 -0700

----------------------------------------------------------------------
 core/src/main/scala/kafka/utils/Utils.scala | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/bbb357c1/core/src/main/scala/kafka/utils/Utils.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/utils/Utils.scala b/core/src/main/scala/kafka/utils/Utils.scala
index 6bfbac1..5c5c4e7 100644
--- a/core/src/main/scala/kafka/utils/Utils.scala
+++ b/core/src/main/scala/kafka/utils/Utils.scala
@@ -139,12 +139,18 @@ object Utils extends Logging {
    * Read a properties file from the given path
    * @param filename The path of the file to read
    */
-  def loadProps(filename: String): Properties = {
-    val propStream = new FileInputStream(filename)
-    val props = new Properties()
-    props.load(propStream)
-    props
-  }
+   def loadProps(filename: String): Properties = {
+     val props = new Properties()
+     var propStream: InputStream = null
+     try {
+       propStream = new FileInputStream(filename)
+       props.load(propStream)
+     } finally {
+       if(propStream != null)
+         propStream.close
+     }
+     props
+   }
 
   /**
    * Open a channel for the given file


Mime
View raw message