Skip to content

Commit 6ae7425

Browse files
no-op onFailure
1 parent 8ad122f commit 6ae7425

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

server/src/main/java/org/elasticsearch/index/engine/ThreadPoolMergeScheduler.java

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,9 @@ public void doRun() throws Exception {
302302
} catch (Throwable t) {
303303
if (t instanceof MergePolicy.MergeAbortedException) {
304304
// OK to ignore. This is what Lucene's ConcurrentMergeScheduler does
305-
} else if (t instanceof Exception == false) {
306-
// onFailure and onAfter should better be called for Errors too
307-
throw new ExceptionWrappingError(t);
308305
} else {
309-
throw t;
306+
abortOnGoingMerge();
307+
handleMergeException(t);
310308
}
311309
}
312310
}
@@ -346,14 +344,7 @@ public void onAfter() {
346344

347345
@Override
348346
public void onFailure(Exception e) {
349-
if (isRunning() == false) {
350-
throw new IllegalStateException("onFailure must only be invoked after doRun");
351-
}
352-
// most commonly the merge should've already be aborted by now,
353-
// plus the engine is probably going to be failed when any merge fails,
354-
// but keep this in case something believes calling `MergeTask#onFailure` is a sane way to abort a merge
355-
abortOnGoingMerge();
356-
handleMergeException(ExceptionWrappingError.maybeUnwrapCause(e));
347+
// no-op, should not be called
357348
}
358349

359350
@Override
@@ -422,17 +413,4 @@ private static String rateToString(double mbPerSec) {
422413
return String.format(Locale.ROOT, "%.1f MB/sec", mbPerSec);
423414
}
424415
}
425-
426-
private static class ExceptionWrappingError extends RuntimeException {
427-
private static Throwable maybeUnwrapCause(Exception e) {
428-
if (e instanceof ExceptionWrappingError exceptionWrappingError) {
429-
return exceptionWrappingError.getCause();
430-
}
431-
return e;
432-
}
433-
434-
private ExceptionWrappingError(Throwable errorCause) {
435-
super(errorCause);
436-
}
437-
}
438416
}

0 commit comments

Comments
 (0)