HTTPCLIENT-2152: Fixed handling of unexpected unchecked exception by the async request retry exec interceptor
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncHttpRequestRetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncHttpRequestRetryExec.java
index 5dad5e8..451e1f7 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncHttpRequestRetryExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncHttpRequestRetryExec.java
@@ -150,15 +150,15 @@
                             LOG.info("Recoverable I/O exception ({}) caught when processing request to {}",
                                     cause.getClass().getName(), route);
                         }
-                        scope.execRuntime.discardEndpoint();
-                        if (entityProducer != null) {
-                            entityProducer.releaseResources();
-                        }
-                        state.retrying = true;
-                        state.execCount++;
                         try {
+                            scope.execRuntime.discardEndpoint();
+                            if (entityProducer != null) {
+                                entityProducer.releaseResources();
+                            }
+                            state.retrying = true;
+                            state.execCount++;
                             internalExecute(state, request, entityProducer, scope, chain, asyncExecCallback);
-                        } catch (final IOException | HttpException ex) {
+                        } catch (final Exception ex) {
                             asyncExecCallback.failed(ex);
                         }
                         return;