Skip to content

Commit

Permalink
WELD-1323 resolved cache in TypeSafeObserverResolver is unbounded
Browse files Browse the repository at this point in the history
  • Loading branch information
jharting committed May 17, 2013
1 parent 9793fd0 commit 23c4dd1
Showing 1 changed file with 11 additions and 1 deletion.
Expand Up @@ -53,6 +53,16 @@ public C load(R from) {

}

/*
* https://issues.jboss.org/browse/WELD-1323
*/
private static final long RESOLVED_CACHE_UPPER_BOUND;
private static final long DEFAULT_RESOLVED_CACHE_UPPER_BOUND = 0x100000L;

static {
RESOLVED_CACHE_UPPER_BOUND = Long.getLong("org.jboss.weld.resolution.cacheSize", DEFAULT_RESOLVED_CACHE_UPPER_BOUND);
}

// The resolved injection points
private final LoadingCache<R, C> resolved;
// The beans to search
Expand All @@ -65,7 +75,7 @@ public C load(R from) {
*/
public TypeSafeResolver(Iterable<? extends T> allBeans) {
this.resolverFunction = new ResolvableToBeanCollection<R, T, C>(this);
this.resolved = CacheBuilder.newBuilder().build(resolverFunction);
this.resolved = CacheBuilder.newBuilder().maximumSize(RESOLVED_CACHE_UPPER_BOUND).build(resolverFunction);
this.allBeans = allBeans;
}

Expand Down

0 comments on commit 23c4dd1

Please sign in to comment.