From ba3a6a08c6534abe66b00553368c8981b408b32b Mon Sep 17 00:00:00 2001 From: Kateryna Oblakevych Date: Wed, 22 May 2024 13:15:21 +0300 Subject: [PATCH] change retry interval --- .../crowdin/cli/client/CrowdinClientCore.java | 4 ---- .../cli/client/CrowdinProjectClient.java | 20 +++++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/crowdin/cli/client/CrowdinClientCore.java b/src/main/java/com/crowdin/cli/client/CrowdinClientCore.java index cd61f4b7..ee46789c 100644 --- a/src/main/java/com/crowdin/cli/client/CrowdinClientCore.java +++ b/src/main/java/com/crowdin/cli/client/CrowdinClientCore.java @@ -77,10 +77,6 @@ protected static List executeRequestFullList(BiFunction T executeRequestWithPossibleRetry(Map, ResponseException> errorHandlers, Supplier request) throws ResponseException { - return executeRequestWithPossibleRetries(errorHandlers, request, 2, defaultMillisToRetry); - } - protected static T executeRequestWithPossibleRetries(Map, ResponseException> errorHandlers, Supplier request, int maxAttempts, long millisToRetry) throws ResponseException { if (maxAttempts < 1) { throw new MaxNumberOfRetriesException(); diff --git a/src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java b/src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java index c3c0360d..5792553f 100644 --- a/src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java +++ b/src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java @@ -221,7 +221,7 @@ public Long uploadStorage(String fileName, InputStream content) throws Response errorHandlers, () -> this.client.getStorageApi().addStorage(fileName, content).getData(), 3, - 6 * 1000 + 2 * 1000 ); return storage.getId(); } @@ -258,10 +258,12 @@ public void updateSource(Long sourceId, UpdateFileRequest request) throws Respon put((code, message) -> StringUtils.contains(message, "Invalid SRX specified"), new ResponseException("Invalid SRX file specified")); put((code, message) -> code.equals("409"), new FileInUpdateException()); }}; - executeRequestWithPossibleRetry( + executeRequestWithPossibleRetries( errorHandlers, - () -> this.client.getSourceFilesApi() - .updateOrRestoreFile(this.projectId, sourceId, request)); + () -> this.client.getSourceFilesApi().updateOrRestoreFile(this.projectId, sourceId, request), + 3, + 2 * 1000 + ); } @Override @@ -275,10 +277,12 @@ public FileInfo addSource(AddFileRequest request) throws ResponseException { put((code, message) -> StringUtils.contains(message, "Invalid SRX specified"), new ResponseException("Invalid SRX file specified")); put((code, message) -> StringUtils.containsAny(message, "isEmpty", "Value is required and can't be empty"), new EmptyFileException("Value is required and can't be empty")); }}; - return executeRequestWithPossibleRetry( + return executeRequestWithPossibleRetries( errorHandlers, - () -> this.client.getSourceFilesApi() - .addFile(this.projectId, request).getData()); + () -> this.client.getSourceFilesApi().addFile(this.projectId, request).getData(), + 3, + 2 * 1000 + ); } @Override @@ -325,7 +329,7 @@ public void uploadTranslations(String languageId, UploadTranslationsRequest requ errorhandlers, () -> this.client.getTranslationsApi().uploadTranslations(this.projectId, languageId, request), 3, - 6 * 1000 + 2 * 1000 ); }