return;
}
- final Repository db;
- try {
- db = resolver.open(req, name);
+ try (Repository db = resolver.open(req, name)) {
+ request.setAttribute(ATTRIBUTE_REPOSITORY, db);
+ chain.doFilter(request, response);
} catch (RepositoryNotFoundException e) {
sendError(req, res, SC_NOT_FOUND);
return;
} catch (ServiceMayNotContinueException e) {
sendError(req, res, e.getStatusCode(), e.getMessage());
return;
- }
- try {
- request.setAttribute(ATTRIBUTE_REPOSITORY, db);
- chain.doFilter(request, response);
} finally {
request.removeAttribute(ATTRIBUTE_REPOSITORY);
- db.close();
}
}
}