diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/CacheResponseStatus.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/CacheResponseStatus.java index aa94bdb29..75998e7e2 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/CacheResponseStatus.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/CacheResponseStatus.java @@ -50,6 +50,6 @@ public enum CacheResponseStatus { /** The response was generated from the cache after validating the * entry with the origin server. */ - VALIDATED; + VALIDATED } diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java index 53dc047ce..d3d1177dc 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java @@ -337,7 +337,7 @@ public class CachingExec implements ClientExecChain { } final Map variants = getExistingCacheVariants(target, request); - if (variants != null && variants.size() > 0) { + if (variants != null && !variants.isEmpty()) { return negotiateResponseFromVariants(route, request, context, execAware, variants); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestSHA256HashingScheme.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestSHA256HashingScheme.java index 28f7b4935..ea75c9b78 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestSHA256HashingScheme.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestSHA256HashingScheme.java @@ -37,7 +37,7 @@ public class TestSHA256HashingScheme { public void canHash() { final SHA256KeyHashingScheme impl = new SHA256KeyHashingScheme(); final String result = impl.hash("hello, hashing world"); - assertTrue(result != null && result.length() > 0); + assertTrue(result != null && !result.isEmpty()); } } diff --git a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiHttpRoutePlanner.java b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiHttpRoutePlanner.java index 8e6488fef..f57d68e53 100644 --- a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiHttpRoutePlanner.java +++ b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiHttpRoutePlanner.java @@ -188,7 +188,7 @@ final class OSGiHttpRoutePlanner extends DefaultRoutePlanner { } private static int toInt(final String value, final int max) { - if (value == null || value.length() == 0) { + if (value == null || value.isEmpty()) { return max; } diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java index 54c792f02..40339aae1 100644 --- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java +++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java @@ -148,7 +148,7 @@ public class WindowsNegotiateScheme extends AuthSchemeBase { final int endIndex) throws MalformedChallengeException { this.challenge = buffer.substringTrimmed(beginIndex, endIndex); - if (this.challenge.length() == 0) { + if (this.challenge.isEmpty()) { if (clientCred != null) { if (continueNeeded) { throw new RuntimeException("Unexpected token"); @@ -192,7 +192,7 @@ public class WindowsNegotiateScheme extends AuthSchemeBase { dispose(); throw new AuthenticationException("Authentication Failed", t); } - } else if (this.challenge == null || this.challenge.length() == 0) { + } else if (this.challenge == null || this.challenge.isEmpty()) { dispose(); throw new AuthenticationException("Authentication Failed"); } else { diff --git a/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java b/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java index 91dc2630b..76a73be2a 100644 --- a/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java +++ b/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java @@ -59,7 +59,7 @@ public class NTUserPrincipal implements Principal, Serializable { } else { this.domain = null; } - if (this.domain != null && this.domain.length() > 0) { + if (this.domain != null && !this.domain.isEmpty()) { final StringBuilder buffer = new StringBuilder(); buffer.append(this.domain); buffer.append('\\'); diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java index 75dd89db3..9dad61495 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java @@ -85,7 +85,7 @@ public abstract class HttpRequestBase extends AbstractExecutionAwareRequest if (uri != null) { uritext = uri.toASCIIString(); } - if (uritext == null || uritext.length() == 0) { + if (uritext == null || uritext.isEmpty()) { uritext = "/"; } return new BasicRequestLine(method, uritext, ver); diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java index 6130096de..f0e978188 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java @@ -110,7 +110,7 @@ public class HttpRequestWrapper extends AbstractHttpMessage implements HttpUriRe } else { requestUri = this.original.getRequestLine().getUri(); } - if (requestUri == null || requestUri.length() == 0) { + if (requestUri == null || requestUri.isEmpty()) { requestUri = "/"; } return new BasicRequestLine(this.method, requestUri, getProtocolVersion()); diff --git a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java index 39a1d343e..597dc2668 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java @@ -50,7 +50,7 @@ public class CloneUtils { final Class clazz = obj.getClass (); final Method m; try { - m = clazz.getMethod("clone", (Class[]) null); + m = clazz.getMethod("clone", (Class[]) null); } catch (final NoSuchMethodException ex) { throw new NoSuchMethodError(ex.getMessage()); } diff --git a/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java b/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java index 014585d49..e76590a19 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java @@ -105,11 +105,11 @@ public class Rfc3492Idn implements Idn { input = input.substring(lastdelim + 1); } - while (input.length() > 0) { + while (!input.isEmpty()) { final int oldi = i; int w = 1; for (int k = base;; k += base) { - if (input.length() == 0) { + if (input.isEmpty()) { break; } final char c = input.charAt(0); diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java index 169465769..b7816ae8f 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java @@ -91,7 +91,7 @@ public class URIBuilder { } private List parseQuery(final String query, final Charset charset) { - if (query != null && query.length() > 0) { + if (query != null && !query.isEmpty()) { return URLEncodedUtils.parse(query, charset); } return null; diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java index 131f20d7a..deb2a57f9 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java @@ -223,7 +223,7 @@ public class URIUtils { if (s.startsWith("?")) { return resolveReferenceStartingWithQueryString(baseURI, ref); } - final boolean emptyReference = s.length() == 0; + final boolean emptyReference = s.isEmpty(); if (emptyReference) { ref = URI.create("#"); } @@ -268,7 +268,7 @@ public class URIUtils { final String[] inputSegments = path.split("/"); final Stack outputSegments = new Stack(); for (final String inputSegment : inputSegments) { - if ((inputSegment.length() == 0) + if ((inputSegment.isEmpty()) || (".".equals(inputSegment))) { // Do nothing } else if ("..".equals(inputSegment)) { diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java index 08ed4450d..3eda38f05 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java @@ -86,7 +86,7 @@ public class URLEncodedUtils { */ public static List parse(final URI uri, final String charset) { final String query = uri.getRawQuery(); - if (query != null && query.length() > 0) { + if (query != null && !query.isEmpty()) { final List result = new ArrayList(); final Scanner scanner = new Scanner(query); parse(result, scanner, QP_SEP_PATTERN, charset); @@ -112,7 +112,7 @@ public class URLEncodedUtils { final ContentType contentType = ContentType.get(entity); if (contentType != null && contentType.getMimeType().equalsIgnoreCase(CONTENT_TYPE)) { final String content = EntityUtils.toString(entity, Consts.ASCII); - if (content != null && content.length() > 0) { + if (content != null && !content.isEmpty()) { Charset charset = contentType.getCharset(); if (charset == null) { charset = HTTP.DEF_CONTENT_CHARSET; @@ -247,7 +247,7 @@ public class URLEncodedUtils { final List list = new ArrayList(); while (!cursor.atEnd()) { final NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, parameterSeparator); - if (nvp.getName().length() > 0) { + if (!nvp.getName().isEmpty()) { list.add(new BasicNameValuePair( decodeFormFields(nvp.getName(), charset), decodeFormFields(nvp.getValue(), charset))); diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java b/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java index 860514967..e721f8118 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java @@ -52,7 +52,7 @@ public final class CookieOrigin { Args.notNull(path, "Path"); this.host = host.toLowerCase(Locale.ENGLISH); this.port = port; - if (path.trim().length() != 0) { + if (!path.trim().isEmpty()) { this.path = path; } else { this.path = "/"; diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java index 78d721d31..1ec4957d4 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java @@ -104,7 +104,7 @@ public class NTLMScheme extends AuthSchemeBase { final CharArrayBuffer buffer, final int beginIndex, final int endIndex) throws MalformedChallengeException { this.challenge = buffer.substringTrimmed(beginIndex, endIndex); - if (this.challenge.length() == 0) { + if (this.challenge.isEmpty()) { if (this.state == State.UNINITIATED) { this.state = State.CHALLENGE_RECEIVED; } else { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java index f355a8183..b63404274 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java @@ -116,7 +116,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable { public CloseableHttpResponse execute( final HttpHost target, final HttpRequest request) throws IOException, ClientProtocolException { - return doExecute(target, request, (HttpContext) null); + return doExecute(target, request, null); } /** diff --git a/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java b/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java index af4857115..3de80594b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java @@ -135,7 +135,7 @@ public class RequestWrapper extends AbstractHttpMessage implements HttpUriReques if (uri != null) { uritext = uri.toASCIIString(); } - if (uritext == null || uritext.length() == 0) { + if (uritext == null || uritext.isEmpty()) { uritext = "/"; } return new BasicRequestLine(method, uritext, ver); diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java index 85ed39d18..74444364f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java @@ -53,7 +53,7 @@ public class BasicDomainHandler implements CookieAttributeHandler { if (value == null) { throw new MalformedCookieException("Missing value for domain attribute"); } - if (value.trim().length() == 0) { + if (value.trim().isEmpty()) { throw new MalformedCookieException("Blank value for domain attribute"); } cookie.setDomain(value); diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java b/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java index cf6f4c358..0d1cdaa8e 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java @@ -72,7 +72,7 @@ public abstract class CookieSpecBase extends AbstractCookieSpec { for (final HeaderElement headerelement : elems) { final String name = headerelement.getName(); final String value = headerelement.getValue(); - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new MalformedCookieException("Cookie name may not be empty"); } diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java index c935d16f5..0d811d3bf 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java @@ -128,7 +128,7 @@ public class PublicSuffixFilter implements CookieAttributeHandler { break; } domain = "*" + domain.substring(nextdot); - } while (domain.length() > 0); + } while (!domain.isEmpty()); return false; } diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java index b89f29193..13e0a4f49 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java @@ -66,7 +66,7 @@ public class PublicSuffixListParser { while (more) { more = readLine(r, sb); String line = sb.toString(); - if (line.length() == 0) { + if (line.isEmpty()) { continue; } if (line.startsWith("//")) diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java index 3364a60dc..0a3a177e7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java @@ -55,7 +55,7 @@ public class RFC2109DomainHandler implements CookieAttributeHandler { if (value == null) { throw new MalformedCookieException("Missing value for domain attribute"); } - if (value.trim().length() == 0) { + if (value.trim().isEmpty()) { throw new MalformedCookieException("Blank value for domain attribute"); } cookie.setDomain(value); diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java index 3d3395559..2abcd0e60 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java @@ -52,7 +52,7 @@ public class RFC2109VersionHandler extends AbstractCookieAttributeHandler { if (value == null) { throw new MalformedCookieException("Missing value for version attribute"); } - if (value.trim().length() == 0) { + if (value.trim().isEmpty()) { throw new MalformedCookieException("Blank value for version attribute"); } try { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java index 3d52846a5..6e352d18e 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java @@ -63,7 +63,7 @@ public class RFC2965DomainAttributeHandler implements CookieAttributeHandler { throw new MalformedCookieException( "Missing value for domain attribute"); } - if (domain.trim().length() == 0) { + if (domain.trim().isEmpty()) { throw new MalformedCookieException( "Blank value for domain attribute"); } diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java index 0588fda50..224f2e4d7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java @@ -110,7 +110,7 @@ public class RFC2965PortAttributeHandler implements CookieAttributeHandler { Args.notNull(cookie, "Cookie"); if (cookie instanceof SetCookie2) { final SetCookie2 cookie2 = (SetCookie2) cookie; - if (portValue != null && portValue.trim().length() > 0) { + if (portValue != null && !portValue.trim().isEmpty()) { final int[] ports = parsePortAttribute(portValue); cookie2.setPorts(ports); } diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java index a341ff382..46edb3b25 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java @@ -99,7 +99,7 @@ public class RFC2965Spec extends RFC2109Spec { for (final HeaderElement headerelement : elems) { final String name = headerelement.getName(); final String value = headerelement.getValue(); - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new MalformedCookieException("Cookie name may not be empty"); } @@ -163,7 +163,7 @@ public class RFC2965Spec extends RFC2109Spec { if (s != null) { buffer.append("; $Port"); buffer.append("=\""); - if (s.trim().length() > 0) { + if (!s.trim().isEmpty()) { final int[] ports = cookie.getPorts(); if (ports != null) { final int len = ports.length; diff --git a/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java b/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java index 14eba94e1..7b13e65e8 100644 --- a/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java +++ b/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java @@ -119,7 +119,7 @@ public class TestExceptions { public void testConnectionPoolTimeoutException() { final String msg = "sample exception message"; ConnectionPoolTimeoutException cptx = new ConnectionPoolTimeoutException(msg); - Assert.assertFalse(cptx.toString().indexOf(msg) < 0); + Assert.assertFalse(!cptx.toString().contains(msg)); Assert.assertSame(msg, cptx.getMessage()); cptx = new ConnectionPoolTimeoutException(); diff --git a/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java b/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java index a42964506..54fb28815 100644 --- a/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java +++ b/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java @@ -111,15 +111,15 @@ public class TestHttpRoute { final String routestr = route.toString(); Assert.assertTrue("missing target in toString", - routestr.indexOf(TARGET1.getHostName()) >= 0); + routestr.contains(TARGET1.getHostName())); Assert.assertTrue("missing local address in toString", - routestr.indexOf(LOCAL41.toString()) >= 0); + routestr.contains(LOCAL41.toString())); Assert.assertTrue("missing proxy 1 in toString", - routestr.indexOf(PROXY1.getHostName()) >= 0); + routestr.contains(PROXY1.getHostName())); Assert.assertTrue("missing proxy 2 in toString", - routestr.indexOf(PROXY2.getHostName()) >= 0); + routestr.contains(PROXY2.getHostName())); Assert.assertTrue("missing proxy 3 in toString", - routestr.indexOf(PROXY3.getHostName()) >= 0); + routestr.contains(PROXY3.getHostName())); } @Test diff --git a/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java b/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java index a81b2f880..30bc30322 100644 --- a/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java +++ b/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java @@ -701,13 +701,13 @@ public class TestRouteTracker { if (rt.getLocalAddress() != null) { final String las = rt.getLocalAddress().toString(); Assert.assertFalse("no local address in toString(): " + rts, - rts.indexOf(las) < 0); + !rts.contains(las)); } for (int i=0; i - - org.codehaus.mojo - clirr-maven-plugin - - ${api.comparison.version} - - org.apache.maven.plugins maven-checkstyle-plugin