commons-lang
commons-lang copied to clipboard
Let mid(null), left(null) and right(null) return empty
I'm not sure if there is reasoning behind left(null, n)
returning null
, but other StringUtils
functions tends to return empty strings if their inputs are null. Likewise, I think it makes sense that mid(null, n)
, left(null, n)
or right(null, n)
returns an empty string instead of returning null. My use case is lambda logging. I have code like this:
log.debug("My output (first 256 chars): {}", StringUtils.left(output, 256)::toString);
I get an NullPointerExceptions when I do and not properly wrap the call, etc. So I can't take advantage of both the left
function as well as lambda based logging.
Coverage decreased (-0.002%) to 94.955% when pulling 821a4a5b04f6fb4bbdcec014be48bf42df5f48ca on esend7881:patch-1 into 5689c91cf2a3a27f0a3a8a362857f2cf0919d4f6 on apache:master.
Coverage decreased (-0.002%) to 94.955% when pulling 821a4a5b04f6fb4bbdcec014be48bf42df5f48ca on esend7881:patch-1 into 5689c91cf2a3a27f0a3a8a362857f2cf0919d4f6 on apache:master.
I think that is because the total number of lines have been reduced (smaller denominator) which makes it seem like there is less coverage.
Not sure about the impact here of changing the behavior... needs a bit more study...