From commits-return-3296-apmail-jmeter-commits-archive=jmeter.apache.org@jmeter.apache.org Sun Sep 14 13:59:20 2014 Return-Path: X-Original-To: apmail-jmeter-commits-archive@minotaur.apache.org Delivered-To: apmail-jmeter-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3070A11FFB for ; Sun, 14 Sep 2014 13:59:20 +0000 (UTC) Received: (qmail 11599 invoked by uid 500); 14 Sep 2014 13:59:20 -0000 Delivered-To: apmail-jmeter-commits-archive@jmeter.apache.org Received: (qmail 11569 invoked by uid 500); 14 Sep 2014 13:59:20 -0000 Mailing-List: contact commits-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jmeter.apache.org Delivered-To: mailing list commits@jmeter.apache.org Received: (qmail 11560 invoked by uid 99); 14 Sep 2014 13:59:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Sep 2014 13:59:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Sep 2014 13:58:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6F70423889E0; Sun, 14 Sep 2014 13:58:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1624849 - in /jmeter/trunk: bin/jmeter.properties src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java xdocs/changes.xml Date: Sun, 14 Sep 2014 13:58:54 -0000 To: commits@jmeter.apache.org From: pmouawad@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140914135854.6F70423889E0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pmouawad Date: Sun Sep 14 13:58:53 2014 New Revision: 1624849 URL: http://svn.apache.org/r1624849 Log: Bug 54778 - HTTP Sampler should not return 204 when resource is found in Cache, make it configurable with new property cache_manager.cached_resource_mode Implemented as per dev mailing list discussion http://mail-archives.apache.org/mod_mbox/jmeter-dev/201409.mbox/%3CCAH9fUpZGrOhLZawoir4WrUFLiuJg3ZrRVJ4mpVxxS%2BahmcKQeQ%40mail.gmail.com%3E Bugzilla Id: 54778 Modified: jmeter/trunk/bin/jmeter.properties jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java jmeter/trunk/xdocs/changes.xml Modified: jmeter/trunk/bin/jmeter.properties URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1624849&r1=1624848&r2=1624849&view=diff ============================================================================== --- jmeter/trunk/bin/jmeter.properties (original) +++ jmeter/trunk/bin/jmeter.properties Sun Sep 14 13:58:53 2014 @@ -415,11 +415,22 @@ log_level.jorphan=INFO #cacheable_methods=GET # N.B. This property is currently a temporary solution for Bug 56162 -# Since 2.12, JMeter does not create anymore a Sample Result for a resource -# found in cache which is inline with what browser do -# If you need to revert to previous behaviour, you can set this property -# to true -#cache_manager.return_204_for_cached_resource=false +# Since 2.12, JMeter does not create anymore a Sample Result with 204 response +# code for a resource found in cache which is inline with what browser do. +#cache_manager.cached_resource_mode=RETURN_NO_SAMPLE + +# You can choose between 3 modes: +# RETURN_NO_SAMPLE (default) +# RETURN_200_CACHE +# RETURN_CUSTOM_STATUS + +# Those mode have the following behaviours: +# RETURN_NO_SAMPLE : this mode returns no Sample Result, it has no additional configuration +# RETURN_200_CACHE : this mode will return Sample Result with response code to 200 and response message to "(ex cache)", you can modify response message by setting +# RETURN_200_CACHE.message=(ex cache) +# RETURN_CUSTOM_STATUS : This mode lets you select what response code and message you want to return, if you use this mode you need to set those properties +# RETURN_CUSTOM_STATUS.code= +# RETURN_CUSTOM_STATUS.message= #--------------------------------------------------------------------------- # Results file configuration Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java?rev=1624849&r1=1624848&r2=1624849&view=diff ============================================================================== --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java (original) +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java Sun Sep 14 13:58:53 2014 @@ -46,12 +46,43 @@ import org.apache.jmeter.util.JMeterUtil * Base class for HTTP implementations used by the HTTPSamplerProxy sampler. */ public abstract class HTTPAbstractImpl implements Interruptible, HTTPConstantsInterface { + private static enum CachedResourceMode { + RETURN_200_CACHE("RETURN_200_CACHE"), + RETURN_NO_SAMPLE("RETURN_NO_SAMPLE"), + RETURN_CUSTOM_STATUS("RETURN_CUSTOM_STATUS"); + + private String name; + + CachedResourceMode(String name) { + this.name = name; + } + } /** * If true create a SampleResult with emply content and 204 response code */ - private static final boolean RETURN_204_FOR_INCACHE_RESOURCE = - JMeterUtils.getPropDefault("cache_manager.return_204_for_cached_resource", false); + private static final CachedResourceMode CACHED_RESOURCE_MODE = + CachedResourceMode.valueOf( + JMeterUtils.getPropDefault("cache_manager.cached_resource_mode", //$NON-NLS-1$ + CachedResourceMode.RETURN_NO_SAMPLE.toString())); + + /** + * SampleResult message when resource was in cache and mode is RETURN_200_CACHE + */ + private static final String RETURN_200_CACHE_MESSAGE = + JMeterUtils.getPropDefault("RETURN_200_CACHE.message","(ex cache)");//$NON-NLS-1$ $NON-NLS-2$ + + /** + * Custom response code for cached resource + */ + private static final String RETURN_CUSTOM_STATUS_CODE = + JMeterUtils.getProperty("RETURN_CUSTOM_STATUS.code");//$NON-NLS-1$ + + /** + * Custom response message for cached resource + */ + private static final String RETURN_CUSTOM_STATUS_MESSAGE = + JMeterUtils.getProperty("RETURN_CUSTOM_STATUS.message"); //$NON-NLS-1$ protected final HTTPSamplerBase testElement; @@ -335,14 +366,24 @@ public abstract class HTTPAbstractImpl i * @return HTTPSampleResult */ protected HTTPSampleResult updateSampleResultForResourceInCache(HTTPSampleResult res) { - if(!RETURN_204_FOR_INCACHE_RESOURCE) { - // We don't want to issue a SampleResult - // see https://issues.apache.org/bugzilla/show_bug.cgi?id=54778 - return null; - } - res.sampleEnd(); - res.setResponseNoContent(); - res.setSuccessful(true); - return res; + switch (CACHED_RESOURCE_MODE) { + case RETURN_NO_SAMPLE: + return null; + case RETURN_200_CACHE: + res.sampleEnd(); + res.setResponseCodeOK(); + res.setResponseMessage(RETURN_200_CACHE_MESSAGE); + res.setSuccessful(true); + return res; + case RETURN_CUSTOM_STATUS: + res.sampleEnd(); + res.setResponseCode(RETURN_CUSTOM_STATUS_CODE); + res.setResponseMessage(RETURN_CUSTOM_STATUS_MESSAGE); + res.setSuccessful(true); + return res; + default: + // Cannot happen + throw new IllegalStateException("Unknown CACHED_RESOURCE_MODE"); + } } } Modified: jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1624849&r1=1624848&r2=1624849&view=diff ============================================================================== --- jmeter/trunk/xdocs/changes.xml (original) +++ jmeter/trunk/xdocs/changes.xml Sun Sep 14 13:58:53 2014 @@ -117,7 +117,7 @@ A workaround is to use a Java 7 update 4
  • Since JMeter 2.12, Mail Reader Sampler will show 1 for number of samples instead of number of messages retrieved, see 56539
  • Since JMeter 2.12, when using Cache Manager, if resource is found in cache no SampleResult will be created, in previous version a SampleResult with empty content and 204 return code was returned, see 54778. -To revert to old behaviour, set property "cache_manager.return_204_for_cached_resource" to true.
  • +You can choose between different ways to handle this case, see cache_manager.cached_resource_mode in jmeter.properties.
  • Since JMeter 2.12, Log Viewer will no more clear logs when closed and will have logs available even if closed. See 56920. Read Hints and Tips > Enabling Debug logging for details on configuring this component.
@@ -135,7 +135,7 @@ for details on configuring this componen
  • 56231 - Move redirect location processing from HC3/HC4 samplers to HTTPSamplerBase#followRedirects()
  • 56207 - URLs get encoded on redirects in HC3.1 & HC4 samplers
  • 56303 - The width of target controller's combo list should be set to the current panel size, not on label size of the controllers
  • -
  • 54778 - HTTP Sampler should not return 204 when resource is found in Cache
  • +
  • 54778 - HTTP Sampler should not return 204 when resource is found in Cache, make it configurable with new property cache_manager.cached_resource_mode
  • Other Samplers