Skip to content

Commit fe7ff4d

Browse files
authored
Merge pull request #2015 from janeklb/jlb/fix-retry-check
[client-v2] Fix check for ConnectTimeoutException in shouldRetry
2 parents 14e0b54 + 64747a1 commit fe7ff4d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### New Features
44
- Added basic auth support for proxies. Now you can specify username/password when connecting via a proxy that requires it with HttpURLConnection and Apache HttpClient.
55

6+
### Bug Fixes
7+
- Fix for retrying on `ConnectTimeoutException`
8+
69
## 0.7.1-patch1
710

811
### Bug Fixes

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import java.io.InputStream;
6464
import java.lang.reflect.InvocationTargetException;
6565
import java.lang.reflect.Method;
66+
import java.net.ConnectException;
6667
import java.net.URL;
6768
import java.nio.charset.StandardCharsets;
6869
import java.time.Duration;
@@ -1408,7 +1409,7 @@ public CompletableFuture<InsertResponse> insert(String tableName, List<?> data,
14081409
metrics.operationComplete();
14091410
metrics.setQueryId(queryId);
14101411
return new InsertResponse(metrics);
1411-
} catch ( NoHttpResponseException | ConnectionRequestTimeoutException | ConnectTimeoutException e) {
1412+
} catch (NoHttpResponseException | ConnectionRequestTimeoutException | ConnectTimeoutException | ConnectException e) {
14121413
lastException = httpClientHelper.wrapException("Insert request initiation failed", e);
14131414
if (httpClientHelper.shouldRetry(e, finalSettings.getAllSettings())) {
14141415
LOG.warn("Retrying", e);
@@ -1536,7 +1537,7 @@ public CompletableFuture<InsertResponse> insert(String tableName,
15361537
metrics.operationComplete();
15371538
metrics.setQueryId(queryId);
15381539
return new InsertResponse(metrics);
1539-
} catch ( NoHttpResponseException | ConnectionRequestTimeoutException | ConnectTimeoutException e) {
1540+
} catch (NoHttpResponseException | ConnectionRequestTimeoutException | ConnectTimeoutException | ConnectException e) {
15401541
lastException = httpClientHelper.wrapException("Insert request initiation failed", e);
15411542
if (httpClientHelper.shouldRetry(e, finalSettings.getAllSettings())) {
15421543
LOG.warn("Retrying", e);
@@ -1702,7 +1703,7 @@ public CompletableFuture<QueryResponse> query(String sqlQuery, Map<String, Objec
17021703

17031704
return new QueryResponse(httpResponse, finalSettings.getFormat(), finalSettings, metrics);
17041705

1705-
} catch ( NoHttpResponseException | ConnectionRequestTimeoutException | ConnectTimeoutException e) {
1706+
} catch (NoHttpResponseException | ConnectionRequestTimeoutException | ConnectTimeoutException | ConnectException e) {
17061707
lastException = httpClientHelper.wrapException("Query request initiation failed", e);
17071708
if (httpClientHelper.shouldRetry(e, finalSettings.getAllSettings())) {
17081709
LOG.warn("Retrying.", e);

client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public boolean shouldRetry(Exception ex, Map<String, Object> requestSettings) {
583583
return retryCauses.contains(ClientFaultCause.NoHttpResponse);
584584
}
585585

586-
if (ex instanceof ConnectException) {
586+
if (ex instanceof ConnectException || ex instanceof ConnectTimeoutException) {
587587
return retryCauses.contains(ClientFaultCause.ConnectTimeout);
588588
}
589589

@@ -598,6 +598,7 @@ public boolean shouldRetry(Exception ex, Map<String, Object> requestSettings) {
598598
// ClientException will be also wrapped
599599
public ClientException wrapException(String message, Exception cause) {
600600
if (cause instanceof ConnectionRequestTimeoutException ||
601+
cause instanceof NoHttpResponseException ||
601602
cause instanceof ConnectTimeoutException ||
602603
cause instanceof ConnectException) {
603604
return new ConnectionInitiationException(message, cause);

0 commit comments

Comments
 (0)