diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java
index 31bfd2f530c..486634146d0 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ public class EhCacheCache implements Cache {
@Override
public ValueWrapper get(Object key) {
Element element = this.cache.get(key);
- return toWrapper(element);
+ return toValueWrapper(element);
}
@Override
@@ -85,7 +85,7 @@ public class EhCacheCache implements Cache {
@Override
public ValueWrapper putIfAbsent(Object key, Object value) {
Element existingElement = this.cache.putIfAbsent(new Element(key, value));
- return toWrapper(existingElement);
+ return toValueWrapper(existingElement);
}
@Override
@@ -98,7 +98,7 @@ public class EhCacheCache implements Cache {
this.cache.removeAll();
}
- private ValueWrapper toWrapper(Element element) {
+ private ValueWrapper toValueWrapper(Element element) {
return (element != null ? new SimpleValueWrapper(element.getObjectValue()) : null);
}
diff --git a/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCache.java b/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCache.java
index 7e8b71429e8..55e3c9a3875 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCache.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCache.java
@@ -16,20 +16,18 @@
package org.springframework.cache.guava;
-import java.io.Serializable;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.UncheckedExecutionException;
-import org.springframework.cache.Cache;
-import org.springframework.cache.support.SimpleValueWrapper;
+import org.springframework.cache.support.AbstractValueAdaptingCache;
import org.springframework.util.Assert;
/**
- * Spring {@link Cache} adapter implementation on top of a
- * Guava {@link com.google.common.cache.Cache} instance.
+ * Spring {@link org.springframework.cache.Cache} adapter implementation
+ * on top of a Guava {@link com.google.common.cache.Cache} instance.
*
*
Requires Google Guava 12.0 or higher.
*
@@ -37,16 +35,12 @@ import org.springframework.util.Assert;
* @author Stephane Nicoll
* @since 4.0
*/
-public class GuavaCache implements Cache {
-
- private static final Object NULL_HOLDER = new NullHolder();
+public class GuavaCache extends AbstractValueAdaptingCache {
private final String name;
private final com.google.common.cache.Cache