Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8067796

(process) Process.waitFor(timeout, unit) doesn't throw NPE if timeout is less than, or equal to zero when unit == null

XMLWordPrintable

    • b57
    • Verified

        Spec of j.l.Process.waitFor(timeout, unit) says:
        "Throws: NullPointerException - if unit is null".

        However, j.l.Process.waitFor(timeout, unit) doesn't throw NPE if timeout is less than, or equal to zero. Instead of this it returns false.

        Minimized test:
        ---------------------------------------------------------------

        public static void main(String[] args) throws IOException, InterruptedException {
            System.out.println(Runtime.getRuntime().exec("java").waitFor(0, null));
            System.out.println(Runtime.getRuntime().exec("java").waitFor(-50, null));
        }
        ---------------------------------------------------------------

        Output:
        ---------------------------------------------------------------

        false
        false
        ---------------------------------------------------------------

        Tested with JDK9 b23.
        Failed JCK test is under development.

              rriggs Roger Riggs
              evotchen Elena Votchennikova (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: