I have a Java application which is writing files to disk. The issue is, Linux does not lock files as Windows does, so someone can delete the file as it is being written to. When this happens, my Java application keeps chugging along like the file still exists...even allows more writes, with no Exceptions.
I added a check for: file.exists(), however this kills my performance by almost 50%. Anyone have any clever ideas as to how i can work around this and keep my performance high?
It's funny to hear of this being considered a "problem" -- those of us who cut their teeth on UNIX think Windows approach to file locking is crude and painful.
If you can't use file permissions to (mostly) prevent this, I think File.exists() is the only solution here, but presumably you could call it less frequently if it's causing a performance problem -- maybe from a "reaper" thread that wakes up occasionally to check for this condition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With