}
Map<Class<?>, CurrentInstance> oldInstances = CurrentInstance
.getInstances(false);
FutureAccess pendingAccess;
try {
while ((pendingAccess = session.getPendingAccessQueue().poll()) != null) {
if (!pendingAccess.isCancelled()) {
CurrentInstance.clearAll();
CurrentInstance.restoreInstances(pendingAccess
.getCurrentInstances());
CurrentInstance.setCurrent(session);
pendingAccess.run();
try {
pendingAccess.get();
} catch (Exception exception) {
pendingAccess.handleError(exception);
}
}
}
} finally {
CurrentInstance.clearAll();