On 07/11/2025 08:23, [email protected] wrote:
:
and I disagree here :)
Let's take a step back, in Java code
1/ people are writing many catch blocks that they should not and usually the
code in the catch block is not exercised enough so it is a little brittle.
2/ the normal behavior is to either get an InterruptedException or to have the flag
"interrupted" set, but not both.
Could you clarify what you are disagreeing with?
The methods that throw IE clear the interrupted status. If you catch IE
then the interrupted status will be clear. The guidance is to either
(a) rethrow the IE, or (b) restore the interrupted status if you
continue normally or abnormally (abnormally is throwing an exception
that is not an IE). You could get unlucky and be interrupted again while
handling the IE, so if you rethrow the IE then you would be doing so
with the interrupted status set - this would be unusual of course, but
possible.
-Alan