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

ProcessHandleImpl.Info toString has an if check which is always true

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 18
    • 18
    • core-libs
    • None
    • b16

      I report this bug because of corelibs-dev email from "Andrey Turbanov"

      ProcessHandleImpl.Info.toString code:

      StringBuilder sb = new StringBuilder(60);
      sb.append('[');
      if (user != null) {
          sb.append("user: ");
          sb.append(user());
      }
      if (command != null) {
          if (sb.length() != 0) sb.append(", ");
          sb.append("cmd: ");
          sb.append(command);
      }

      Opening bracket '[' is added unconditionally to the StringBuilder. But later the code checks "if (sb.length() != 0)". This condition will always be true.

      See also:

      https://mail.openjdk.java.net/pipermail/core-libs-dev/2021-September/081774.html

            rriggs Roger Riggs
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: