Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cache implementations to wrap the EntryProcessorException #131

Merged
merged 1 commit into from
Oct 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ public void noValueException() {
cache.invoke(key, new CombineEntryProcessor(processors));
fail();
} catch (CacheException e) {
assertTrue("expected IllegalAccessError; observed " + e.getCause(),
e.getCause() instanceof IllegalAccessError);
Throwable rootCause = getRootCause(e);
assertTrue("expected IllegalAccessError; observed " + rootCause,
rootCause instanceof IllegalAccessError);
}
assertFalse(cache.containsKey(key));
}
Expand All @@ -230,6 +231,13 @@ public void existingReplace() {
assertEquals(newValue, cache.get(key));
}

private static Throwable getRootCause(Throwable t) {
if (t.getCause() == null) {
return t;
}
return getRootCause(t.getCause());
}

@Test
public void existingException() {
final Integer key = 123;
Expand All @@ -246,8 +254,9 @@ public void existingException() {
cache.invoke(key, new CombineEntryProcessor<Integer, String>(processors));
fail();
} catch (CacheException e) {
assertTrue("expected IllegalAccessError; observed " + e.getCause(),
e.getCause() instanceof IllegalAccessError);
Throwable rootCause = getRootCause(e);
assertTrue("expected IllegalAccessError; observed " + rootCause,
rootCause instanceof IllegalAccessError);
}
assertEquals(oldValue, cache.get(key));
}
Expand Down Expand Up @@ -287,8 +296,9 @@ public void removeException() {
cache.invoke(key, new ThrowExceptionEntryProcessor<Integer, String, Void>(IllegalAccessError.class));
fail();
} catch (CacheException e) {
assertTrue("expected IllegalAccessError; observed " + e.getCause(),
e.getCause() instanceof IllegalAccessError);
Throwable t = getRootCause(e);
assertTrue("expected IllegalAccessError; observed " + t,
t instanceof IllegalAccessError);
}
assertEquals(oldValue, cache.get(key));
}
Expand Down