jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1714469 - /jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
Date Sun, 15 Nov 2015 17:12:57 GMT
Author: pmouawad
Date: Sun Nov 15 17:12:57 2015
New Revision: 1714469

URL: http://svn.apache.org/viewvc?rev=1714469&view=rev
Log:
Bug 57981 - Require a minimum of Java 7
Use Java7 resource management
Bugzilla Id: 57981

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java?rev=1714469&r1=1714468&r2=1714469&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java Sun Nov 15 17:12:57 2015
@@ -214,38 +214,28 @@ public class SaveService {
 
     public static Properties loadProperties() throws IOException{
         Properties nameMap = new Properties();
-        FileInputStream fis = null;
-        try {
-            fis = new FileInputStream(JMeterUtils.getJMeterHome()
-                         + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES, SAVESERVICE_PROPERTIES_FILE));
+        try (FileInputStream fis = new FileInputStream(JMeterUtils.getJMeterHome()
+                + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES, SAVESERVICE_PROPERTIES_FILE))){
             nameMap.load(fis);
-        } finally {
-            JOrphanUtils.closeQuietly(fis);
         }
         return nameMap;
     }
 
     private static String getChecksumForPropertiesFile()
             throws NoSuchAlgorithmException, IOException {
-        FileInputStream fis = null;
-        InputStreamReader inStream = null;
-        BufferedReader reader = null;
         MessageDigest md = MessageDigest.getInstance("SHA1");
-        try {
-            fis = new FileInputStream(JMeterUtils.getJMeterHome()
-                    + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES,
-                            SAVESERVICE_PROPERTIES_FILE));
-            inStream = new InputStreamReader(fis);
-            reader = new BufferedReader(inStream);
+        try (BufferedReader reader = 
+                new BufferedReader(
+                        new InputStreamReader(
+                                new FileInputStream(JMeterUtils.getJMeterHome()
+                                        + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES,
+                                                SAVESERVICE_PROPERTIES_FILE))))
+                ) {
             String line = null;
             while ((line = reader.readLine()) != null) {
                 md.update(line.getBytes());
             }
-        } finally {
-            JOrphanUtils.closeQuietly(reader);
-            JOrphanUtils.closeQuietly(inStream);
-            JOrphanUtils.closeQuietly(fis);
-        }
+        } 
         return JOrphanUtils.baToHexString(md.digest());
     }
     private static void initProps() {
@@ -542,12 +532,8 @@ public class SaveService {
      */
     public static HashTree loadTree(File file) throws IOException {
         log.info("Loading file: " + file);
-        InputStream reader = null;
-        try {
-            reader = new FileInputStream(file);
+        try (InputStream reader = new FileInputStream(file)){
             return readTree(reader, file);
-        } finally {
-            JOrphanUtils.closeQuietly(reader);
         }
     }
 



Mime
View raw message