Author: sebb
Date: Sun Apr 30 10:42:04 2006
New Revision: 398391

URL: http://svn.apache.org/viewcvs?rev=398391&view=rev
Log:
Bug 38250 - allow locale of zh_CN and zh_TW
Close properties files after use

Modified:
    
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/JMeterUtils.java
    jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml

Modified: 
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/JMeterUtils.java
URL: 
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/JMeterUtils.java?rev=398391&r1=398390&r2=398391&view=diff
==============================================================================
--- 
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/JMeterUtils.java
 (original)
+++ 
jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/util/JMeterUtils.java
 Sun Apr 30 10:42:04 2006
@@ -55,7 +55,6 @@
 /**
  * This class contains the static utility methods used by JMeter.
  * 
- * @version $Revision$ updated on $Date$
  */
 public class JMeterUtils implements UnitTestManager {
        private static Logger log = LoggingManager.getLoggerForClass();
@@ -99,12 +98,14 @@
         */
        public static Properties getProperties(String file) {
                Properties p = new Properties(System.getProperties());
+        InputStream is = null;
                try {
                        File f = new File(file);
-                       p.load(new FileInputStream(f));
+                       is = new FileInputStream(f);
+            p.load(is);
                } catch (IOException e) {
                        try {
-                               InputStream is = 
+                               is = 
                                        
ClassLoader.getSystemResourceAsStream("org/apache/jmeter/jmeter.properties"); 
// $NON-NLS-1$
                                if (is == null)
                                        throw new RuntimeException("Could not 
read JMeter properties file");
@@ -113,13 +114,21 @@
                                // JMeter.fail("Could not read internal 
resource. " +
                                // "Archive is broken.");
                        }
-               }
+               } finally {
+            JOrphanUtils.closeQuietly(is);            
+        }
                appProperties = p;
                LoggingManager.initializeLogging(appProperties);
                log = LoggingManager.getLoggerForClass();
                String loc = appProperties.getProperty("language"); // 
$NON-NLS-1$
                if (loc != null) {
-                       setLocale(new Locale(loc, "")); // $NON-NLS-1$
+            String []parts = JOrphanUtils.split(loc,"_");// $NON-NLS-1$
+            if (parts.length==2) {
+                setLocale(new Locale(parts[0], parts[1]));              
+            } else {
+                       setLocale(new Locale(loc, "")); // $NON-NLS-1$
+            }
+            
                } else {
                        setLocale(Locale.getDefault());
                }
@@ -136,12 +145,14 @@
         */
        public static Properties loadProperties(String file) {
                Properties p = new Properties();
+        InputStream is = null;
                try {
                        File f = new File(file);
-                       p.load(new FileInputStream(f));
+                       is = new FileInputStream(f);
+            p.load(is);
                } catch (IOException e) {
                        try {
-                               InputStream is = 
JMeterUtils.class.getClassLoader().getResource(file).openStream();
+                               is = 
JMeterUtils.class.getClassLoader().getResource(file).openStream();
                                if (is == null) {
                                        log.warn("Cannot find " + file);
                                        return null;
@@ -151,7 +162,9 @@
                                log.warn("Error reading " + file + " " + 
ex.toString());
                                return null;
                        }
-               }
+               } finally {
+            JOrphanUtils.closeQuietly(is);            
+        }
                return p;
        }
 

Modified: jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml
URL: 
http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml?rev=398391&r1=398390&r2=398391&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml (original)
+++ jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml Sun Apr 30 10:42:04 2006
@@ -134,6 +134,7 @@
 <li>Bug 25236 - remove double scrollbar from Assertion Result Listener</li>
 <li>Bug 38234 - Graph Listener divide by zero problem</li>
 <li>Bug 38824 - clarify behaviour of Ignore Status</li>
+<li>Bug 38250 - allow locale of zh_CN and zh_TW</li>
 </ul>  
        
 <h4>Other changes</h4>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to