MCPcopy Index your code
hub / github.com/apache/tomcat / unload

Method unload

java/org/apache/catalina/session/StandardManager.java:189–248  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

187
188
189 @Override
190 public void unload() throws IOException {
191 if (log.isTraceEnabled()) {
192 log.trace(sm.getString("standardManager.unloading.debug"));
193 }
194
195 if (sessions.isEmpty()) {
196 log.debug(sm.getString("standardManager.unloading.nosessions"));
197 return; // nothing to do
198 }
199
200 // Open an output stream to the specified pathname, if any
201 File file = file();
202 if (file == null) {
203 return;
204 }
205 if (log.isTraceEnabled()) {
206 log.trace(sm.getString("standardManager.unloading", pathname));
207 }
208
209 // Keep a note of sessions that are expired
210 List<StandardSession> list = new ArrayList<>();
211
212 try (FileOutputStream fos = new FileOutputStream(file.getAbsolutePath());
213 BufferedOutputStream bos = new BufferedOutputStream(fos);
214 ObjectOutputStream oos = new ObjectOutputStream(bos)) {
215
216 synchronized (sessions) {
217 if (log.isTraceEnabled()) {
218 log.trace("Unloading " + sessions.size() + " sessions");
219 }
220 // Write the number of active sessions, followed by the details
221 oos.writeObject(Integer.valueOf(sessions.size()));
222 for (Session s : sessions.values()) {
223 StandardSession session = (StandardSession) s;
224 list.add(session);
225 session.passivate();
226 session.writeObjectData(oos);
227 }
228 }
229 }
230
231 // Expire all the sessions we just wrote
232 if (log.isDebugEnabled()) {
233 log.debug(sm.getString("standardManager.expiringSessions", Integer.toString(list.size())));
234 }
235 for (StandardSession session : list) {
236 try {
237 session.expire(false);
238 } catch (Throwable t) {
239 ExceptionUtils.handleThrowable(t);
240 } finally {
241 session.recycle();
242 }
243 }
244
245 if (log.isTraceEnabled()) {
246 log.trace("Unloading complete");

Callers 1

stopInternalMethod · 0.95

Calls 15

fileMethod · 0.95
passivateMethod · 0.95
writeObjectDataMethod · 0.95
expireMethod · 0.95
handleThrowableMethod · 0.95
recycleMethod · 0.95
isTraceEnabledMethod · 0.65
traceMethod · 0.65
getStringMethod · 0.65
debugMethod · 0.65
addMethod · 0.65
isDebugEnabledMethod · 0.65

Tested by

no test coverage detected