From e5edc592805819598ed96fafb5586c745f99184e Mon Sep 17 00:00:00 2001 From: Ben Evans Date: Wed, 31 Jul 2024 10:02:43 +0200 Subject: [PATCH] Move the BackoffWrapper into api (#249) --- .../redhat/insights/http}/BackoffWrapper.java | 4 ++-- .../insights/http}/BackoffWrapperTest.java | 22 +++++++++---------- .../httpclient/InsightsJdkHttpClient.java | 1 + 3 files changed, 14 insertions(+), 13 deletions(-) rename {runtime/src/main/java/com/redhat/insights/core/httpclient => api/src/main/java/com/redhat/insights/http}/BackoffWrapper.java (96%) rename {runtime/src/test/java/com/redhat/insights/core/httpclient => api/src/test/java/com/redhat/insights/http}/BackoffWrapperTest.java (75%) diff --git a/runtime/src/main/java/com/redhat/insights/core/httpclient/BackoffWrapper.java b/api/src/main/java/com/redhat/insights/http/BackoffWrapper.java similarity index 96% rename from runtime/src/main/java/com/redhat/insights/core/httpclient/BackoffWrapper.java rename to api/src/main/java/com/redhat/insights/http/BackoffWrapper.java index 95a2bc54..7bcc8cbd 100644 --- a/runtime/src/main/java/com/redhat/insights/core/httpclient/BackoffWrapper.java +++ b/api/src/main/java/com/redhat/insights/http/BackoffWrapper.java @@ -1,5 +1,5 @@ -/* Copyright (C) Red Hat 2023 */ -package com.redhat.insights.core.httpclient; +/* Copyright (C) Red Hat 2023-2024 */ +package com.redhat.insights.http; import static com.redhat.insights.InsightsErrorCode.ERROR_CLIENT_BACKOFF_RETRIES_FAILED; import static com.redhat.insights.InsightsErrorCode.ERROR_INTERRUPTED_THREAD; diff --git a/runtime/src/test/java/com/redhat/insights/core/httpclient/BackoffWrapperTest.java b/api/src/test/java/com/redhat/insights/http/BackoffWrapperTest.java similarity index 75% rename from runtime/src/test/java/com/redhat/insights/core/httpclient/BackoffWrapperTest.java rename to api/src/test/java/com/redhat/insights/http/BackoffWrapperTest.java index 4a64d62c..2623b5ba 100644 --- a/runtime/src/test/java/com/redhat/insights/core/httpclient/BackoffWrapperTest.java +++ b/api/src/test/java/com/redhat/insights/http/BackoffWrapperTest.java @@ -1,5 +1,5 @@ -/* Copyright (C) Red Hat 2023 */ -package com.redhat.insights.core.httpclient; +/* Copyright (C) Red Hat 2023-2024 */ +package com.redhat.insights.http; import static org.junit.jupiter.api.Assertions.*; @@ -13,16 +13,16 @@ class BackoffWrapperTest { @Test void notFailingAction() { - var logger = PrintLogger.STDOUT_LOGGER; - var backoff = new BackoffWrapper(logger, 100L, 2L, 3, () -> {}); + PrintLogger logger = PrintLogger.STDOUT_LOGGER; + BackoffWrapper backoff = new BackoffWrapper(logger, 100L, 2L, 3, () -> {}); assertEquals(0, backoff.run()); } @Test void alwaysFailingAction() { - var start = System.currentTimeMillis(); - var logger = PrintLogger.STDOUT_LOGGER; - var backoff = + long start = System.currentTimeMillis(); + PrintLogger logger = PrintLogger.STDOUT_LOGGER; + BackoffWrapper backoff = new BackoffWrapper( logger, 10L, @@ -45,10 +45,10 @@ void alwaysFailingAction() { @Test void eventuallySucceedingAction() { - var start = System.currentTimeMillis(); - var count = new AtomicInteger(0); - var logger = PrintLogger.STDOUT_LOGGER; - var backoff = + long start = System.currentTimeMillis(); + AtomicInteger count = new AtomicInteger(0); + PrintLogger logger = PrintLogger.STDOUT_LOGGER; + BackoffWrapper backoff = new BackoffWrapper( logger, 10L, diff --git a/runtime/src/main/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClient.java b/runtime/src/main/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClient.java index e1ab6519..5e95b006 100644 --- a/runtime/src/main/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClient.java +++ b/runtime/src/main/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClient.java @@ -5,6 +5,7 @@ import com.redhat.insights.InsightsException; import com.redhat.insights.config.InsightsConfiguration; +import com.redhat.insights.http.BackoffWrapper; import com.redhat.insights.http.InsightsHttpClient; import com.redhat.insights.logging.InsightsLogger; import com.redhat.insights.reports.InsightsReport;