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

Fix recursive load guava cache error #525

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 @@ -193,25 +193,25 @@ long size() {
private InternalSession getFromCacheOrFind(final String key, final Callable<InternalSession> sessionFinder)
throws SessionPersistenceException {
try {
return getCache().get(key, new Callable<InternalSession>() {
@Override
public InternalSession call() throws Exception {
InternalSession result = sessionFinder.call();
if (result == null) {
throw NullResultException.INSTANCE;
}
return result;
InternalSession internalSession = getCache().getIfPresent(key);
if(internalSession == null) {
internalSession = sessionFinder.call();
if (internalSession == null) {
throw NullResultException.INSTANCE;
}
});
} catch (ExecutionException e) {
if (e.getCause() instanceof NullResultException) {
}
getCache().put(key, internalSession);
return internalSession;

} catch (Exception e) {
if (e instanceof NullResultException) {
// There was no result - return back into a null here
return null;
}
// Rethrow any Error/RuntimeException/SessionPersistenceException
Throwables.propagateIfPossible(e.getCause(), SessionPersistenceException.class);
Throwables.propagateIfPossible(e, SessionPersistenceException.class);
// Wrap anything else as a new SessionPersistenceException
throw new SessionPersistenceException(e.getMessage(), e.getCause());
throw new SessionPersistenceException(e.getMessage(), e);
}
}

Expand Down