RFR 8214971 : Replace use of string.equals("") with isEmpty()

Daniel Fuchs daniel.fuchs at oracle.com
Fri Dec 7 11:54:41 UTC 2018


Hi Hannes,

On 07/12/2018 09:24, Hannes Wallnöfer wrote:
> Hi Roger,
> 
> There are quite a few occurrences of the reverse calling pattern "".equals(str) in core libs.
> 
> This is a bit more tricky because it allows str to be null, but when used following a null/not-null check it could be replaced with isEmpty() as well.
> 
> I wonder if these should be included in the patch?

I would advocate either not doing it - or doing it in another
patch - as I believe such a change would require a more careful
review - especially as to whether 'str' can be null at the
call site. Though checking for null for something that's guaranteed
not to be null is harmless, it can confuse the reader (I know it
usually confuses me as it makes me wonder what the programmer's intent
really was and whether there's a bug lurking somewhere) - so
I'd rather avoid a global mechanical change for those cases.

best regards,

-- daniel

> 
> Hannes
> 



More information about the core-libs-dev mailing list