-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 17, 18, 19, 20
-
b24
-
x86_64
-
windows
-
Verified
ADDITIONAL SYSTEM INFORMATION :
Windows (any version), OpenJDK (any version)
A DESCRIPTION OF THE PROBLEM :
When a Java application spawns a process on Windows that returns an exit code of 259 (0x103), the call to `Process.waitFor()` throws an IllegalThreadStateException.
It does this because the implementation method, `waitFor()` in ProcessImpl.java, calls `exitValue()`. In turn, `exitValue()` checks if the exit value is 259, which on Windows is returned when the process has not yet exited. `exitValue()` then goes ahead and throws an exception.
This can easily be fixed by having `waitFor()` call `getExitCodeProcess()` directly, thus bypassing the check for "not yet exited" since we know it actually has exited. In other words, in https://github.com/openjdk/jdk/blob/master/src/java.base/windows/classes/java/lang/ProcessImpl.java, replace line 575, containing "return exitValue();", with "return getExitCodeProcess(handle);"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Process that exits with an exit value of 259 on Windows. Call process.waitFor().
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should return 259.
ACTUAL -
It throws an exception saying the process has not exited.
CUSTOMER SUBMITTED WORKAROUND :
There is no workaround, but it can be easily fixed in the JDK source.
FREQUENCY : always
Windows (any version), OpenJDK (any version)
A DESCRIPTION OF THE PROBLEM :
When a Java application spawns a process on Windows that returns an exit code of 259 (0x103), the call to `Process.waitFor()` throws an IllegalThreadStateException.
It does this because the implementation method, `waitFor()` in ProcessImpl.java, calls `exitValue()`. In turn, `exitValue()` checks if the exit value is 259, which on Windows is returned when the process has not yet exited. `exitValue()` then goes ahead and throws an exception.
This can easily be fixed by having `waitFor()` call `getExitCodeProcess()` directly, thus bypassing the check for "not yet exited" since we know it actually has exited. In other words, in https://github.com/openjdk/jdk/blob/master/src/java.base/windows/classes/java/lang/ProcessImpl.java, replace line 575, containing "return exitValue();", with "return getExitCodeProcess(handle);"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Process that exits with an exit value of 259 on Windows. Call process.waitFor().
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should return 259.
ACTUAL -
It throws an exception saying the process has not exited.
CUSTOMER SUBMITTED WORKAROUND :
There is no workaround, but it can be easily fixed in the JDK source.
FREQUENCY : always