You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2020/01/09 16:45:12 UTC
[httpcomponents-client] branch master updated: Misc clean ups.
(#200)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/master by this push:
new 071fa68 Misc clean ups. (#200)
071fa68 is described below
commit 071fa68a3c0186455c804a3fe4cfb89513b807df
Author: Gary Gregory <ga...@users.noreply.github.com>
AuthorDate: Thu Jan 9 11:45:04 2020 -0500
Misc clean ups. (#200)
---
.../hc/client5/http/ConnectExceptionSupport.java | 7 +++----
.../java/org/apache/hc/client5/http/HttpRoute.java | 3 +--
.../hc/client5/http/entity/DecompressingEntity.java | 3 +--
.../hc/client5/http/entity/mime/FormBodyPart.java | 1 +
.../http/impl/routing/DefaultRoutePlanner.java | 3 +--
.../hc/client5/http/psl/PublicSuffixMatcher.java | 3 +--
.../hc/client5/http/routing/RoutingSupport.java | 19 +++++++++----------
.../client5/http/ssl/ConscryptClientTlsStrategy.java | 3 +--
.../hc/client5/http/ssl/TlsSessionValidator.java | 3 +--
9 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectExceptionSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectExceptionSupport.java
index 49ab397..b7b72d8 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectExceptionSupport.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectExceptionSupport.java
@@ -74,11 +74,10 @@ public final class ConnectExceptionSupport {
final IOException ex = createConnectTimeoutException(cause, namedEndpoint, remoteAddresses);
ex.initCause(cause);
return ex;
- } else {
- final IOException ex = createHttpHostConnectException(cause, namedEndpoint, remoteAddresses);
- ex.setStackTrace(cause.getStackTrace());
- return ex;
}
+ final IOException ex = createHttpHostConnectException(cause, namedEndpoint, remoteAddresses);
+ ex.setStackTrace(cause.getStackTrace());
+ return ex;
} else {
return cause;
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java b/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java
index ce3a6be..6651640 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java
@@ -213,9 +213,8 @@ public final class HttpRoute implements RouteInfo, Cloneable {
Args.check(hop < hopcount, "Hop index exceeds tracked route length");
if (hop < hopcount - 1) {
return this.proxyChain.get(hop);
- } else {
- return this.targetHost;
}
+ return this.targetHost;
}
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java
index 5b10188..38f51cd 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java
@@ -67,8 +67,7 @@ public class DecompressingEntity extends HttpEntityWrapper {
}
private InputStream getDecompressingStream() throws IOException {
- final InputStream in = super.getContent();
- return new LazyDecompressingInputStream(in, inputStreamFactory);
+ return new LazyDecompressingInputStream(super.getContent(), inputStreamFactory);
}
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPart.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPart.java
index 9f3e926..5edb67c 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPart.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPart.java
@@ -51,6 +51,7 @@ public class FormBodyPart extends MultipartPart {
return this.name;
}
+ @Override
public void addField(final String name, final String value) {
Args.notNull(name, "Field name");
super.addField(name, value);
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java
index 5471476..3ee5e07 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/DefaultRoutePlanner.java
@@ -77,9 +77,8 @@ public class DefaultRoutePlanner implements HttpRoutePlanner {
final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
if (proxy == null) {
return new HttpRoute(target, determineLocalAddress(target, context), secure);
- } else {
- return new HttpRoute(target, determineLocalAddress(proxy, context), proxy, secure);
}
+ return new HttpRoute(target, determineLocalAddress(proxy, context), proxy, secure);
}
/**
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 bb1fdcd..628ee78 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
@@ -106,9 +106,8 @@ public final class PublicSuffixMatcher {
final DomainType domainType = map.get(rule);
if (domainType == null) {
return false;
- } else {
- return expectedType == null || domainType.equals(expectedType);
}
+ return expectedType == null || domainType.equals(expectedType);
}
private boolean hasRule(final String rule, final DomainType expectedType) {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java
index 965a8c7..4205a19 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java
@@ -51,18 +51,17 @@ public final class RoutingSupport {
throw new ProtocolException("Protocol scheme is not specified");
}
return new HttpHost(scheme, authority);
- } else {
- try {
- final URI requestURI = request.getUri();
- if (requestURI.isAbsolute()) {
- final HttpHost httpHost = URIUtils.extractHost(requestURI);
- if (httpHost == null) {
- throw new ProtocolException("URI does not specify a valid host name: " + requestURI);
- }
- return httpHost;
+ }
+ try {
+ final URI requestURI = request.getUri();
+ if (requestURI.isAbsolute()) {
+ final HttpHost httpHost = URIUtils.extractHost(requestURI);
+ if (httpHost == null) {
+ throw new ProtocolException("URI does not specify a valid host name: " + requestURI);
}
- } catch (final URISyntaxException ignore) {
+ return httpHost;
}
+ } catch (final URISyntaxException ignore) {
}
return null;
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ConscryptClientTlsStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ConscryptClientTlsStrategy.java
index 9ec8dbf..e446b08 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ConscryptClientTlsStrategy.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ConscryptClientTlsStrategy.java
@@ -101,9 +101,8 @@ public class ConscryptClientTlsStrategy extends AbstractClientTlsStrategy {
TlsDetails createTlsDetails(final SSLEngine sslEngine) {
if (Conscrypt.isConscrypt(sslEngine)) {
return new TlsDetails(sslEngine.getSession(), Conscrypt.getApplicationProtocol(sslEngine));
- } else {
- return null;
}
+ return null;
}
public static boolean isSupported() {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsSessionValidator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsSessionValidator.java
index b2d49aa..4611bab 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsSessionValidator.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/TlsSessionValidator.java
@@ -117,9 +117,8 @@ final class TlsSessionValidator {
final ProtocolVersion tls = TLS.parse(sslsession.getProtocol());
if (tls.greaterEquals(TLS.V_1_3.version)) {
return;
- } else {
- throw ex;
}
+ throw ex;
} catch (final ParseException ex2) {
throw ex;
}