Skip to content

Commit 0735d5f

Browse files
committed
PLUGIN-1928: Update read time out to 5min and add retry for SocketException.
1 parent 11a872f commit 0735d5f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/io/cdap/plugin/servicenow/apiclient/ServiceNowAPIException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.apache.http.conn.ConnectTimeoutException;
88
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
99

10+
import java.net.SocketException;
1011
import java.util.Arrays;
1112
import java.util.HashSet;
1213
import java.util.Set;
@@ -67,6 +68,7 @@ public boolean isErrorRetryable() {
6768
Throwable t = this.getCause();
6869
return t instanceof OAuthSystemException
6970
|| t instanceof ConnectTimeoutException
71+
|| t instanceof SocketException
7072
|| (this.getMessage() != null
7173
&& this.getMessage().contains(ServiceNowConstants.MAXIMUM_EXECUTION_TIME_EXCEEDED))
7274
|| RETRYABLE_CODES.contains(getStatusCode());

src/main/java/io/cdap/plugin/servicenow/restapi/RestAPIClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
import org.slf4j.LoggerFactory;
4444

4545
import java.io.IOException;
46+
import java.net.SocketException;
47+
import java.net.SocketTimeoutException;
4648
import java.util.Collections;
4749
import java.util.concurrent.Callable;
4850
import java.util.concurrent.ExecutionException;
@@ -58,7 +60,7 @@ public abstract class RestAPIClient {
5860
private static final int DEFAULT_CONNECT_TIMEOUT_MS = 12000;
5961

6062
/* Read Timeout in ms for waiting for data after the connection is established */
61-
private static final int DEFAULT_READ_TIMEOUT_MS = 3600;
63+
private static final int DEFAULT_READ_TIMEOUT_MS = 300000;
6264

6365
private static final RequestConfig requestConfig = RequestConfig.custom()
6466
.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MS)
@@ -79,7 +81,7 @@ public RestAPIResponse executeGet(RestAPIRequest request) throws IOException {
7981
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
8082
return RestAPIResponse.parse(httpResponse, request.getResponseHeaders());
8183
}
82-
} catch (ConnectTimeoutException e) {
84+
} catch (ConnectTimeoutException | SocketException e) {
8385
ServiceNowAPIException exception = new ServiceNowAPIException(e, null);
8486
return new RestAPIResponse(Collections.emptyMap(), null, exception);
8587
}

0 commit comments

Comments
 (0)