Bind caches as eager singletons
All H2 caches must be created before the enclosing LifecycleManager starts, therefore they must be created eagerly. If they are not, it is possible for an assisted factory to attempt to create the cache for the first time only when that factory's create() method is called (as opposed to when the factory is injected). Change-Id: I058d8783161ffc4274dd78337842ce55c53de183
This commit is contained in:
@@ -85,7 +85,7 @@ public abstract class CacheModule extends AbstractModule {
|
||||
|
||||
CacheProvider<K, V> m =
|
||||
new CacheProvider<K, V>(this, name, keyType, valType);
|
||||
bind(key).toProvider(m).in(Scopes.SINGLETON);
|
||||
bind(key).toProvider(m).asEagerSingleton();
|
||||
bind(ANY_CACHE).annotatedWith(Exports.named(name)).to(key);
|
||||
return m.maximumWeight(1024);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user