I never thought it would happen to me, but I ran into my first bug in Java:
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.
Thanks,
-Ben
解决方案
The basic problem you have with NFS is that it caches attributes, files and directories information. This means the information can be out of date. You might be able to turn off caching, you will see a significant reduction in performance.
The important thing to remember is that NFS is not a messaging service and is not designed for timely delivery of data.