From 3b4258817aa188e45f3b064c0ea714fc9620ce91 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sun, 5 Aug 2018 11:33:36 -0600 Subject: [PATCH] Remove exceptions not thrown from method signatures. Don't nest unnecessarily. --- .../org/apache/http/impl/execchain/MainClientExec.java | 6 ++---- .../apache/http/impl/execchain/MinimalClientExec.java | 9 +++------ .../apache/http/impl/execchain/ResponseEntityProxy.java | 4 ++-- .../java/org/apache/http/impl/execchain/RetryExec.java | 3 +-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java index 99dd347b2..271d796c4 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java @@ -178,9 +178,8 @@ public class MainClientExec implements ClientExecChain { if (execAware.isAborted()) { connRequest.cancel(); throw new RequestAbortedException("Request aborted"); - } else { - execAware.setCancellable(connRequest); } + execAware.setCancellable(connRequest); } final RequestConfig config = context.getRequestConfig(); @@ -336,9 +335,8 @@ public class MainClientExec implements ClientExecChain { // connection not needed and (assumed to be) in re-usable state connHolder.releaseConnection(); return new HttpResponseProxy(response, null); - } else { - return new HttpResponseProxy(response, connHolder); } + return new HttpResponseProxy(response, connHolder); } catch (final ConnectionShutdownException ex) { final InterruptedIOException ioex = new InterruptedIOException( "Connection has been shut down"); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java index 113c6956c..e2fbcc01c 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java @@ -146,9 +146,8 @@ public class MinimalClientExec implements ClientExecChain { if (execAware.isAborted()) { connRequest.cancel(); throw new RequestAbortedException("Request aborted"); - } else { - execAware.setCancellable(connRequest); } + execAware.setCancellable(connRequest); } final RequestConfig config = context.getRequestConfig(); @@ -174,9 +173,8 @@ public class MinimalClientExec implements ClientExecChain { if (execAware.isAborted()) { releaseTrigger.close(); throw new RequestAbortedException("Request aborted"); - } else { - execAware.setCancellable(releaseTrigger); } + execAware.setCancellable(releaseTrigger); } if (!managedConn.isOpen()) { @@ -230,9 +228,8 @@ public class MinimalClientExec implements ClientExecChain { // connection not needed and (assumed to be) in re-usable state releaseTrigger.releaseConnection(); return new HttpResponseProxy(response, null); - } else { - return new HttpResponseProxy(response, releaseTrigger); } + return new HttpResponseProxy(response, releaseTrigger); } catch (final ConnectionShutdownException ex) { final InterruptedIOException ioex = new InterruptedIOException( "Connection has been shut down"); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java index 7013e09eb..6f53c2314 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java @@ -65,13 +65,13 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher } } - private void abortConnection() throws IOException { + private void abortConnection() { if (this.connHolder != null) { this.connHolder.abortConnection(); } } - public void releaseConnection() throws IOException { + public void releaseConnection() { if (this.connHolder != null) { this.connHolder.releaseConnection(); } diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java index 201733e9b..42039fb0a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java @@ -118,9 +118,8 @@ public class RetryExec implements ClientExecChain { route.getTargetHost().toHostString() + " failed to respond"); updatedex.setStackTrace(ex.getStackTrace()); throw updatedex; - } else { - throw ex; } + throw ex; } } }