You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by jk...@apache.org on 2014/04/29 00:43:29 UTC
git commit: KAFKA-1428 Ensure we close the file handle when reading
the config.
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 <ja...@gmail.com>
Authored: Mon Apr 28 15:37:29 2014 -0700
Committer: Jay Kreps <ja...@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