I never thought it would happen to me, but I ran into my first bug in Java:
https://bugs.java.com/bugdatabase/view_bug?bug_id=5003595
I'm pretty much in the same exact situation as described in the bug (NFS on linux), and I'm seeing that File.exists()
is not returning the correct value (at least not right away).
So my question is, is there any alternative to this method of checking if a file exists? I'd prefer to keep it OS agnostic if possible.
EDIT: I have found a workaround. If you make a call to ls $filedir
, the NFS refreshes whatever cache/metadata that is giving Java trouble, and File.exists()
returns the correct value. Granted, this isn't totally ideal, since it hurts portability, but there are ways to deal with that problem.