Skip to content

Commit 22bb0e8

Browse files
committed
MET-6544 Add catch statement to stop processing when unrecoverable record exception occurred
1 parent 309221f commit 22bb0e8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

commons/src/main/java/eu/europeana/processing/retryable/RetryableMethodExecutor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static boolean areRetryParamsOverridden() {
4646
return OVERRIDE_ATTEMPT_COUNT != null || OVERRIDE_DELAY_BETWEEN_ATTEMPTS != null;
4747
}
4848

49-
public static <V, E extends Exception> V executeOnRest(String errorMessage, GenericCallable<V, E> callable) throws E {
49+
public static <V, E extends Exception> V executeOnRest(String errorMessage, GenericCallable<V, E> callable) throws E, UnrecoverableRecordException {
5050
return execute(errorMessage, DEFAULT_REST_ATTEMPTS, DELAY_BETWEEN_REST_ATTEMPTS, callable);
5151
}
5252

@@ -55,7 +55,7 @@ public static <V, E extends Exception> V executeOnRest(String errorMessage, Gene
5555
// of type E or RuntimeException, cause of callable type. Both are expected to be thrown by this method.
5656
public static <V, E extends Throwable> V execute(String errorMessage, int maxAttempts,
5757
int sleepTimeBetweenRetriesMs,
58-
GenericCallable<V, E> callable) throws E {
58+
GenericCallable<V, E> callable) throws E, UnrecoverableRecordException {
5959
maxAttempts = Optional.ofNullable(OVERRIDE_ATTEMPT_COUNT).orElse(maxAttempts);
6060
sleepTimeBetweenRetriesMs = Optional.ofNullable(OVERRIDE_DELAY_BETWEEN_ATTEMPTS).orElse(sleepTimeBetweenRetriesMs);
6161
while (true) {
@@ -66,6 +66,8 @@ public static <V, E extends Throwable> V execute(String errorMessage, int maxAtt
6666
throw new RetryInterruptedException(e);
6767
} catch (UnrecoverableJobException e) {
6868
throw new SuppressRestartsException(e);
69+
} catch (UnrecoverableRecordException e) {
70+
throw e;
6971
} catch (Exception e) {
7072
if (--maxAttempts > 0) {
7173
LOGGER.warn("{} - {} Retries Left {} ", errorMessage, e.getMessage(), maxAttempts, e);

0 commit comments

Comments
 (0)