-
Bug
-
Resolution: Fixed
-
P4
-
8, 11
-
b08
-
x86_64
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8236207 | 11.0.7-oracle | Ivan Gerasimov | P4 | Resolved | Fixed | b01 |
JDK-8236027 | 11.0.7 | Roger Riggs | P4 | Resolved | Fixed | b01 |
JDK-8239165 | openjdk8u252 | Andrew Hughes | P4 | Resolved | Fixed | b03 |
JDK-8235890 | openjdk8u242 | Andrew Hughes | P4 | Resolved | Fixed | b05 |
JDK-8236468 | 8u251 | Roger Riggs | P4 | Resolved | Fixed | b01 |
JDK-8239709 | emb-8u251 | Roger Riggs | P4 | Resolved | Fixed | team |
Please consider this code snippet:
```
public class Temp {
public static void main(String[] args) throws IOException, InterruptedException {
java.lang.Process unixProcess = new ProcessBuilder("ls").directory(new File(".")).start();
unixProcess.waitFor(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
}
```
it should work, but it dies with "IllegalArgumentException: timeout value is negative" exception.
Looking at `java.lang.UNIXProcess#waitFor(long timeout, TimeUnit unit)` method:
long remainingNanos = unit.toNanos(timeout); //reporter: this returns Long.MAX_VALUE
long deadline = System.nanoTime() + remainingNanos;
```
...
do {
// Round up to next millisecond
wait(TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L)); //reporter: remainingNanos + 999_999L evaluates to negative value, because remainingNanos == Long.MAX_VALUE
...
```
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public class Temp {
public static void main(String[] args) throws IOException, InterruptedException {
java.lang.Process unixProcess = new ProcessBuilder("ls").directory(new File(".")).start();
unixProcess.waitFor(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful execution
ACTUAL -
Exception in thread "main" java.lang.IllegalArgumentException: timeout value is negative
at java.lang.Object.wait(Native Method)
at java.lang.UNIXProcess.waitFor(UNIXProcess.java:412)
---------- BEGIN SOURCE ----------
public class Temp {
public static void main(String[] args) throws IOException, InterruptedException {
java.lang.Process unixProcess = new ProcessBuilder("ls").directory(new File(".")).start();
unixProcess.waitFor(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Specify smaller timeout
- backported by
-
JDK-8235890 Conversion of milliseconds to nanoseconds in UNIXProcess contains bug.
-
- Resolved
-
-
JDK-8236027 Conversion of milliseconds to nanoseconds in UNIXProcess contains bug.
-
- Resolved
-
-
JDK-8236207 Conversion of milliseconds to nanoseconds in UNIXProcess contains bug.
-
- Resolved
-
-
JDK-8236468 Conversion of milliseconds to nanoseconds in UNIXProcess contains bug.
-
- Resolved
-
-
JDK-8239165 Conversion of milliseconds to nanoseconds in UNIXProcess contains bug.
-
- Resolved
-
-
JDK-8239709 Conversion of milliseconds to nanoseconds in UNIXProcess contains bug.
-
- Resolved
-