To “re-interrupt” as a best practice:
try{
//some code
} catch (InterruptedException ie) {
logger.error("InterruptedException: ", ie);
Thread.currentThread().interrupt();
} catch (ExecutionException ee) {
logger.error("ExecutionException: ",ee);
}
Usually, when a thread is interrupted, whoever is interrupting the thread, wants the thread to exit what it’s currently doing.
However, make sure that you do NOT multi-catch:
catch (InterruptedException | ExecutionException e) {
logger.error("An error has occurred: ", e);
Thread.currentThread().interrupt();
}
We do not want ExecutionException to be “re-interrupted”.
BONUS:
If you are interested, you can play with the examples here
Cheers