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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b16

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: