Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
any
Description
Taken from - http://kylecartmell.com/?p=9
By convention, methods that throw InterruptedException reset the thread interrupt flag.
Unfortunately Process.waitFor didn't get that memo. (See Sun bug 6420270 - http://bugs.sun.com/view_bug.do?bug_id=6420270).
This is especially entertaining when a thread invokes multiple processes consecutively and calls waitFor for each of them;
After one call to waitFor is interrupted, future calls to waitFor from the same thread will immediately throw InterruptedException until the interrupt flag is cleared.
Process.waitFor should always be called from a try block whether InterruptedException is caught or not, with a corresponding finally block that calls Thread.interrupted to clear the interrupt flag.
So maybe the code in DefaultExecutor.executeInternal() method should change:
int exitValue = Executor.INVALID_EXITVALUE;
try {
exitValue = process.waitFor();
} catch (InterruptedException e) {
process.destroy();
}
Maybe there is a need to add
Thread.interrupted()
to the catch/finally block