ResourceResolver try-with-resources in AEM 6.2
Based on the versions I've found, it should work but I just wanted to confirm if anyone has used/tested this with any luck, without leaving tons of sessions open all over the place.
According to SLING-4805[1], ResourceResolver should properly extend AutoCloseable[2] as of Sling API 2.11.0. And according to the bundle I'm seeing in my system console of my local AEM 6.2 instance, it's using Sling API 2.11.0. So I should be able to refactor all of our try-catch-finally resource resolver code to try-with-resources[3], yeah?
try (ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(null)) { // do something with the resolver } catch (LoginException e) { // error handle }Probably just being paranoid and second guessing myself, wondering if anyone else has tried this.
[1] https://issues.apache.org/jira/browse/SLING-4805
[2] https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html
[3] https://docs.oracle.com/javase/8/docs/technotes/guides/language/try-with-resources.html