I am implementing an interface which throws IOException
. In my implementation, I call another method which can block, and therefore throw InterruptedException
.
Context:
- I want to end the treatment if I am interrupted;
- this is not a thread I created myself.
My current idea is to do as such (skeleton code):
@Override
public void implementedMethod()
throws IOException
{
try {
methodThatBlocks();
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
throw new IOException();
}
}
is that the correct way? Or should I just throw
and not .interrupt()
?