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

    Details

    • Subcomponent:
    • Resolved In Build:
      b57
    • Verification:
      Verified

      Backports

        Description

        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.

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: