Skip to content
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 @@ -102,7 +102,23 @@ protected void doFilterInternal(HttpServletRequest req,
if (authentication != null) {
SecurityContextHolder.getContext().setAuthentication(authentication);
}
chain.doFilter(req, res);

try {
chain.doFilter(req, res);
} finally {
// Abort the request-scoped DSpace Context if it is still open, so a leaked, dirty
// Hibernate session is not left bound to the worker thread (prevents orphaned items).
Comment thread
jr-rk marked this conversation as resolved.
// See https://github.com/dataquest-dev/DSpace/issues/1353
Context context = (Context) req.getAttribute(ContextUtil.DSPACE_CONTEXT);
// Ensure the context is cleared after the request is done
if (context != null && context.isValid()) {
try {
context.abort();
} catch (Exception e) {
log.error("{} occurred while trying to close", e.getMessage(), e);
}
Comment thread
jr-rk marked this conversation as resolved.
}
}
}

/**
Expand Down
Loading