jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1783506 - /jmeter/trunk/src/core/org/apache/jmeter/samplers/DiskStoreSampleSender.java
Date Sat, 18 Feb 2017 11:07:34 GMT
Author: fschumacher
Date: Sat Feb 18 11:07:34 2017
New Revision: 1783506

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

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/DiskStoreSampleSender.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/DiskStoreSampleSender.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/DiskStoreSampleSender.java?rev=1783506&r1=1783505&r2=1783506&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/DiskStoreSampleSender.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/DiskStoreSampleSender.java Sat Feb 18
11:07:34 2017
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamException;
@@ -88,10 +89,9 @@ public class DiskStoreSampleSender exten
             log.error("Executor did not terminate in a timely fashion", e);
             Thread.currentThread().interrupt();
         }
-        ObjectInputStream ois = null;
-        try {
-            ois = new ObjectInputStream(new FileInputStream(temporaryFile));
-            Object obj = null;
+        try (InputStream fis = new FileInputStream(temporaryFile);
+                ObjectInputStream ois = new ObjectInputStream(fis)){
+            Object obj;
             while((obj = ois.readObject()) != null) {
                 if (obj instanceof SampleEvent) {
                     try {
@@ -116,7 +116,6 @@ public class DiskStoreSampleSender exten
             } catch (RemoteException e) {
                 log.error("returning sample", e);
             }
-            IOUtils.closeQuietly(ois);
             if(!temporaryFile.delete()) {
                 if (log.isWarnEnabled()) {
                     log.warn("Could not delete file: {}", temporaryFile.getAbsolutePath());



Mime
View raw message