RFR: JDK-8280004: DCmdArgument<jlong>::parse_value() should handle NULL input
David Holmes
dholmes at openjdk.java.net
Tue Jan 18 07:07:25 UTC 2022
On Fri, 14 Jan 2022 10:40:58 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> Hi,
>
> may I have eyes please on this simple fix (Sonarcloud-inspired) which sanitizes the error output of DCmdArgument<jlong>::parse_value():
> - since the input can be NULL, we should handle NULL
> - we also limit parroting of invalid input to 64 chars max
> - we also do not need a temporary RA buffer to assemble the output
>
> Example output with patch, first a short, then a long invalid numeric parameter:
>
>
> thomas at starfish:~$ jcmd Simple GC.class_histogram -parallel=hallo
> 399746:
> java.lang.IllegalArgumentException: Integer parsing error in command argument '-parallel'. Could not parse: "hallo".
> thomas at starfish:~$ jcmd Simple GC.class_histogram -parallel=hallo012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
> 399746:
> java.lang.IllegalArgumentException: Integer parsing error in command argument '-parallel'. Could not parse: "hallo01234567890123456789012345678901234567890123456789012345678...".
>
>
> Thanks, Thomas
Seems fine.
Thanks,
David
Thanks Thomas! I was too focused on the original string and didn't check that the exception code was going to make a copy anyway. There's likely multiple copies made on the way to the final String object.
-------------
Marked as reviewed by dholmes (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/7079
More information about the hotspot-runtime-dev
mailing list