Index: jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java =================================================================== --- jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java (revision 672112) +++ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java (working copy) @@ -56,7 +56,7 @@ /** * The reaper thread responsible for removing files awaiting deletion */ - private final Thread reaper; + private final ReaperThread reaper; /** * Shutdown hook which removes all files awaiting deletion @@ -163,7 +163,9 @@ // jvm shutdown sequence has already begun, // silently ignore... } + shutdownHook = null; } + reaper.stopWorking(); } //--------------------------------------------------------< inner classes > @@ -172,6 +174,8 @@ */ private class ReaperThread extends Thread { + private boolean stopping = false; + ReaperThread(String name) { super(name); } @@ -186,6 +190,10 @@ try { // wait until a MoribundFileReference is ready for deletion fileRef = (MoribundFileReference) phantomRefQueue.remove(); + } catch (InterruptedException e) { + if (stopping) { + break; + } } catch (Exception e) { // silently ignore... continue; @@ -196,6 +204,14 @@ trackedRefs.remove(fileRef); } } + + /** + * Stops the reaper thread. + */ + public void stopWorking() { + stopping = true; + interrupt(); + } } /**