commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "nir (JIRA)" <>
Subject [jira] Created: (EXEC-46) Process.waitFor should clear interrupt status when throwing InterruptedException
Date Mon, 24 May 2010 15:54:23 GMT
Process.waitFor should clear interrupt status when throwing InterruptedException

                 Key: EXEC-46
             Project: Commons Exec
          Issue Type: Improvement
         Environment: any
            Reporter: nir
            Priority: Minor

Taken from -

By convention, methods that throw InterruptedException reset the thread interrupt flag. 
Unfortunately Process.waitFor didn't get that memo. (See Sun bug 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

So maybe the code in DefaultExecutor.executeInternal() method should change:
int exitValue = Executor.INVALID_EXITVALUE;
try {
  exitValue = process.waitFor();
} catch (InterruptedException e) {

Maybe there is a need to add
to the catch/finally block

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message