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

dhavalshah9131 pushed a commit to branch RANGER-5199
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit b6dc209d6e8205287fe30dbd4d749aa7eee0d9e8
Author: Naoki Takezoe <take...@gmail.com>
AuthorDate: Sat Apr 26 08:58:35 2025 +0900

    RANGER-5201: Retry GET request on server error in RangerRESTClient (#565)
---
 .../java/org/apache/ranger/plugin/util/RangerRESTClient.java     | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTClient.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTClient.java
index da308f942..3c833e9cc 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTClient.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTClient.java
@@ -46,6 +46,7 @@
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 import javax.ws.rs.core.Cookie;
+import javax.ws.rs.core.Response;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -342,6 +343,10 @@ public ClientResponse get(String relativeUrl, Map<String, 
String> params) throws
                 finalResponse = 
webResource.accept(RangerRESTUtils.REST_EXPECTED_MIME_TYPE).type(RangerRESTUtils.REST_MIME_TYPE_JSON).get(ClientResponse.class);
 
                 if (finalResponse != null) {
+                    if (finalResponse.getStatusInfo().getFamily() == 
Response.Status.Family.SERVER_ERROR) {
+                        throw new ClientHandlerException("Response status: " + 
finalResponse.getStatus());
+                    }
+
                     setLastKnownActiveUrlIndex(currentIndex);
 
                     break;
@@ -372,6 +377,10 @@ public ClientResponse get(String relativeUrl, Map<String, 
String> params, Cookie
                 finalResponse = 
br.accept(RangerRESTUtils.REST_EXPECTED_MIME_TYPE).type(RangerRESTUtils.REST_MIME_TYPE_JSON).get(ClientResponse.class);
 
                 if (finalResponse != null) {
+                    if (finalResponse.getStatusInfo().getFamily() == 
Response.Status.Family.SERVER_ERROR) {
+                        throw new ClientHandlerException("Response status: " + 
finalResponse.getStatus());
+                    }
+
                     setLastKnownActiveUrlIndex(currentIndex);
 
                     break;

Reply via email to