Author: sebb
Date: Fri Sep 30 22:44:46 2011
New Revision: 1177871
URL: http://svn.apache.org/viewvc?rev=1177871&view=rev
Log:
Bug 51932 - CacheManager does not handle cache-control header with any
attributes after max-age
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
jakarta/jmeter/trunk/xdocs/changes.xml
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java?rev=1177871&r1=1177870&r2=1177871&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
Fri Sep 30 22:44:46 2011
@@ -158,8 +158,11 @@ public class CacheManager extends Config
final String MAX_AGE = "max-age=";
// TODO - check for other CacheControl attributes?
if (cacheControl != null && cacheControl.contains("public") &&
cacheControl.contains(MAX_AGE)) {
- long maxAge =
Long.parseLong(cacheControl.substring(cacheControl.indexOf(MAX_AGE)+MAX_AGE.length()))*1000;
- expiresDate=new Date(System.currentTimeMillis()+maxAge);
+ long maxAgeInSecs = Long.parseLong(
+
cacheControl.substring(cacheControl.indexOf(MAX_AGE)+MAX_AGE.length())
+ .split("[, ]")[0] // Bug 51932 - allow for
optional trailing attributes
+ );
+ expiresDate=new
Date(System.currentTimeMillis()+maxAgeInSecs*1000);
} else if (expires != null) {
try {
expiresDate = DateUtil.parseDate(expires);
Modified:
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java?rev=1177871&r1=1177870&r2=1177871&view=diff
==============================================================================
---
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
(original)
+++
jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
Fri Sep 30 22:44:46 2011
@@ -226,6 +226,18 @@ public class TestCacheManager extends JM
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
}
+ public void testCacheHttpClientBug51932() throws Exception{
+ this.cacheManager.setUseExpires(true);
+ this.cacheManager.testIterationStart(null);
+ assertNull("Should not find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid
entry",this.cacheManager.inCache(url));
+ ((HttpMethodStub)httpMethod).expires=makeDate(new
Date(System.currentTimeMillis()));
+ ((HttpMethodStub)httpMethod).cacheControl="public, max-age=10,
no-transform";
+ this.cacheManager.saveDetails(httpMethod, sampleResultOK);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertTrue("Should find valid entry",this.cacheManager.inCache(url));
+ }
+
public void testGetClearEachIteration() throws Exception {
assertFalse("Should default not to clear after each iteration.",
this.cacheManager.getClearEachIteration());
this.cacheManager.setClearEachIteration(true);
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1177871&r1=1177870&r2=1177871&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Fri Sep 30 22:44:46 2011
@@ -29,6 +29,13 @@
Earlier changes are detailed in the <a href="changes_history.html">History of
Previous Changes</a>.
</note>
+<h1>Version 2.5.2?</h1>
+<p>temporary section to collect changes while release vote is in progress</p>
+<ul>
+<li>Bug 51932 - CacheManager does not handle cache-control header with any
attributes after max-age</li>
+</ul>
+
+
<!-- =================== -->
<h1>Version 2.5.1</h1>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]