diff --git a/src/main/java/com/ciaranwood/tapestry/cache/services/advice/CacheMethodAdvice.java b/src/main/java/com/ciaranwood/tapestry/cache/services/advice/CacheMethodAdvice.java index 76a16bc..8181117 100644 --- a/src/main/java/com/ciaranwood/tapestry/cache/services/advice/CacheMethodAdvice.java +++ b/src/main/java/com/ciaranwood/tapestry/cache/services/advice/CacheMethodAdvice.java @@ -26,9 +26,17 @@ public void advise(MethodInvocation invocation) { Element cached = cache.get(key); if(cached == null) { log.debug("cache miss for {} using cache {}", key, cache.getName()); - invocation.proceed(); - Object result = invocation.getReturnValue(); - cache.put(new Element(key, result)); + try + { + invocation.proceed(); + Object result = invocation.getReturnValue(); + cache.put(new Element(key, result)); + } + catch (Throwable throwable) + { + cache.put(new Element(key, null)); + throw throwable; + } log.debug("cached result of {} using cache {}", key, cache.getName()); } else { invocation.setReturnValue(cached.getValue());