From dbe9a8e0a51bc5e76a6e7f2d592e87b4b4511525 Mon Sep 17 00:00:00 2001 From: jack-berg <34418638+jack-berg@users.noreply.github.com> Date: Wed, 18 May 2022 08:11:28 -0500 Subject: [PATCH] RetryInterceptor retries on SocketTimeoutException with no message (#4475) --- .../exporter/internal/retry/RetryInterceptor.java | 4 +++- .../exporter/internal/retry/RetryInterceptorTest.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/retry/RetryInterceptor.java b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/retry/RetryInterceptor.java index 990b584da4..a433b2f533 100644 --- a/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/retry/RetryInterceptor.java +++ b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/retry/RetryInterceptor.java @@ -102,7 +102,9 @@ public final class RetryInterceptor implements Interceptor { return false; } String message = e.getMessage(); - return message != null && message.toLowerCase().contains("connect timed out"); + // Connect timeouts can produce SocketTimeoutExceptions with no message, or with "connect timed + // out" + return message == null || message.toLowerCase().contains("connect timed out"); } // Visible for testing diff --git a/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/retry/RetryInterceptorTest.java b/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/retry/RetryInterceptorTest.java index 05c776b4eb..ac9a369f10 100644 --- a/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/retry/RetryInterceptorTest.java +++ b/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/retry/RetryInterceptorTest.java @@ -195,7 +195,7 @@ class RetryInterceptorTest { // Shouldn't retry on write timeouts, where error message is "timeout", or other IOException assertThat(RetryInterceptor.isRetryableException(new SocketTimeoutException("timeout"))) .isFalse(); - assertThat(RetryInterceptor.isRetryableException(new SocketTimeoutException())).isFalse(); + assertThat(RetryInterceptor.isRetryableException(new SocketTimeoutException())).isTrue(); assertThat(RetryInterceptor.isRetryableException(new IOException("error"))).isFalse(); }