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

Method load

java/org/apache/catalina/session/FileStore.java:196–237  ·  view source on GitHub ↗
(String id)

Source from the content-addressed store, hash-verified

194
195
196 @Override
197 public Session load(String id) throws ClassNotFoundException, IOException {
198 // Open an input stream to the specified pathname, if any
199 File file = file(id);
200 if (file == null) {
201 return null;
202 }
203
204 Context context = getManager().getContext();
205 Log contextLog = context.getLogger();
206
207 if (contextLog.isTraceEnabled()) {
208 contextLog.trace(sm.getString(getStoreName() + ".loading", id, file.getAbsolutePath()));
209 }
210
211 ClassLoader oldThreadContextCL = context.bind(null);
212 try {
213 Lock readLock = sessionLocksById.getLock(id).readLock();
214 readLock.lock();
215 try {
216 if (!file.exists()) {
217 return null;
218 }
219 try (FileInputStream fis = new FileInputStream(file.getAbsolutePath());
220 ObjectInputStream ois = getObjectInputStream(fis)) {
221 StandardSession session = (StandardSession) manager.createEmptySession();
222 session.readObjectData(ois);
223 session.setManager(manager);
224 return session;
225 } catch (FileNotFoundException e) {
226 if (contextLog.isDebugEnabled()) {
227 contextLog.debug(sm.getString("fileStore.noFile", id, file.getAbsolutePath()), e);
228 }
229 return null;
230 }
231 } finally {
232 readLock.unlock();
233 }
234 } finally {
235 context.unbind(oldThreadContextCL);
236 }
237 }
238
239
240 @Override

Callers 1

testFileStoreMethod · 0.95

Calls 15

fileMethod · 0.95
isTraceEnabledMethod · 0.95
traceMethod · 0.95
getStoreNameMethod · 0.95
readObjectDataMethod · 0.95
setManagerMethod · 0.95
isDebugEnabledMethod · 0.95
debugMethod · 0.95
readLockMethod · 0.80
getObjectInputStreamMethod · 0.80
getContextMethod · 0.65
getManagerMethod · 0.65

Tested by 1

testFileStoreMethod · 0.76