Hi Team,
I have created ResourceResolver from request object of the Servlet. Do we need to close it manually in the Servlet?
1) PageManager pageManager = request.getResourceResolver().adaptTo(PageManager.class);
2) Session session=request.getResourceResolver().adaptTo(Session.class);
String newurl = "/jcr:content/root/responsivegrid/responsivegrid/login";
3) Resource resource = request.getResourceResolver().getResource(newurl);
Solved! Go to Solution.
Views
Replies
Total Likes
I think getResourceResolver() does not create a new ResourceResolver; as a best practice, we recommend using the try-with-resources statement that ensures that each resource is closed at the end of the statement, with the most commonly used way to make a new ResourceResolver i.e ResourceResolverFactory.
More info here- https://cqdump.joerghoh.de/2018/11/14/try-with-resource-or-i-will-never-forget-to-close-a-resource-r...
I think, no need to close it explicitly.
I think getResourceResolver() does not create a new ResourceResolver; as a best practice, we recommend using the try-with-resources statement that ensures that each resource is closed at the end of the statement, with the most commonly used way to make a new ResourceResolver i.e ResourceResolverFactory.
More info here- https://cqdump.joerghoh.de/2018/11/14/try-with-resource-or-i-will-never-forget-to-close-a-resource-r...
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies