Shut up findbugs/protect the shutdownHook in LocalDiskRepositoryTestcase

Singleton references should be protected from multiple threads. As far as we
know this cannot happen as JUnit is used today since we currently don't run
tests in parallel, but now this code will not prevent anyone.

Change-Id: I29109344d2e8025fa2a3ccaf7c2c16469544ce05
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
This commit is contained in:
Robin Rosenberg 2010-09-10 00:38:58 +02:00
parent e5c217bcf3
commit 96f45e35f3
1 changed files with 11 additions and 10 deletions

View File

@ -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();