Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gissuebot/38bd3a291323da2936a1 to your computer and use it in GitHub Desktop.
Save gissuebot/38bd3a291323da2936a1 to your computer and use it in GitHub Desktop.
Migrated attachment for Guice issue 288, comment 93
diff --git a/core/src/com/google/inject/internal/InjectorImpl.java b/core/src/com/google/inject/internal/InjectorImpl.java
index ee5e2d6..264cbab 100644
--- a/core/src/com/google/inject/internal/InjectorImpl.java
+++ b/core/src/com/google/inject/internal/InjectorImpl.java
@@ -116,6 +116,13 @@ final class InjectorImpl implements Injector, Lookups {
final Set<Key<?>> failedJitBindings = Sets.newHashSet();
Lookups lookups = new DeferredLookups(this);
+
+ private static final class LocalContext extends ThreadLocal<Object[]> {
+ @Override
+ protected Object[] initialValue() {
+ return new Object[1];
+ }
+ }
InjectorImpl(InjectorImpl parent, State state, InjectorOptions injectorOptions) {
this.parent = parent;
@@ -125,12 +132,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 LocalContext();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment