[jruby-joni] 204/279: avoid sub-classing ThreadLocal since it will leak in envs such as (warbled) .war apps
Hideki Yamane
henrich at moszumanska.debian.org
Mon Nov 16 11:27:34 UTC 2015
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository jruby-joni.
commit d7d78f8139c39b39950aff703c8f08483a51e966
Author: kares <self at kares.org>
Date: Fri Jun 27 21:11:22 2014 +0200
avoid sub-classing ThreadLocal since it will leak in envs such as (warbled) .war apps
due JRuby classes being loaded from the (WEB-INF/lib) application loader ...
prevents such applications from correctly releasing class memory (e.g. on re-deploys)
---
src/org/joni/StackMachine.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/org/joni/StackMachine.java b/src/org/joni/StackMachine.java
index a5e51a4..7b16780 100644
--- a/src/org/joni/StackMachine.java
+++ b/src/org/joni/StackMachine.java
@@ -66,19 +66,19 @@ abstract class StackMachine extends Matcher implements StackType {
}
static final ThreadLocal<WeakReference<StackEntry[]>> stacks
- = new ThreadLocal<WeakReference<StackEntry[]>>() {
- @Override
- protected WeakReference<StackEntry[]> initialValue() {
- return new WeakReference<StackEntry[]>(allocateStack());
- }
- };
+ = new ThreadLocal<WeakReference<StackEntry[]>>();
private static StackEntry[] fetchStack() {
WeakReference<StackEntry[]> ref = stacks.get();
- StackEntry[] stack = ref.get();
- if (stack == null) {
- ref = new WeakReference<StackEntry[]>(stack = allocateStack());
- stacks.set(ref);
+ StackEntry[] stack;
+ if (ref == null) {
+ stacks.set( new WeakReference<StackEntry[]>(stack = allocateStack()) );
+ }
+ else {
+ stack = ref.get();
+ if (stack == null) {
+ stacks.set( new WeakReference<StackEntry[]>(stack = allocateStack()) );
+ }
}
return stack;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git
More information about the pkg-java-commits
mailing list