Bug 51932 - Bug 51932 - CacheManager does not handle cache-control header with any attributes after max-age
Bug 51932 - CacheManager does not handle cache-control header with any attrib...
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: HTTP
Nightly (Please specify date)
All All
: P2 normal (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-09-30 21:02 UTC by Ronald Chen
Modified: 2011-09-30 22:45 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ronald Chen 2011-09-30 21:02:22 UTC
When JMeter makes an http request and the reponse has a cache-control header, it will crash when there are multiple directives.

For example JMeter will crash when trying to parse the header:
cache-control: public, max-age=86400, no-transform

The exception thrown with JMeter 2.5:
java.lang.NumberFormatException: For input string: "86400, no-transform"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Long.parseLong(Long.java:419)
    at java.lang.Long.parseLong(Long.java:468)
    at org.apache.jmeter.protocol.http.control.CacheManager.setCache(CacheManager.java:161)
    at org.apache.jmeter.protocol.http.control.CacheManager.saveDetails(CacheManager.java:113)
    at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sample(HTTPJavaImpl.java:589)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.downloadPageResources(HTTPSamplerBase.java:1155)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.resultProcessing(HTTPSamplerBase.java:1394)
    at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.resultProcessing(HTTPAbstractImpl.java:244)
    at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sample(HTTPJavaImpl.java:592)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.followRedirects(HTTPSamplerBase.java:1308)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.resultProcessing(HTTPSamplerBase.java:1379)
    at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.resultProcessing(HTTPAbstractImpl.java:244)
    at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sample(HTTPJavaImpl.java:592)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:999)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:985)
    at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:381)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:274)
    at java.lang.Thread.run(Thread.java:662)

I checked trunk and code didn't change for the parsing of cache-control.

It is still in there as of svn rev 1166165 /jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java

The code does not split on commas at all.  The existing code will work if max-age happens to be the last cache directive, but as you can see in the repo case it is not.

Multiple cache directives are part of the HTTP spec:
http://stackoverflow.com/questions/4762377/cache-control-headers-repeated-valid-or-not-nginx
Comment 1 Sebb 2011-09-30 22:45:35 UTC
Thanks for the report.

Fixed in SVN:

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