jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1226061 - /jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
Date Sat, 31 Dec 2011 10:52:39 GMT
Author: pmouawad
Date: Sat Dec 31 10:52:39 2011
New Revision: 1226061

URL: http://svn.apache.org/viewvc?rev=1226061&view=rev
Log:
Bug 52396 - TCP Sampler in "reuse connection mode" reuses previous sampler's connection even
if it's configured with other host, port, user or password

Modified:
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java?rev=1226061&r1=1226060&r2=1226061&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java (original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java Sat
Dec 31 10:52:39 2011
@@ -442,6 +442,9 @@ public class TCPSampler extends Abstract
         }
     }
 
+    /**
+     * Close socket of current sampler
+     */
     private void closeSocket() {
         Map<String, Object> cp = tp.get();
         Socket con = (Socket) cp.remove(getSocketKey());
@@ -455,11 +458,32 @@ public class TCPSampler extends Abstract
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public void threadFinished() {
         log.debug("Thread Finished"); //$NON-NLS-1$
-        closeSocket();
+        tearDown();
         if (protocolHandler != null){
             protocolHandler.teardownTest();
         }
     }
+
+    /**
+     * Closes all connections, clears Map and remove thread local Map
+     */
+	private void tearDown() {
+		Map<String, Object> cp = tp.get();
+		for (Map.Entry<String, Object> element : cp.entrySet()) {
+			if(element.getKey().startsWith(TCPKEY)) {
+				try {
+					((Socket)element.getValue()).close();
+				} catch (IOException e) {
+					// NOOP
+				}
+			}
+		}
+		cp.clear();
+		tp.remove();
+	}
 }



Mime
View raw message