You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2017/02/18 11:21:33 UTC
svn commit: r1783515 -
/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
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);
}
}