[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-develop
Subject:    [HtmlUnit] SF.net SVN: htmlunit:[6439]
From:       mguillem () users ! sourceforge ! net
Date:       2011-05-30 8:25:17
Message-ID: E1QQxmn-0006M9-Ja () sfp-svn-2 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 6439
          http://htmlunit.svn.sourceforge.net/htmlunit/?rev=6439&view=rev
Author:   mguillem
Date:     2011-05-30 08:25:17 +0000 (Mon, 30 May 2011)

Log Message:
-----------
ensure that the InputStream used to read the browser properties gets closed

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java
 ===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java	2011-05-29 \
                13:22:07 UTC (rev 6438)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java	2011-05-30 \
08:25:17 UTC (rev 6439) @@ -14,6 +14,7 @@
  */
 package com.gargoylesoftware.htmlunit;
 
+import java.io.InputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -22,6 +23,7 @@
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 
@@ -210,10 +212,12 @@
     }
 
     private void initDefaultFeatures() {
+        InputStream stream = null;
         try {
             final Properties props = new Properties();
-            props.load(getClass().getResourceAsStream("/com/gargoylesoftware/htmlunit/javascript/configuration/"
                
-                    + nickname_ + ".properties"));
+            stream = \
getClass().getResourceAsStream("/com/gargoylesoftware/htmlunit/javascript/configuration/"
 +                + nickname_ + ".properties");
+            props.load(stream);
             for (final Object key : props.keySet()) {
                 try {
                     features_.add(BrowserVersionFeatures.valueOf(key.toString()));
@@ -227,6 +231,9 @@
         catch (final Exception e) {
             throw new RuntimeException("Configuration file not found for \
BrowserVersion: " + nickname_);  }
+        finally {
+            IOUtils.closeQuietly(stream);
+        }
     }
 
     /**


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
HtmlUnit-develop mailing list
HtmlUnit-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic