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

try {
chain.doFilter(req, res);
} finally {
// Complete the context to avoid transactions getting stuck in the connection pool in the
// `idle in transaction` state.
// TODO add the issue url
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);
}
}
}
}

/**
Expand Down
Loading