Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Rosenberg2010-09-09 22:38:58 +0000
committerRobin Rosenberg2010-09-28 21:27:04 +0000
commit96f45e35f31aee24ac60625801e1085f15cd79f2 (patch)
tree9431354ead761abc37e4927005c711da6511389c /org.eclipse.jgit.junit/src
parente5c217bcf3edd34c2999fa665632780cce5d6177 (diff)
downloadjgit-96f45e35f31aee24ac60625801e1085f15cd79f2.tar.gz
jgit-96f45e35f31aee24ac60625801e1085f15cd79f2.tar.xz
jgit-96f45e35f31aee24ac60625801e1085f15cd79f2.zip
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>
Diffstat (limited to 'org.eclipse.jgit.junit/src')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java21
1 files changed, 11 insertions, 10 deletions
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 d28c7edb50..568fcdcd0e 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();

Back to the top