-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEOT-1368] Deadlock while creating a Coordinate Reference System
git-svn-id: http://svn.osgeo.org/geotools/branches/2.7.x@37023 e5c1c795-43da-0310-a71f-fac65c449510
- Loading branch information
aaime
committed
Apr 27, 2011
1 parent
d858862
commit 7f3636d
Showing
10 changed files
with
254 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
modules/library/metadata/src/main/java/org/geotools/factory/RecursionCheckingHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.geotools.factory; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
class RecursionCheckingHelper { | ||
|
||
private final ThreadLocal<Set> threadLocalSet = new ThreadLocal<Set>(); | ||
|
||
boolean addAndCheck(Object item) { | ||
Set set = threadLocalSet.get(); | ||
if(set == null) { | ||
set = new HashSet<Class<?>>(); | ||
threadLocalSet.set(set); | ||
} | ||
return set.add(item); | ||
} | ||
|
||
boolean contains(Object item) { | ||
Set<Class<?>> set = threadLocalSet.get(); | ||
if(set == null) { | ||
return false; | ||
} | ||
return set.contains(item); | ||
} | ||
|
||
void removeAndCheck(Object item) { | ||
Set<Class<?>> set = threadLocalSet.get(); | ||
if(set == null) { | ||
throw new AssertionError(null); // Should never happen. | ||
} else if(!set.remove(item)) { | ||
throw new AssertionError(item); // Should never happen. | ||
} | ||
if(set.isEmpty()) { | ||
threadLocalSet.remove(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.