Skip to content

Commit bb5a058

Browse files
committed
chore: added log messages to the http retries
1 parent 16d7148 commit bb5a058

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/main/java/dev/jbang/jdkdb/util/HttpUtils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
import java.time.Duration;
1414
import java.time.Instant;
1515
import java.time.format.DateTimeFormatter;
16+
import org.slf4j.Logger;
17+
import org.slf4j.LoggerFactory;
1618

1719
/** Utility class for HTTP operations */
1820
public class HttpUtils {
1921

22+
private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
23+
2024
/** Functional interface for operations that can throw IOException and InterruptedException */
2125
@FunctionalInterface
2226
private interface IOSupplier<T> {
@@ -121,6 +125,12 @@ private <T> T retry(IOSupplier<T> operation) throws IOException, InterruptedExce
121125
if (attempt < DEFAULT_MAX_RETRIES - 1) {
122126
// Exponential backoff: 2s, 4s, 8s, ...
123127
long backoffMillis = INITIAL_BACKOFF.toMillis() * (1L << attempt);
128+
logger.warn(
129+
"HTTP operation failed (attempt {}/{}): {} - retrying after {}ms",
130+
attempt + 1,
131+
DEFAULT_MAX_RETRIES,
132+
e.getMessage(),
133+
backoffMillis);
124134
Thread.sleep(backoffMillis);
125135
}
126136
}

0 commit comments

Comments
 (0)