@@ -69,8 +69,8 @@ public CaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Objec
69
69
* given internal {@link com.github.benmanes.caffeine.cache.Cache} to use.
70
70
* @param name the name of the cache
71
71
* @param cache the backing Caffeine Cache instance
72
- * @param allowNullValues whether to accept and convert {@code null}
73
- * values for this cache
72
+ * @param allowNullValues whether to accept and convert {@code null} values
73
+ * for this cache
74
74
*/
75
75
public CaffeineCache (String name , com .github .benmanes .caffeine .cache .Cache <Object , Object > cache ,
76
76
boolean allowNullValues ) {
@@ -86,9 +86,9 @@ public CaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Objec
86
86
* Create a {@link CaffeineCache} instance with the specified name and the
87
87
* given internal {@link AsyncCache} to use.
88
88
* @param name the name of the cache
89
- * @param cache the backing Caffeine Cache instance
90
- * @param allowNullValues whether to accept and convert {@code null}
91
- * values for this cache
89
+ * @param cache the backing Caffeine AsyncCache instance
90
+ * @param allowNullValues whether to accept and convert {@code null} values
91
+ * for this cache
92
92
* @since 6.1
93
93
*/
94
94
public CaffeineCache (String name , AsyncCache <Object , Object > cache , boolean allowNullValues ) {
@@ -118,6 +118,7 @@ public final com.github.benmanes.caffeine.cache.Cache<Object, Object> getNativeC
118
118
/**
119
119
* Return the internal Caffeine AsyncCache.
120
120
* @throws IllegalStateException if no AsyncCache is available
121
+ * @since 6.1
121
122
* @see #CaffeineCache(String, AsyncCache, boolean)
122
123
* @see CaffeineCacheManager#setAsyncCacheMode
123
124
*/
@@ -130,7 +131,7 @@ public final AsyncCache<Object, Object> getAsyncCache() {
130
131
@ SuppressWarnings ("unchecked" )
131
132
@ Override
132
133
@ Nullable
133
- public <T > T get (Object key , final Callable <T > valueLoader ) {
134
+ public <T > T get (Object key , Callable <T > valueLoader ) {
134
135
return (T ) fromStoreValue (this .cache .get (key , new LoadFunction (valueLoader )));
135
136
}
136
137
@@ -166,7 +167,7 @@ public void put(Object key, @Nullable Object value) {
166
167
167
168
@ Override
168
169
@ Nullable
169
- public ValueWrapper putIfAbsent (Object key , @ Nullable final Object value ) {
170
+ public ValueWrapper putIfAbsent (Object key , @ Nullable Object value ) {
170
171
PutIfAbsentFunction callable = new PutIfAbsentFunction (value );
171
172
Object result = this .cache .get (key , callable );
172
173
return (callable .called ? null : toValueWrapper (result ));
@@ -200,7 +201,7 @@ private class PutIfAbsentFunction implements Function<Object, Object> {
200
201
@ Nullable
201
202
private final Object value ;
202
203
203
- private boolean called ;
204
+ boolean called ;
204
205
205
206
public PutIfAbsentFunction (@ Nullable Object value ) {
206
207
this .value = value ;
@@ -219,16 +220,17 @@ private class LoadFunction implements Function<Object, Object> {
219
220
private final Callable <?> valueLoader ;
220
221
221
222
public LoadFunction (Callable <?> valueLoader ) {
223
+ Assert .notNull (valueLoader , "Callable must not be null" );
222
224
this .valueLoader = valueLoader ;
223
225
}
224
226
225
227
@ Override
226
- public Object apply (Object o ) {
228
+ public Object apply (Object key ) {
227
229
try {
228
230
return toStoreValue (this .valueLoader .call ());
229
231
}
230
232
catch (Exception ex ) {
231
- throw new ValueRetrievalException (o , this .valueLoader , ex );
233
+ throw new ValueRetrievalException (key , this .valueLoader , ex );
232
234
}
233
235
}
234
236
}
0 commit comments