Thanks for reporting.
Filed: https://bugs.openjdk.java.net/browse/JDK-8274003 -Sundar ________________________________ From: core-libs-dev <[email protected]> on behalf of Andrey Turbanov <[email protected]> Sent: 20 September 2021 20:49 To: core-libs-dev <[email protected]> Subject: Condition is always false in 'ProcessHandleImpl.Info#toString' Hello. I found suspicious code in the method java.lang.ProcessHandleImpl.Info#toString https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/ProcessHandleImpl.java#L645 ``` 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 then the code checks "if (sb.length() != 0)" This condition will always be *false*. Looks like comparison with 1 should be used instead. Andrey Turbanov
