• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • ehcache-core
  • lorban
  • Reporter: cpruett
  • November 18, 2010
  • 0
  • Watchers: 0
  • March 05, 2013
  • January 26, 2011

Description

When getAllWithLoader() encounters expired elements, it populates the return map with null values instead of delegating to the cache loader to reload the value. This behavior is asymmetric with getWithLoader(), which correctly calls the loader when expired elements are found.

I believe that the following code is the culprit:

public Map getAllWithLoader(Collection keys, Object loaderArgument) throws CacheException {
	// ... snipped ...
	if (isKeyInCache(key)) {
	    Element element = get(key);
	    if (element != null) {
	        map.put(key, element.getObjectValue());
	    } else {
	        map.put(key, null);
	    }
	} else {
	    missingKeys.add(key);
	}
	// ... snipped ...

}

isKeyInCache() returns true, regardless of whether the key is expired.

Comments

Ludovic Orban 2011-01-26

Fixed.