diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java index 287e455da..4f3efeade 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java @@ -287,10 +287,7 @@ class CachedResponseSuitabilityChecker { return false; } - if (hasLastModifiedValidator && !lastModifiedValidatorMatches) { - return false; - } - return true; + return !hasLastModifiedValidator || lastModifiedValidatorMatches; } private boolean hasUnsupportedConditionalHeaders(final HttpRequest request) { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java index ca94c0506..b7b47ec13 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java @@ -325,11 +325,7 @@ public class CachingExecBase { } final Header h = request.getFirstHeader(HeaderConstants.MAX_FORWARDS); - if (!"0".equals(h != null ? h.getValue() : null)) { - return false; - } - - return true; + return "0".equals(h != null ? h.getValue() : null); } boolean revalidationResponseIsTooOld(final HttpResponse backendResponse, final HttpCacheEntry cacheEntry) { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java index d4b380519..be0810b05 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java @@ -159,11 +159,7 @@ class RequestProtocolCompliance { return false; } - if (requestProtocol.getMinor() > HttpVersion.HTTP_1_1.getMinor()) { - return true; - } - - return false; + return requestProtocol.getMinor() > HttpVersion.HTTP_1_1.getMinor(); } protected boolean requestVersionIsTooLow(final HttpRequest request) { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java index c6f084a47..4ecd4e962 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java @@ -192,10 +192,7 @@ class ResponseCachingPolicy { if (status >= 400 && status <= 417) { return false; } - if (status >= 500 && status <= 505) { - return false; - } - return true; + return status < 500 || status > 505; } protected boolean isExplicitlyNonCacheable(final HttpResponse response) { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/WarningValue.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/WarningValue.java index 2a6a1cbc3..adf681784 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/WarningValue.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/WarningValue.java @@ -119,8 +119,7 @@ class WarningValue { * CHAR = */ private boolean isChar(final char c) { - final int i = c; - return (i >= 0 && i <= 127); + return ((int) c >= 0 && (int) c <= 127); } /* @@ -128,8 +127,7 @@ class WarningValue { (octets 0 - 31) and DEL (127)> */ private boolean isControl(final char c) { - final int i = c; - return (i == 127 || (i >=0 && i <= 31)); + return ((int) c == 127 || ((int) c >=0 && (int) c <= 31)); } /* diff --git a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/classic/EchoHandler.java b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/classic/EchoHandler.java index ead1a30dd..7ceb218f4 100644 --- a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/classic/EchoHandler.java +++ b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/classic/EchoHandler.java @@ -87,8 +87,7 @@ public class EchoHandler implements HttpRequestHandler { contentType = contentTypeStr == null ? null : ContentType.parse(contentTypeStr); } - final ByteArrayEntity bae = new ByteArrayEntity(data, contentType); - entity = bae; + entity = new ByteArrayEntity(data, contentType); response.setCode(HttpStatus.SC_OK); response.setEntity(entity); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java index 66bac25a5..984b3a3fd 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java @@ -71,9 +71,7 @@ public final class BasicUserPrincipal implements Principal, Serializable { } if (o instanceof BasicUserPrincipal) { final BasicUserPrincipal that = (BasicUserPrincipal) o; - if (LangUtils.equals(this.username, that.username)) { - return true; - } + return LangUtils.equals(this.username, that.username); } return false; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java index 1ee470d80..dc0533c7e 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java @@ -159,11 +159,9 @@ public class NTCredentials implements Credentials, Serializable { } if (o instanceof NTCredentials) { final NTCredentials that = (NTCredentials) o; - if (LangUtils.equals(this.principal, that.principal) + return LangUtils.equals(this.principal, that.principal) && LangUtils.equals(this.workstation, that.workstation) - && LangUtils.equals(this.netbiosDomain, that.netbiosDomain)) { - return true; - } + && LangUtils.equals(this.netbiosDomain, that.netbiosDomain); } return false; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTUserPrincipal.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTUserPrincipal.java index 78e36ff2c..1df1b3f6a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTUserPrincipal.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTUserPrincipal.java @@ -99,10 +99,8 @@ public class NTUserPrincipal implements Principal, Serializable { } if (o instanceof NTUserPrincipal) { final NTUserPrincipal that = (NTUserPrincipal) o; - if (LangUtils.equals(this.username, that.username) - && LangUtils.equals(this.domain, that.domain)) { - return true; - } + return LangUtils.equals(this.username, that.username) + && LangUtils.equals(this.domain, that.domain); } return false; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/UsernamePasswordCredentials.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/UsernamePasswordCredentials.java index 46b22cc0d..967ae9f5f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/UsernamePasswordCredentials.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/UsernamePasswordCredentials.java @@ -87,9 +87,7 @@ public class UsernamePasswordCredentials implements Credentials, Serializable { } if (o instanceof UsernamePasswordCredentials) { final UsernamePasswordCredentials that = (UsernamePasswordCredentials) o; - if (LangUtils.equals(this.principal, that.principal)) { - return true; - } + return LangUtils.equals(this.principal, that.principal); } return false; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java index 08cf173f7..7d5065eab 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java @@ -333,12 +333,11 @@ public class DigestScheme implements AuthScheme, Serializable { final String checksum = formatHex(digester.digest(this.buffer.toByteArray())); buffer.reset(); buffer.append(checksum).append(":").append(nonce).append(":").append(cnonce); - a1 = buffer.toByteArray(); } else { // unq(username-value) ":" unq(realm-value) ":" passwd buffer.append(username).append(":").append(realm).append(":").append(password); - a1 = buffer.toByteArray(); } + a1 = buffer.toByteArray(); final String hasha1 = formatHex(digester.digest(a1)); buffer.reset(); @@ -383,13 +382,12 @@ public class DigestScheme implements AuthScheme, Serializable { final byte[] digestInput; if (qop == QOP_MISSING) { buffer.append(hasha1).append(":").append(nonce).append(":").append(hasha2); - digestInput = buffer.toByteArray(); } else { buffer.append(hasha1).append(":").append(nonce).append(":").append(nc).append(":") .append(cnonce).append(":").append(qop == QOP_AUTH_INT ? "auth-int" : "auth") .append(":").append(hasha2); - digestInput = buffer.toByteArray(); } + digestInput = buffer.toByteArray(); buffer.reset(); final String digest = formatHex(digester.digest(digestInput)); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java index edbf78e3f..ffaa0f06e 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java @@ -103,9 +103,7 @@ public class BasicDomainHandler implements CommonCookieAttributeHandler { if (prefix == 0) { return true; } - if (prefix > 1 && host.charAt(prefix - 1) == '.') { - return true; - } + return prefix > 1 && host.charAt(prefix - 1) == '.'; } return false; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java index 9de0403f9..693c455c4 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java @@ -75,9 +75,7 @@ public class BasicPathHandler implements CommonCookieAttributeHandler { if (uriPath.length() == normalizedCookiePath.length()) { return true; } - if (uriPath.charAt(normalizedCookiePath.length()) == '/') { - return true; - } + return uriPath.charAt(normalizedCookiePath.length()) == '/'; } return false; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java index b7acc3b52..191d4d5b5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java @@ -138,8 +138,7 @@ public final class PublicSuffixMatcher { if (domain.startsWith(".")) { return null; } - final String normalized = DnsUtils.normalize(domain); - String segment = normalized; + String segment = DnsUtils.normalize(domain); String result = null; while (segment != null) { // An exception rule takes priority over any other matching rule. diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DefaultHostnameVerifier.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DefaultHostnameVerifier.java index 75952032d..2bbfc6c75 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DefaultHostnameVerifier.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DefaultHostnameVerifier.java @@ -220,9 +220,7 @@ public final class DefaultHostnameVerifier implements HttpClientHostnameVerifier if (strict) { final String remainder = host.substring( prefix.length(), host.length() - suffix.length()); - if (remainder.contains(".")) { - return false; - } + return !remainder.contains("."); } return true; }