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

Method load

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

Source from the content-addressed store, hash-verified

110 // --------------------------------------------------------- Public Methods
111
112 @Override
113 public void load() throws ClassNotFoundException, IOException {
114 if (log.isTraceEnabled()) {
115 log.trace("Start: Loading persisted sessions");
116 }
117
118 // Initialize our internal data structures
119 sessions.clear();
120
121 // Open an input stream to the specified pathname, if any
122 File file = file();
123 if (file == null) {
124 return;
125 }
126 if (log.isTraceEnabled()) {
127 log.trace(sm.getString("standardManager.loading", pathname));
128 }
129 Loader loader;
130 ClassLoader classLoader = null;
131 Log logger;
132 try (FileInputStream fis = new FileInputStream(file.getAbsolutePath());
133 BufferedInputStream bis = new BufferedInputStream(fis)) {
134 Context c = getContext();
135 loader = c.getLoader();
136 logger = c.getLogger();
137 if (loader != null) {
138 classLoader = loader.getClassLoader();
139 }
140 if (classLoader == null) {
141 classLoader = getClass().getClassLoader();
142 }
143
144 // Load the previously unloaded active sessions
145 synchronized (sessions) {
146 try (ObjectInputStream ois = new CustomObjectInputStream(bis, classLoader, logger,
147 getSessionAttributeValueClassNamePattern(), getWarnOnSessionAttributeFilterFailure())) {
148 Integer count = (Integer) ois.readObject();
149 int n = count.intValue();
150 if (log.isTraceEnabled()) {
151 log.trace("Loading " + n + " persisted sessions");
152 }
153 for (int i = 0; i < n; i++) {
154 StandardSession session = getNewSession();
155 session.readObjectData(ois);
156 session.setManager(this);
157 sessions.put(session.getIdInternal(), session);
158 session.activate();
159 if (!session.isValidInternal()) {
160 // If session is already invalid,
161 // expire session to prevent memory leak.
162 session.setValid(true);
163 session.expire();
164 }
165 }
166 } finally {
167 // Delete the persistent storage file in all cases, since retrying after an exception
168 // is not an option
169 if (file.exists()) {

Callers 1

startInternalMethod · 0.95

Calls 15

fileMethod · 0.95
getLoaderMethod · 0.95
getClassLoaderMethod · 0.95
readObjectDataMethod · 0.95
setManagerMethod · 0.95
getIdInternalMethod · 0.95
activateMethod · 0.95
isValidInternalMethod · 0.95
setValidMethod · 0.95
expireMethod · 0.95

Tested by

no test coverage detected