You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/12/21 17:33:15 UTC
svn commit: r1775519 -
/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Author: pmouawad
Date: Wed Dec 21 17:33:15 2016
New Revision: 1775519
URL: http://svn.apache.org/viewvc?rev=1775519&view=rev
Log:
Sonar : Fix errors and code smells
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1775519&r1=1775518&r2=1775519&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java Wed Dec 21 17:33:15 2016
@@ -179,21 +179,13 @@ public class HTTPHC4Impl extends HTTPHCA
* would throw org.apache.http.impl.conn.ConnectionShutdownException
* See <a href="https://bz.apache.org/jira/browse/HTTPCLIENT-1081">HTTPCLIENT-1081</a>
*/
- private static final HttpResponseInterceptor METRICS_SAVER = new HttpResponseInterceptor(){
- @Override
- public void process(HttpResponse response, HttpContext context)
- throws HttpException, IOException {
- HttpConnectionMetrics metrics = ((HttpConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION)).getMetrics();
- context.setAttribute(CONTEXT_METRICS, metrics);
- }
+ private static final HttpResponseInterceptor METRICS_SAVER = (HttpResponse response, HttpContext context) -> {
+ HttpConnectionMetrics metrics = ((HttpConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION)).getMetrics();
+ context.setAttribute(CONTEXT_METRICS, metrics);
};
- private static final HttpRequestInterceptor METRICS_RESETTER = new HttpRequestInterceptor() {
- @Override
- public void process(HttpRequest request, HttpContext context)
- throws HttpException, IOException {
- HttpConnectionMetrics metrics = ((HttpConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION)).getMetrics();
- metrics.reset();
- }
+ private static final HttpRequestInterceptor METRICS_RESETTER = (HttpRequest request, HttpContext context) -> {
+ HttpConnectionMetrics metrics = ((HttpConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION)).getMetrics();
+ metrics.reset();
};
@@ -398,10 +390,8 @@ public class HTTPHC4Impl extends HTTPHCA
res.sampleStart();
final CacheManager cacheManager = getCacheManager();
- if (cacheManager != null && HTTPConstants.GET.equalsIgnoreCase(method)) {
- if (cacheManager.inCache(url)) {
- return updateSampleResultForResourceInCache(res);
- }
+ if (cacheManager != null && HTTPConstants.GET.equalsIgnoreCase(method) && cacheManager.inCache(url)) {
+ return updateSampleResultForResourceInCache(res);
}
try {
@@ -457,10 +447,10 @@ public class HTTPHC4Impl extends HTTPHCA
// record some sizes to allow HTTPSampleResult.getBytes() with different options
HttpConnectionMetrics metrics = (HttpConnectionMetrics) localContext.getAttribute(CONTEXT_METRICS);
long headerBytes =
- res.getResponseHeaders().length() // condensed length (without \r)
- + httpResponse.getAllHeaders().length // Add \r for each header
- + 1 // Add \r for initial header
- + 2; // final \r\n before data
+ (long)res.getResponseHeaders().length() // condensed length (without \r)
+ + (long) httpResponse.getAllHeaders().length // Add \r for each header
+ + 1L // Add \r for initial header
+ + 2L; // final \r\n before data
long totalBytes = metrics.getReceivedBytesCount();
res.setHeadersSize((int)headerBytes);
res.setBodySize(totalBytes - headerBytes);