You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2006/05/14 18:40:44 UTC

svn commit: r406370 - /jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java

Author: sebb
Date: Sun May 14 09:40:44 2006
New Revision: 406370

URL: http://svn.apache.org/viewcvs?rev=406370&view=rev
Log:
Don't continue using connection if an error occurred;
don't log error response content

Modified:
    jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java

Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java?rev=406370&r1=406369&r2=406370&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java Sun May 14 09:40:44 2006
@@ -221,7 +221,6 @@
 	protected byte[] readResponse(HttpURLConnection conn, SampleResult res) throws IOException {
 		byte[] readBuffer = getThreadContext().getReadBuffer();
 		BufferedInputStream in;
-		boolean logError = false; // Should we log the error?
 		try {
             // works OK even if ContentEncoding is null
 			if (ENCODING_GZIP.equals(conn.getContentEncoding())) {
@@ -240,7 +239,6 @@
 				// JDK1.4: if (cause != null){
 				// JDK1.4: log.error("Cause: "+cause);
 				// JDK1.4: }
-				logError = true;
 			}
 			// Normal InputStream is not available
 			in = new BufferedInputStream(conn.getErrorStream());
@@ -251,7 +249,6 @@
 			// JDK1.4: log.error("Cause: "+cause);
 			// JDK1.4: }
 			in = new BufferedInputStream(conn.getErrorStream());
-			logError = true;
 		}
 		java.io.ByteArrayOutputStream w = new ByteArrayOutputStream();
 		int x = 0;
@@ -266,15 +263,6 @@
 		in.close();
 		w.flush();
 		w.close();
-		if (logError) {
-			String s;
-			if (w.size() > 1000) {
-				s = "\n" + w.toString().substring(0, 1000) + "\n\t...";
-			} else {
-				s = "\n" + w.toString();
-			}
-			log.error("readResponse: errorStream:"+s);
-		}
 		return w.toByteArray();
 	}
 
@@ -497,12 +485,15 @@
 			return res;
 		} catch (IOException e) {
 			res.sampleEnd();
+			// We don't want to continue using this connection, even if KeepAlive is set
+            conn.disconnect();
+            conn=null; // Don't process again
 			return errorResult(e, res);
 		} finally {
 			// calling disconnect doesn't close the connection immediately,
 			// but indicates we're through with it. The JVM should close
 			// it when necessary.
-			disconnect(conn);
+			disconnect(conn); // Disconnect unless using KeepAlive
 		}
 	}
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org