Bug 51932

Summary: Bug 51932 - CacheManager does not handle cache-control header with any attributes after max-age
Product: JMeter - Now in Github Reporter: Ronald Chen <ronald.chen>
Component: HTTPAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: Nightly (Please specify date)   
Target Milestone: ---   
Hardware: All   
OS: All   

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
Comment 2 The ASF infrastructure team 2022-09-24 20:37:47 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2573