Created attachment 32467 [details] Error instead of no sample showing Hi, I was trying to write a simple test script for our site and found interesting issue. I think it's a bug the new feature of not recording samples for HTTP-cached responses (https://issues.apache.org/bugzilla/show_bug.cgi?id=54778). Steps to reproduce: (1) Create test with 1 HTTP Sampler request for an URL which returns Expires & Cache-Control headers in HTTP response, like: Response headers: HTTP/1.1 200 OK Date: Thu, 12 Feb 2015 22:09:52 GMT ... Vary: Accept-Encoding Expires: Sun, 09 Feb 2025 22:09:52 GMT Cache-Control: max-age=315360000, public ETag: "c7109969:dtagent7888VJDk:dtagent7888kDJV" Last-Modified: Wed, 30 Oct 2013 17:05:39 GMT Content-Type: text/css Content-Length: 320 Connection: close (2) Add "HTTP Cache Manager" element, check "Use Cache-Control / Expires header when processing GET requests" (3) Run the test with 1 thread, with 10 iterations (Loop count = 10). Result: First run executes HTTP request, server returns 200 + caching headers. Second request (and any subsequent) fails with Error in the JMeter. This was taken from element "View Results Tree": "Sampler result" tab: Thread Name: Liferay Authenticated Users Browsing 1-1 Sample Start: 1969-12-31 18:00:00 CST Load time: 0 Latency: 0 Size in bytes: 413 Headers size in bytes: 0 Body size in bytes: 413 Sample Count: 1 Error Count: 1 Response code: Non HTTP response code: java.lang.NullPointerException Response message: Non HTTP response message: null Response headers: HTTPSampleResult fields: ContentType: DataEncoding: null "Request" tab: null "Response data" tab: java.lang.NullPointerException at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1142) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1130) at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:431) at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:258) at java.lang.Thread.run(Thread.java:745) Expected: No error is shown, no sample is recorded. Workaround: If you change the behavior of JMeter cache manager using this property: cache_manager.cached_resource_mode=RETURN_200_CACHE then script works without errors (samples with response time=0 are recorded as expected). Details: Seems like issue 54778 causes this, I debugged through the code and if the main sample URL is found in the JMeter cache: org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.updateSampleResultForResourceInCache():365 ... protected HTTPSampleResult updateSampleResultForResourceInCache(HTTPSampleResult res) { switch (CACHED_RESOURCE_MODE) { case RETURN_NO_SAMPLE: return null; // line 365 case RETURN_200_CACHE: ... null is returned as the HTTPSampleResult. But then JMeter tries to set the label on this result: org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample():1142 ... public SampleResult sample() { SampleResult res = null; try { res = sample(getUrl(), getMethod(), false, 0); res.setSampleLabel(getName()); // line 1142 return res; } catch (Exception e) { return errorResult(e, new HTTPSampleResult()); } } ... This fails for NPE. Note that if the same HTTP response headers are set on a HTTP request which is a sub-sample (for example originating from "Retrieve All Embedded Resource"), this works fine -- no error is shown, no sample is recorded. I'm using OS X 10.10.2 which is not in the list of OSes.
Created attachment 32468 [details] first iteration request
Created attachment 32469 [details] second iteration - request tab
Created attachment 32470 [details] second iteration - response data tab
Date: Sun Feb 15 13:31:44 2015 New Revision: 1659922 URL: http://svn.apache.org/r1659922 Log: Bug 57579 - NullPointerException error is raised on main sample if "RETURN_NO_SAMPLE" is used (default) and "Use Cache-Control / Expires header..." is checked in HTTP Cache Manager Bugzilla Id: 57579 Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSampler.java jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java jmeter/trunk/xdocs/changes.xml
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3538