RFR 9: 8064932: test java/lang/ProcessBuilder/Basic.java: waitFor didn't take long enough

roger riggs roger.riggs at oracle.com
Fri Nov 14 22:15:08 UTC 2014


Hi Martin,

The artifact is by-product of using System.nanoTime to measure the duration
in UNIXProcess and the conversion to milliseconds to call Object.wait():

The low order bits of nanoseconds are truncated in the conversion.

         long timeoutAsNanos = unit.toNanos(timeout);
         long startTime = System.nanoTime();
         long rem = timeoutAsNanos;

         while (!hasExited && (rem > 0)) {
             wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
             rem = timeoutAsNanos - (System.nanoTime() - startTime);
         }

The issue may be further complicated by the test logic also doing the
timing in nanoSeconds when the best Object.wait can do is milliseconds.

If System.nanoTime is to be used, perhaps it should be modulo milliseconds.

Roger


On 11/14/2014 2:57 PM, Martin Buchholz wrote:
> This sort of change may be a necessary concession to reality, but
> before we go there ... as I said in a previous review, this test may
> demonstrate a real bug in the jdk implementation.  Is this
> system-dependent?  Is it easy to reproduce?  Can we fix the JDK?
>
> On Fri, Nov 14, 2014 at 11:48 AM, roger riggs <roger.riggs at oracle.com> wrote:
>> Please review this test change to make the wait time in ProcessBuilder/Basic
>> a bit more lenient.
>>
>> Webrev:
>> http://cr.openjdk.java.net/~rriggs/webrev-basic-notenough-8064932/
>>
>> Issue:
>>     8064932: java/lang/ProcessBuilder/Basic.java: waitFor didn't take long
>> enough
>>
>> Thanks, Roger
>>




More information about the core-libs-dev mailing list