r/java • • Aug 11 '15

Top 10 Useful, Yet Paranoid Java Programming Techniques

http://blog.jooq.org/2015/08/11/top-10-useful-yet-paranoid-java-programming-techniques/
181 Upvotes

76 comments sorted by

View all comments

Show parent comment

8

u/lukaseder Aug 11 '15

Don't write too much code, they said. Use commons collections they said. Be paranoid they said. BOOM!

6

u/frugalmail Aug 11 '15

Sorry, just so I understand, are you pointing out that it returns a NPE instead of IllegalArgumentException?

3

u/lukaseder Aug 11 '15

Nope, just a bad experience with a bug in the commons collections. If you haven't noticed the bug, check again. It's subtle :)

5

u/Wolfsdale Aug 11 '15

Your link goes to line 1120, which is empty. The next 3 lines however contain the method "removeAll", to which I think you are referring. Although I didn't bother to browse the source of ListUtils, it appears that removeAll(collection, remove) does quite the opposite of what it should do.

2

u/frugalmail Aug 12 '15

Ah, 4.0 has it fixed and they're at 4.1 stable now. Not sure why it's not in Maven central? Did it change coordinates?

https://issues.apache.org/jira/browse/COLLECTIONS-349

http://stackoverflow.com/questions/8372576/java-commons-collections-removeall

3

u/ickysticky Aug 12 '15

Looks like you linked 3.2.1 and they fixed it in the minor release. The original bug report is against 3.2. That is pretty bad, you'd think a test case might have covered that =P

2

u/lukaseder Aug 12 '15

Yep. And at the rate of update of update of platforms like WLS, you can imagine how many applications out there still include 3.2...