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

Method invoke

java/org/apache/catalina/valves/PersistentValve.java:113–236  ·  view source on GitHub ↗
(Request request, Response response)

Source from the content-addressed store, hash-verified

111
112
113 @Override
114 public void invoke(Request request, Response response) throws IOException, ServletException {
115
116 // request without session
117 if (isRequestWithoutSession(request.getDecodedRequestURI())) {
118 if (containerLog.isTraceEnabled()) {
119 containerLog.trace(sm.getString("persistentValve.requestIgnore", request.getDecodedRequestURI()));
120 }
121 getNext().invoke(request, response);
122 return;
123 } else if (containerLog.isTraceEnabled()) {
124 containerLog.trace(sm.getString("persistentValve.requestProcess", request.getDecodedRequestURI()));
125 }
126
127 // Select the Context to be used for this Request
128 Context context = request.getContext();
129 if (context == null) {
130 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, sm.getString("standardHost.noContext"));
131 return;
132 }
133
134 boolean asyncOnEntry = request.isAsync();
135
136 String sessionId = request.getRequestedSessionId();
137 UsageCountingSemaphore semaphore = null;
138 boolean mustReleaseSemaphore = true;
139
140 try {
141 /*
142 * If the request was in asynchronous mode when it entered the Valve, the semaphore was acquired during the
143 * original request where asynchronous processing started and does not need to be acquired again.
144 */
145 if (!asyncOnEntry) {
146 /*
147 * Acquire the per session semaphore.
148 */
149 if (sessionId != null) {
150 semaphore = sessionToSemaphoreMap.compute(sessionId,
151 (k, v) -> v == null ? new UsageCountingSemaphore(semaphoreFairness) : v.incrementUsageCount());
152 if (semaphoreBlockOnAcquire) {
153 if (semaphoreAcquireUninterruptibly) {
154 semaphore.acquireUninterruptibly();
155 } else {
156 try {
157 semaphore.acquire();
158 } catch (InterruptedException e) {
159 mustReleaseSemaphore = false;
160 onSemaphoreNotAcquired(request, response);
161 if (containerLog.isDebugEnabled()) {
162 containerLog.debug(sm.getString("persistentValve.acquireInterrupted",
163 request.getDecodedRequestURI()));
164 }
165 return;
166 }
167 }
168 } else {
169 if (!semaphore.tryAcquire()) {
170 mustReleaseSemaphore = false;

Callers 3

testSemaphoreMethod · 0.95

Calls 15

acquireMethod · 0.95
tryAcquireMethod · 0.95
getManagerMethod · 0.95
loadMethod · 0.95
isValidMethod · 0.95
isSessionStaleMethod · 0.95
expireMethod · 0.95
removeMethod · 0.95
setManagerMethod · 0.95

Tested by 3

testSemaphoreMethod · 0.76