...
Code Block | ||||
---|---|---|---|---|
| ||||
try (SessionWrapper sessionWrapper = new SessionWrapper(mySessionManager)) { Session session = sessionWrapper.getSession(); // your logic here } catch (IOException e) { // Handle the exception } |
Please note that the getSession() should be called outside of the try-with-resources statement. This is because the SessionWrapper should be in control of closing the session. If you place the sessionWrapper.getSession() within the try-with-resources the session might be auto-closed, leading to errors.