<commit_before>Description: Decouple the context ThreadLocal from the containing Injector/ClassLoader
Author: <NAME> <<EMAIL>>
Bug-Google: http://code.google.com/p/google-guice/issues/detail?id=288
Last-Update: 2012-08-07

diff --git a/core/src/com/google/inject/internal/InjectorImpl.java b/core/src/com/google/inject/internal/InjectorImpl.java
index 03f1d06..a2c746e 100644
--- a/core/src/com/google/inject/internal/InjectorImpl.java
+++ b/core/src/com/google/inject/internal/InjectorImpl.java
@@ -128,12 +128,7 @@ final class InjectorImpl implements Injector, Lookups {
     if (parent != null) {
       localContext = parent.localContext;
     } else {
-      localContext = new ThreadLocal<Object[]>() {
-        @Override
-        protected Object[] initialValue() {
-          return new Object[1];
-        }
-      };
+      localContext = new ThreadLocal<Object[]>();
     }
   }
 
@@ -1040,11 +1035,15 @@ final class InjectorImpl implements Injector, Lookups {
     return getProvider(type).get();
   }
 
-  final ThreadLocal<Object[]> localContext;
+  private final ThreadLocal<Object[]> localContext;
 
   /** Looks up thread local context. Creates (and removes) a new context if necessary. */
   <T> T callInContext(ContextualCallable<T> callable) throws ErrorsException {
     Object[] reference = localContext.get();
+    if (reference == null) {
+      reference = new Object[1];
+      localContext.set(reference);
+    }
     if (reference[0] == null) {
       reference[0] = new InternalContext();
       try {<commit_msg>Update patch for issue 288<commit_after>Description: Decouple the context ThreadLocal from the containing Injector/ClassLoader
Author: <NAME> <<EMAIL>>
Bug-Google: http://code.google.com/p/google-guice/issues/detail?id=288
Last-Update: 2013-09-19

diff --git a/core/src/com/google/inject/internal/InjectorImpl.java b/core/src/com/google/inject/internal/InjectorImpl.java
index 6faab97..3c25b40 100644
--- a/core/src/com/google/inject/internal/InjectorImpl.java
+++ b/core/src/com/google/inject/internal/InjectorImpl.java
@@ -128,7 +128,7 @@ final class InjectorImpl implements Injector, Lookups {
     if (parent != null) {
       localContext = parent.localContext;
     } else {
-      localContext = new LocalContextThreadLocal();
+      localContext = new ThreadLocal<Object[]>();
     }
   }
 
@@ -1035,11 +1035,15 @@ final class InjectorImpl implements Injector, Lookups {
     return getProvider(type).get();
   }
 
-  final ThreadLocal<Object[]> localContext;
+  private final ThreadLocal<Object[]> localContext;
 
   /** Looks up thread local context. Creates (and removes) a new context if necessary. */
   <T> T callInContext(ContextualCallable<T> callable) throws ErrorsException {
     Object[] reference = localContext.get();
+    if (reference == null) {
+      reference = new Object[1];
+      localContext.set(reference);
+    }
     if (reference[0] == null) {
       reference[0] = new InternalContext();
       try {
@@ -1061,10 +1065,4 @@ final class InjectorImpl implements Injector, Lookups {
         .toString();
   }
 
-  private static final class LocalContextThreadLocal extends ThreadLocal<Object[]> {
-    @Override
-    protected Object[] initialValue() {
-      return new Object[1];
-    }
-  }
 }
{'fraction_non_alphanumeric': 0.1353498319584479, 'fraction_numerical': 0.034830430797433545, 'mean_word_length': 3.4604904632152587, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5991554', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1017, 'n_words': 230}