Skip to content

Commit 0b81c72

Browse files
committed
change retry interval
1 parent 263ca40 commit 0b81c72

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/main/java/com/crowdin/cli/client/CrowdinClientCore.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ protected static <T> List<T> executeRequestFullList(BiFunction<Integer, Integer,
7777
return directories;
7878
}
7979

80-
protected static <T> T executeRequestWithPossibleRetry(Map<BiPredicate<String, String>, ResponseException> errorHandlers, Supplier<T> request) throws ResponseException {
81-
return executeRequestWithPossibleRetries(errorHandlers, request, 2, defaultMillisToRetry);
82-
}
83-
8480
protected static <T> T executeRequestWithPossibleRetries(Map<BiPredicate<String, String>, ResponseException> errorHandlers, Supplier<T> request, int maxAttempts, long millisToRetry) throws ResponseException {
8581
if (maxAttempts < 1) {
8682
throw new MaxNumberOfRetriesException();

src/main/java/com/crowdin/cli/client/CrowdinProjectClient.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public Long uploadStorage(String fileName, InputStream content) throws Response
221221
errorHandlers,
222222
() -> this.client.getStorageApi().addStorage(fileName, content).getData(),
223223
3,
224-
6 * 1000
224+
2 * 1000
225225
);
226226
return storage.getId();
227227
}
@@ -258,10 +258,13 @@ public void updateSource(Long sourceId, UpdateFileRequest request) throws Respon
258258
put((code, message) -> StringUtils.contains(message, "Invalid SRX specified"), new ResponseException("Invalid SRX file specified"));
259259
put((code, message) -> code.equals("409"), new FileInUpdateException());
260260
}};
261-
executeRequestWithPossibleRetry(
261+
executeRequestWithPossibleRetries(
262262
errorHandlers,
263-
() -> this.client.getSourceFilesApi()
264-
.updateOrRestoreFile(this.projectId, sourceId, request));
263+
() -> this.client.getSourceFilesApi().updateOrRestoreFile(this.projectId, sourceId, request),
264+
3,
265+
2 * 1000
266+
267+
);
265268
}
266269

267270
@Override
@@ -275,10 +278,12 @@ public FileInfo addSource(AddFileRequest request) throws ResponseException {
275278
put((code, message) -> StringUtils.contains(message, "Invalid SRX specified"), new ResponseException("Invalid SRX file specified"));
276279
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"));
277280
}};
278-
return executeRequestWithPossibleRetry(
281+
return executeRequestWithPossibleRetries(
279282
errorHandlers,
280-
() -> this.client.getSourceFilesApi()
281-
.addFile(this.projectId, request).getData());
283+
() -> this.client.getSourceFilesApi().addFile(this.projectId, request).getData(),
284+
3,
285+
2 * 1000
286+
);
282287
}
283288

284289
@Override
@@ -325,7 +330,7 @@ public void uploadTranslations(String languageId, UploadTranslationsRequest requ
325330
errorhandlers,
326331
() -> this.client.getTranslationsApi().uploadTranslations(this.projectId, languageId, request),
327332
3,
328-
6 * 1000
333+
2 * 1000
329334
);
330335
}
331336

0 commit comments

Comments
 (0)