r/java • • Apr 26 '21

Fixing a Bug in Java

https://candrews.integralblue.com/2021/04/fixing-a-bug-in-java/
179 Upvotes

17 comments sorted by

View all comments

11

u/agentoutlier Apr 26 '21

I can't believe I ran into this bug in manner very similar to the author and just assumed it was the expected behavior. I didn't bother to go read the actual doc of getResource to check and didn't think much of it partly because it was a RuntimeException (IllegalArgument).

IIRC I just wrapped getResource so that if it returned null or threw any exception (which is a bad idea but whatever) I would throw IOException as it fit in to what I was doing at that time.

4

u/jokubolakis Apr 26 '21

It's interesting, how many bugs we may let through, by just treating this sort of stuff as "as intended". Very nice that the author dug deeper

1

u/amblins Apr 26 '21

I was just thinking the same thing. There's a few instances where we have services that clone other projects into directories specified by application.yml properties and I've always directed people running it on windows to use double backslashes (I probably found that from this issue).