Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Commons Lang: Can the "incompatibilities" between 'lang' and 'lang3' cause different runtime results?

My code uses Apache Commons Lang v.2 (commons-lang). If I update my code to use v.3 (commons-lang3) instead, should I worry that my code might start to behave differently (of course except differences due to fixed bugs and to possible new bugs, which would be normal and don't count) ?

In other words, can lang3 have methods that were also in lang (with the exact same signature) but that might return different results in the two versions?

Apache does mention backwards incompatibilities, and very clearly, but I always understood these incompatibilities in the sense that they break compilation, not in the sense that the very same method can return different results.

I'm asking this because it was claimed to me that some of the backwards incompatibilities that prompted Apache to rename the package from lang to lang3 are methods that may return different results. I believe this is a wrong claim and for me it matters because I always happily replace lang with lang3 in all the imports I stumble upon and I only check that it still compiles, and I really think I'm in the right, but now, due to those claims, I have been told to stop, which I think is wrong, but I have no information that I can use to counter those claims and be allowed to continue.

like image 584
SantiBailors Avatar asked Jul 09 '19 13:07

SantiBailors


1 Answers

Did you read their migration guide?

It says that despite the backwards incompatibility tag on v3, most upgrades are as simple as updating imports to use lang3 in place of lang.

There are some classes and methods that were removed, which any IDE and compiler will quickly identify for you.

I think the more dangerous areas are where the behavior and contracts of methods has changed. For example, see this note:

StringUtils.isAlpha, isNumeric and isAlphanumeric now all return false when passed an empty String. Previously they returned true.

If your code is using those methods, you may see different behavior. It's gonna be up to you to see if your code uses them and if so, if you care.

like image 174
Mike Avatar answered Sep 28 '22 00:09

Mike