jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1362306 - in /jmeter/trunk: src/core/org/apache/jmeter/util/BeanShellClient.java src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java
Date Mon, 16 Jul 2012 23:04:20 GMT
Author: sebb
Date: Mon Jul 16 23:04:19 2012
New Revision: 1362306

URL: http://svn.apache.org/viewvc?rev=1362306&view=rev
Log:
Close resources

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellClient.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
    jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellClient.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellClient.java?rev=1362306&r1=1362305&r2=1362306&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellClient.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellClient.java Mon Jul 16 23:04:19
2012
@@ -70,8 +70,10 @@ public class BeanShellClient {
         while ((b=fis.read()) != -1){
             os.write(b);
         }
+        fis.close();
         sendLine("bsh.prompt=\"bsh % \";",os);// Reset for other users
         os.flush();
+        os.close();
         sock.shutdownOutput(); // Tell server that we are done
     }
 

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java?rev=1362306&r1=1362305&r2=1362306&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
Mon Jul 16 23:04:19 2012
@@ -285,9 +285,11 @@ public class HTTPJavaImpl extends HTTPAb
             }
             in = new BufferedInputStream(conn.getErrorStream());
         }
+        // N.B. this closes 'in'
         byte[] responseData = readResponse(res, in, contentLength);
         if (instream != null) {
             res.setBodySize(((CountingInputStream) instream).getCount());
+            instream.close();
         }
         return responseData;
     }

Modified: jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java?rev=1362306&r1=1362305&r2=1362306&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/monitor/model/benchmark/ParseBenchmark.java Mon
Jul 16 23:04:19 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jmeter.monitor.model.benchmark;
 
+import org.apache.commons.io.IOUtils;
+
 public class ParseBenchmark {
 
     /**
@@ -41,21 +43,25 @@ public class ParseBenchmark {
             if (args[2] != null) {
                 loops = Integer.parseInt(args[2]);
             }
-
             java.io.File infile = new java.io.File(file);
             java.io.FileInputStream fis = null;
             java.io.InputStreamReader isr = null;
+            java.io.BufferedReader br = null;
             StringBuilder buf = new StringBuilder();
             try {
                 fis = new java.io.FileInputStream(infile);
                 isr = new java.io.InputStreamReader(fis);
-                java.io.BufferedReader br = new java.io.BufferedReader(isr);
+                br = new java.io.BufferedReader(isr);
                 String line = null;
                 while ((line = br.readLine()) != null) {
                     buf.append(line);
                 }
             } catch (Exception e) {
                 e.printStackTrace();
+            } finally {
+                IOUtils.closeQuietly(br);
+                IOUtils.closeQuietly(isr);
+                IOUtils.closeQuietly(fis);
             }
             long start = 0;
             long end = 0;



Mime
View raw message