/** * Closes the session that was opened by {@link #openSystemSession()} or {@link #openUserSession()}. * * @since 5.8 */ public void closeSession() { if (session != null) { ((CloseableCoreSession) session).close(); session = null; } }
@Override public void close() throws IOException { if (shouldBeClosed) { ((CloseableCoreSession) session).close(); } }
public void destroy() { try { session.close(); } finally { session = null; } } }
@Override public void destroy() { try { session.close(); } finally { session = null; lock = null; } }
public void releaseCoreSession() { ((CloseableCoreSession) session).close(); session = null; }
@Destroy public void destroy() { if (dedicatedSession != null) { dedicatedSession.close(); } }
@Override public void disconnect() { if (reconnectedCoreSession != null) { reconnectedCoreSession.close(); } reconnectedCoreSession = null; reconnectedEvents = null; if (loginCtx != null) { try { loginCtx.logout(); } catch (LoginException e) { log.error("Cannot log out", e); } finally { loginCtx = null; } } }
@Override @WebMethod public void disconnect(@WebParam(name = "sessionId") String sid) { WSRemotingSession rs = initSession(sid); ((CloseableCoreSession) rs.getDocumentManager()).close(); }
public final void dispose() { try { if (session != null) { try { session.save(); } finally { session.close(); } } } finally { try { session = null; lc.logout(); lc = null; } catch (LoginException e) { log.error(e); // don't rethrow inside finally } } } }
String serverName = entry.getKey().getName(); CloseableCoreSession session = entry.getValue(); session.close(); log.debug("Closed session for repository " + serverName);
@Override public void afterRun(FeaturesRunner runner) { waitForAsyncCompletion(); // fulltext and various workers if (granularity != Granularity.METHOD) { cleanupSession(runner); } if (session != null) { releaseCoreSession(); } List<CoreSessionRegistrationInfo> leakedInfos = Framework.getService(CoreSessionService.class) .getCoreSessionRegistrationInfos(); if (leakedInfos.size() == 0) { return; } AssertionError leakedErrors = new AssertionError(String.format("leaked %d sessions", leakedInfos.size())); for (CoreSessionRegistrationInfo info : leakedInfos) { try { ((CloseableCoreSession) info.getCoreSession()).close(); leakedErrors.addSuppressed(info); } catch (RuntimeException cause) { leakedErrors.addSuppressed(cause); } } throw leakedErrors; }
} finally { if (closeSession) { ((CloseableCoreSession) session).close();
public void run(final List<EventListenerDescriptor> listeners, EventBundle bundle) { // EventBundle that have gone through bus have been serialized // we need to reconnect them before filtering // this means we need a valid transaction ! if (!(bundle instanceof ReconnectedEventBundleImpl)) { scheduleListeners(listeners, bundle); } else { final EventBundle tmpBundle = bundle; TransactionHelper.runInTransaction(() -> { EventBundle connectedBundle = new EventBundleImpl(); Map<String, CoreSession> sessions = new HashMap<>(); List<Event> events = ((ReconnectedEventBundleImpl)tmpBundle).getReconnectedEvents(); for (Event event : events) { connectedBundle.push(event); CoreSession session = event.getContext().getCoreSession(); if (!(sessions.keySet().contains(session.getRepositoryName()))) { sessions.put(session.getRepositoryName(), session); } } for (CoreSession session : sessions.values()) { ((CloseableCoreSession) session).close(); } scheduleListeners(listeners, connectedBundle); }); } }
} finally { if (sessionOpened) { ((CloseableCoreSession) session).close();
public List<Blob> getBlobs(String title) { CoreSession session = getSession(); boolean sessionOpened = false; if (session == null) { sessionOpened = true; session = CoreInstance.openCoreSession(doc.getRepositoryName()); } try { DocumentModelList docList = session.getChildren(doc.getRef(), "Picture"); List<Blob> blobList = new ArrayList<Blob>(docList.size()); for (DocumentModel documentModel : docList) { if ("Original".equals(title)) { BlobHolder bh = documentModel.getAdapter(BlobHolder.class); blobList.add(bh.getBlob()); } else { PictureResourceAdapter picture = documentModel.getAdapter(PictureResourceAdapter.class); blobList.add(picture.getPictureFromTitle(title)); } } return blobList; } finally { if (sessionOpened) { ((CloseableCoreSession) session).close(); } } }
} finally { if (closeableCoreSession != null) { closeableCoreSession.close();
@Override public Blob getBlob() { CoreSession session = getSession(); boolean sessionOpened = false; if (session == null) { sessionOpened = true; session = CoreInstance.openCoreSession(doc.getRepositoryName()); } try { DocumentModelList docs = session.getChildren(doc.getRef(), "Picture"); if (docs.isEmpty()) { return null; } DocumentModel documentModel = docs.get(0); if (documentModel == null) { return null; } BlobHolder bh = documentModel.getAdapter(BlobHolder.class); return bh.getBlob(); } finally { if (sessionOpened) { ((CloseableCoreSession) session).close(); } } }