[NEW BUG]: Avoid allocations in String.replace(CharSequence, CharSequence) in case no replacement happened

Jonathan Bluett-Duncan jbluettduncan at gmail.com
Thu Mar 2 13:56:22 UTC 2017

Hi Vitaly,

> If there's no early bail out, there's an implicit null check when
> replacement.toString() is called...

Oh apologies! I had missed in the code that NPE does get thrown if
`replacement` is null, no matter if the `if (j < 0) { ... }` block is
entered or not, because `replacement.toString()` gets called immediately
after the if block, which of course executes an implicit null-check.

In that case, the patch LGTM. :)

Kind regards,

More information about the core-libs-dev mailing list