ModeShape/modeshape — pull request #258 by rhauch (2011-12-22 20:21:31+00:00)
Title: MODE-1357 Eliminated NPE and blocking on binary garbage collection

Changed a couple of things. First, modified the JavaDoc on the two BinaryStore methods related to garbage collection to state that the methods may never block. Then, the FileSystemBinaryStore implementation was changed to correct the NPE and to also try to obtain a write lock on the temporary file that is being deleted; if the write lock cannot immediately be obtained, then that file is skipped and will be removed during the next pass (assuming it will be unlocked shortly). Finally, the FileLocks class was modified to add two methods for trying to obtain locks.

Verified that the behavior works (at least on OS X; we'll see about Windows). Note that FileSystemBinaryStore has a new private static variable that defines whether it should use a lock. If needed (and Windows doesn't like deleting a file that is locked), this constant could be set based upon the operating system.

All unit and integration tests pass on the 3.0 codebase with these changes.