Author: sebb
Date: Sat Sep 17 23:23:04 2011
New Revision: 1172147
URL: http://svn.apache.org/viewvc?rev=1172147&view=rev
Log:
Bug 51380 - Control reuse of cached SSL Context from iteration to iteration
Modified:
jakarta/jmeter/trunk/bin/jmeter.properties
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerProxy.java
jakarta/jmeter/trunk/xdocs/changes.xml
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jakarta/jmeter/trunk/bin/jmeter.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/bin/jmeter.properties?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
--- jakarta/jmeter/trunk/bin/jmeter.properties (original)
+++ jakarta/jmeter/trunk/bin/jmeter.properties Sat Sep 17 23:23:04 2011
@@ -74,6 +74,10 @@ xml.parser=org.apache.xerces.parsers.SAX
# List of protocols to enable (unlikely to be needed):
#https.socket.protocols=SSLv2Hello SSLv3 TLSv1
+# Control if we allow reuse of cached SSL context between iterations
+# set the value to 'false' to reset the SSL context each iteration
+#https.use.cached.ssl.context=true
+
#---------------------------------------------------------------------------
# Look and Feel configuration
#---------------------------------------------------------------------------
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
Sat Sep 17 23:23:04 2011
@@ -251,4 +251,12 @@ public abstract class HTTPAbstractImpl i
testElement.setUseKeepAlive(b);
}
+ /**
+ * Called by testIterationStart if the SSL Context was reset.
+ *
+ * This implementation does nothing.
+ */
+ protected void notifySSLContextWasReset() {
+ // NOOP
+ }
}
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
Sat Sep 17 23:23:04 2011
@@ -1071,6 +1071,14 @@ public class HTTPHC3Impl extends HTTPHCA
public void threadFinished() {
log.debug("Thread Finished");
+ closeThreadLocalConnections();
+ }
+
+
+ /**
+ *
+ */
+ private void closeThreadLocalConnections() {
// Does not need to be synchronised, as all access is from same thread
Map<HostConfiguration, HttpClient> map = httpClients.get();
@@ -1100,4 +1108,13 @@ public class HTTPHC3Impl extends HTTPHCA
return client != null;
}
+ /**
+ * {@inheritDoc}
+ * This implementation closes all local connections.
+ */
+ @Override
+ protected void notifySSLContextWasReset() {
+ log.debug("freeThreadConnections called");
+ closeThreadLocalConnections();
+ }
}
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Sat Sep 17 23:23:04 2011
@@ -1047,6 +1047,13 @@ public class HTTPHC4Impl extends HTTPHCA
@Override
public void threadFinished() {
log.debug("Thread Finished");
+ closeThreadLocalConnections();
+ }
+
+ /**
+ *
+ */
+ private void closeThreadLocalConnections() {
// Does not need to be synchronised, as all access is from same thread
Map<HttpClientKey, HttpClient> map = HTTPCLIENTS.get();
if ( map != null ) {
@@ -1069,5 +1076,11 @@ public class HTTPHC4Impl extends HTTPHCA
}
return request != null;
}
-
+
+ /** {@inheritDoc} */
+ @Override
+ protected void notifySSLContextWasReset() {
+ log.debug("closeThreadLocalConnections called");
+ closeThreadLocalConnections();
+ }
}
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
Sat Sep 17 23:23:04 2011
@@ -73,4 +73,13 @@ public class HTTPSampler2 extends HTTPSa
protected void setSavedClient(HttpClient savedClient) {
hc.savedClient = savedClient;
}
+
+ /**
+ * {@inheritDoc}
+ * This implementation forwards to the implementation class.
+ */
+ @Override
+ protected void notifySSLContextWasReset() {
+ hc.notifySSLContextWasReset();
+ }
}
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
Sat Sep 17 23:23:04 2011
@@ -70,6 +70,8 @@ import org.apache.jmeter.testelement.pro
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.testelement.property.TestElementProperty;
import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.util.JsseSSLManager;
+import org.apache.jmeter.util.SSLManager;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.util.JOrphanUtils;
import org.apache.log.Logger;
@@ -233,6 +235,10 @@ public abstract class HTTPSamplerBase ex
private static final String RESPONSE_PARSERS= // list of parsers
JMeterUtils.getProperty("HTTPResponse.parsers");//$NON-NLS-1$
+ // Control reuse of cached SSL Context in subsequent iterations
+ private static final boolean USE_CACHED_SSL_CONTEXT =
+ JMeterUtils.getPropDefault("https.use.cached.ssl.context",
true);//$NON-NLS-1$
+
static{
String []parsers = JOrphanUtils.split(RESPONSE_PARSERS, " " , true);//
returns empty array for null
for (int i=0;i<parsers.length;i++){
@@ -258,6 +264,9 @@ public abstract class HTTPSamplerBase ex
parsersForType.put("text/html", ""); //$NON-NLS-1$ //$NON-NLS-2$
log.info("No response parsers defined: text/html only will be
scanned for embedded resources");
}
+
+ log.info("Reuse SSL session context on subsequent iterations: "
+ + USE_CACHED_SSL_CONTEXT);
}
// Bug 49083
@@ -1234,11 +1243,25 @@ public abstract class HTTPSamplerBase ex
testEnded();
}
- /**
- * {@inheritDoc}
- */
- public void testIterationStart(LoopIterationEvent event) {
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void testIterationStart(LoopIterationEvent event) {
+ if (!USE_CACHED_SSL_CONTEXT) {
+ JsseSSLManager sslMgr = (JsseSSLManager)
SSLManager.getInstance();
+ sslMgr.resetContext();
+ notifySSLContextWasReset();
+ }
+ }
+
+ /**
+ * Called by testIterationStart if the SSL Context was reset.
+ *
+ * This implementation does nothing.
+ */
+ protected void notifySSLContextWasReset() {
+ // NOOP
+ }
/**
* {@inheritDoc}
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerProxy.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerProxy.java?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerProxy.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerProxy.java
Sat Sep 17 23:23:04 2011
@@ -78,4 +78,15 @@ public final class HTTPSamplerProxy exte
}
return false;
}
+
+ /**
+ * {@inheritDoc}
+ * This implementation forwards to the implementation class.
+ */
+ @Override
+ protected void notifySSLContextWasReset() {
+ if (impl != null) {
+ impl.notifySSLContextWasReset();
+ }
+ }
}
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sat Sep 17 23:23:04 2011
@@ -128,6 +128,7 @@ This can be overridden by setting the JM
<h3>HTTP Samplers</h3>
<ul>
+<li>Bug 51380 - Control reuse of cached SSL Context from iteration to
iteration</li>
</ul>
<h3>Other samplers</h3>
Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1172147&r1=1172146&r2=1172147&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Sat Sep 17
23:23:04 2011
@@ -154,6 +154,13 @@ Latency is set to the time it takes to l
<pre>
https.sessioncontext.shared=true
</pre>
+ By default, the SSL context is retained for the duration of the test.
+ In versions of JMeter from 2.5.1, the SSL session can be optionally
reset for each test iteration.
+ To enable this, set the JMeter property:
+<pre>
+https.use.cached.ssl.context=false
+</pre>
+ Note: this does not apply to the Java HTTP implementation.
</p>
<p>
JMeter defaults to the SSL protocol level TLS.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]