Polishing

This commit is contained in:
Juergen Hoeller
2016-08-10 14:20:42 +02:00
parent a4b6682c3e
commit 59a24b406a
25 changed files with 154 additions and 152 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -31,14 +31,16 @@ public abstract class AbstractCacheInvoker {
private CacheErrorHandler errorHandler;
protected AbstractCacheInvoker() {
this(new SimpleCacheErrorHandler());
}
protected AbstractCacheInvoker(CacheErrorHandler errorHandler) {
Assert.notNull("ErrorHandler must not be null");
this.errorHandler = errorHandler;
}
protected AbstractCacheInvoker() {
this(new SimpleCacheErrorHandler());
}
/**
* Set the {@link CacheErrorHandler} instance to use to handle errors
@@ -56,6 +58,7 @@ public abstract class AbstractCacheInvoker {
return this.errorHandler;
}
/**
* Execute {@link Cache#get(Object)} on the specified {@link Cache} and
* invoke the error handler if an exception occurs. Return {@code null}
@@ -67,9 +70,9 @@ public abstract class AbstractCacheInvoker {
try {
return cache.get(key);
}
catch (RuntimeException e) {
getErrorHandler().handleCacheGetError(e, cache, key);
return null; // If the exception is handled, return a cache miss
catch (RuntimeException ex) {
getErrorHandler().handleCacheGetError(ex, cache, key);
return null; // If the exception is handled, return a cache miss
}
}
@@ -81,8 +84,8 @@ public abstract class AbstractCacheInvoker {
try {
cache.put(key, result);
}
catch (RuntimeException e) {
getErrorHandler().handleCachePutError(e, cache, key, result);
catch (RuntimeException ex) {
getErrorHandler().handleCachePutError(ex, cache, key, result);
}
}
@@ -94,8 +97,8 @@ public abstract class AbstractCacheInvoker {
try {
cache.evict(key);
}
catch (RuntimeException e) {
getErrorHandler().handleCacheEvictError(e, cache, key);
catch (RuntimeException ex) {
getErrorHandler().handleCacheEvictError(ex, cache, key);
}
}
@@ -107,8 +110,8 @@ public abstract class AbstractCacheInvoker {
try {
cache.clear();
}
catch (RuntimeException e) {
getErrorHandler().handleCacheClearError(e, cache);
catch (RuntimeException ex) {
getErrorHandler().handleCacheClearError(ex, cache);
}
}

View File

@@ -418,7 +418,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
excluded.add(context);
}
}
catch (VariableNotAvailableException e) {
catch (VariableNotAvailableException ex) {
// Ignoring failure due to missing result, consider the cache put has to proceed
}
}