aboutsummaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authoraclement <aclement>2008-05-27 18:46:58 +0000
committeraclement <aclement>2008-05-27 18:46:58 +0000
commitd78772db596a4169095d26ab6e13cf92fda0dde0 (patch)
tree52cd6c1bcb44db76c8570fc161e3bf46b6a103e1 /bridge
parentd8c8d2bb1b8ddbeb0d11fae9ebbea95d73fa2b27 (diff)
downloadaspectj-d78772db596a4169095d26ab6e13cf92fda0dde0.tar.gz
aspectj-d78772db596a4169095d26ab6e13cf92fda0dde0.zip
210470: preventing weaver leaks: do not mess up the context stack in a multi-threaded environment
Diffstat (limited to 'bridge')
-rw-r--r--bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java
index 9f546b131..c9acc4967 100644
--- a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java
+++ b/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java
@@ -136,12 +136,17 @@ public class CompilationAndWeavingContext {
private CompilationAndWeavingContext() {
}
- // for testing...
public static void reset() {
- contextMap = new HashMap();
- contextStack = new Stack();
- formatterMap = new HashMap();
- nextTokenId = 1;
+ if (!multiThreaded) {
+ contextMap = new HashMap();
+ contextStack = new Stack();
+ formatterMap = new HashMap();
+ nextTokenId = 1;
+ } else {
+ contextMap.remove(Thread.currentThread());
+ // TODO what about formatterMap?
+ // TODO what about nextTokenId?
+ }
}
public static void setMultiThreaded(boolean mt) { multiThreaded = mt; }
@@ -204,13 +209,12 @@ public class CompilationAndWeavingContext {
return contextStack;
}
else {
- if (contextMap.containsKey(Thread.currentThread())) {
- return (Stack) contextMap.get(Thread.currentThread());
- } else {
- Stack contextStack = new Stack();
+ Stack contextStack = (Stack) contextMap.get(Thread.currentThread());
+ if (contextStack == null) {
+ contextStack = new Stack();
contextMap.put(Thread.currentThread(),contextStack);
- return contextStack;
}
+ return contextStack;
}
}