This is an automated email from the ASF dual-hosted git repository.

amagyar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new b9b732933 KNOX-2951 - During discovery if cm is not reachable and 
throws SocketException then retry is not happening (#788)
b9b732933 is described below

commit b9b7329339a9c5376c51cf87abf3bdf2c9f05198
Author: Attila Magyar <[email protected]>
AuthorDate: Tue Sep 5 12:38:57 2023 +0200

    KNOX-2951 - During discovery if cm is not reachable and throws 
SocketException then retry is not happening (#788)
---
 .../topology/discovery/cm/ClouderaManagerServiceDiscovery.java    | 8 ++++++--
 .../discovery/cm/ClouderaManagerServiceDiscoveryTest.java         | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscovery.java
 
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscovery.java
index c03b36938..298de2c29 100644
--- 
a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscovery.java
+++ 
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscovery.java
@@ -40,7 +40,9 @@ import 
org.apache.knox.gateway.topology.discovery.ServiceDiscovery;
 import org.apache.knox.gateway.topology.discovery.ServiceDiscoveryConfig;
 import 
org.apache.knox.gateway.topology.discovery.cm.monitor.ClouderaManagerClusterConfigurationMonitor;
 
-import java.net.ConnectException;
+import java.net.SocketException;
+import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
 import java.security.KeyStore;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -234,7 +236,9 @@ public class ClouderaManagerServiceDiscovery implements 
ServiceDiscovery, Cluste
     if (maxRetryAttempts > 0 && maxRetryAttempts > 
retryAttempts.getAndIncrement()) {
       final Throwable cause = e.getCause();
       if (cause != null) {
-        if (ConnectException.class.isAssignableFrom(cause.getClass())) {
+        if (SocketException.class.isAssignableFrom(cause.getClass())
+                || 
SocketTimeoutException.class.isAssignableFrom(cause.getClass())
+                || 
UnknownHostException.class.isAssignableFrom(cause.getClass())) {
           return true;
         }
       }
diff --git 
a/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryTest.java
 
b/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryTest.java
index 3495b84d6..76843e11f 100644
--- 
a/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryTest.java
+++ 
b/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryTest.java
@@ -62,7 +62,7 @@ import org.easymock.EasyMock;
 import org.junit.Test;
 
 import java.lang.reflect.Type;
-import java.net.ConnectException;
+import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -1352,7 +1352,7 @@ public class ClouderaManagerServiceDiscoveryTest {
     @Override
     public <T> ApiResponse<T> execute(Call call, Type returnType) throws 
ApiException {
       if (executeCount.getAndIncrement() < 
GatewayConfig.DEFAULT_CM_SERVICE_DISCOVERY_MAX_RETRY_ATTEMPTS - 2) {
-        throw new ApiException(new ConnectException("Failed to connect to CM 
HOST"));
+        throw new ApiException(new SocketTimeoutException("Failed to connect 
to CM HOST"));
       }
       return super.execute(call, returnType);
     }

Reply via email to