jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1782593 - /jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java
Date Sat, 11 Feb 2017 12:31:01 GMT
Author: fschumacher
Date: Sat Feb 11 12:31:01 2017
New Revision: 1782593

URL: http://svn.apache.org/viewvc?rev=1782593&view=rev
Log:
Use try-with syntax.

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

Modified: jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java?rev=1782593&r1=1782592&r2=1782593&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java Sat Feb 11 12:31:01 2017
@@ -23,7 +23,9 @@ import java.io.CharArrayWriter;
 import java.io.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.Reader;
 import java.io.StringReader;
 import java.io.Writer;
 import java.nio.charset.StandardCharsets;
@@ -136,12 +138,12 @@ public final class CSVSaveService {
      */
     public static void processSamples(String filename, Visualizer visualizer,
             ResultCollector resultCollector) throws IOException {
-        BufferedReader dataReader = null;
         final boolean errorsOnly = resultCollector.isErrorLogging();
         final boolean successOnly = resultCollector.isSuccessOnlyLogging();
-        try {
-            dataReader = new BufferedReader(new InputStreamReader(
-                    new FileInputStream(filename), SaveService.getFileEncoding(StandardCharsets.UTF_8.name())));
+        try (InputStream inStream = new FileInputStream(filename);
+                Reader inReader = new InputStreamReader(inStream,
+                        SaveService.getFileEncoding(StandardCharsets.UTF_8.name()));
+                BufferedReader dataReader = new BufferedReader(inReader)) {
             dataReader.mark(400);// Enough to read the header column names
             // Get the first line, and see if it is the header
             String line = dataReader.readLine();
@@ -175,8 +177,6 @@ public final class CSVSaveService {
                     }
                 }
             }
-        } finally {
-            JOrphanUtils.closeQuietly(dataReader);
         }
     }
 



Mime
View raw message