jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1783515 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
Date Sat, 18 Feb 2017 11:21:33 GMT
Author: fschumacher
Date: Sat Feb 18 11:21:33 2017
New Revision: 1783515

URL: http://svn.apache.org/viewvc?rev=1783515&view=rev
Log:
Use try-with statement to close writer.

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java?rev=1783515&r1=1783514&r2=1783515&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
Sat Feb 18 11:21:33 2017
@@ -335,18 +335,14 @@ public class AuthManager extends ConfigT
         if (!file.isAbsolute()) {
             file = new File(System.getProperty("user.dir"),authFile);
         }
-        PrintWriter writer = null;
-        try {
-            writer = new PrintWriter(new FileWriter(file));
+        try (FileWriter fw = new FileWriter(file);
+                PrintWriter writer = new PrintWriter(fw)){
             writer.println("# JMeter generated Authorization file");
             for (int i = 0; i < getAuthObjects().size(); i++) {
                 Authorization auth = (Authorization) getAuthObjects().get(i).getObjectValue();
                 writer.println(auth.toString());
             }
             writer.flush();
-            writer.close();
-        } finally {
-            JOrphanUtils.closeQuietly(writer);
         }
     }
 



Mime
View raw message