updated to guava 11 cache miss behavior

This commit is contained in:
Adrian Cole 2011-12-22 03:21:45 -08:00
parent 617d267360
commit a80e1b07e6
2 changed files with 4 additions and 2 deletions

View File

@ -58,6 +58,7 @@ import org.jclouds.logging.Logger;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -169,7 +170,7 @@ public class CloudSigmaComputeServiceAdapter implements
public Future<DriveInfo> apply(String input) { public Future<DriveInfo> apply(String input) {
try { try {
return Futures.immediateFuture(cache.getUnchecked(input)); return Futures.immediateFuture(cache.getUnchecked(input));
} catch (NullPointerException e) { } catch (CacheLoader.InvalidCacheLoadException e) {
logger.debug("drive %s not found", input); logger.debug("drive %s not found", input);
} catch (UncheckedExecutionException e) { } catch (UncheckedExecutionException e) {
logger.warn(e, "error finding drive %s: %s", input, e.getMessage()); logger.warn(e, "error finding drive %s: %s", input, e.getMessage());

View File

@ -61,6 +61,7 @@ import org.jclouds.logging.Logger;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -169,7 +170,7 @@ public class ElasticStackComputeServiceAdapter implements
public Future<DriveInfo> apply(String input) { public Future<DriveInfo> apply(String input) {
try { try {
return Futures.immediateFuture(cache.getUnchecked(input)); return Futures.immediateFuture(cache.getUnchecked(input));
} catch (NullPointerException e) { } catch (CacheLoader.InvalidCacheLoadException e) {
logger.debug("drive %s not found", input); logger.debug("drive %s not found", input);
} catch (UncheckedExecutionException e) { } catch (UncheckedExecutionException e) {
logger.warn(e, "error finding drive %s: %s", input, e.getMessage()); logger.warn(e, "error finding drive %s: %s", input, e.getMessage());