diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java index d28c7edb5..568fcdcd0 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java @@ -114,17 +114,18 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { protected void setUp() throws Exception { super.setUp(); - if (shutdownHook == null) { - shutdownHook = new Thread() { - @Override - public void run() { - System.gc(); - recursiveDelete("SHUTDOWN", trash, false, false); - } - }; - Runtime.getRuntime().addShutdownHook(shutdownHook); + synchronized(this) { + if (shutdownHook == null) { + shutdownHook = new Thread() { + @Override + public void run() { + System.gc(); + recursiveDelete("SHUTDOWN", trash, false, false); + } + }; + Runtime.getRuntime().addShutdownHook(shutdownHook); + } } - recursiveDelete(testName(), trash, true, false); mockSystemReader = new MockSystemReader();