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

Class AsyncContextImpl

java/org/apache/catalina/core/AsyncContextImpl.java:76–716  ·  view source on GitHub ↗

Implementation of AsyncContext that manages the lifecycle of an asynchronous request processing operation. Each instance is associated with a single request object. If an asynchronous request starts multiple cycles of asynchronous processing, the AsyncContextImpl is re-used for all cycles. O

Source from the content-addressed store, hash-verified

74 * </ul>
75 */
76public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
77
78 private static final Log log = LogFactory.getLog(AsyncContextImpl.class);
79
80 /**
81 * String manager for localized log messages.
82 */
83 protected static final StringManager sm = StringManager.getManager(AsyncContextImpl.class);
84
85 /*
86 * When a request uses a sequence of multiple start(); dispatch() with non-container threads it is possible for a
87 * previous dispatch() to interfere with a following start(). This lock prevents that from happening. It is a
88 * dedicated object as user code may lock on the AsyncContext so if container code also locks on that object
89 * deadlocks may occur.
90 */
91 private final Object asyncContextLock = new Object();
92
93 /*
94 * Used to provide a thread-safe way to check the recycled status and, by implication, the validity of any local
95 * copies taken before the check was made.
96 */
97 private final AtomicBoolean hasBeenRecycled = new AtomicBoolean(false);
98
99 /*
100 * The request object with which this instance is associated.
101 */
102 private volatile Request request;
103
104 /*
105 * The asynchronous request information used to start the most recent asynchronous processing.
106 */
107 private volatile Context context = null;
108 private volatile ServletRequest servletRequest = null;
109 private volatile ServletResponse servletResponse = null;
110
111 /*
112 * Per asynchronous cycle fields.
113 */
114 private final List<AsyncListenerWrapper> listeners = new CopyOnWriteArrayList<>();
115 private volatile Runnable dispatch = null;
116 // Default of 30000 (30s) is set by the connector
117 private long timeout = -1;
118
119 /*
120 * Basis for async events that are passed to listeners
121 */
122 private volatile AsyncEvent event = null;
123
124 /*
125 * Internal flags.
126 */
127 private volatile boolean hasOriginalRequestAndResponse = true;
128 private final AtomicBoolean hasErrorProcessingStarted = new AtomicBoolean(false);
129 private final AtomicBoolean hasOnErrorReturned = new AtomicBoolean(false);
130
131
132 /**
133 * Constructs an AsyncContextImpl for the given request.

Callers

nothing calls this directly

Calls 2

getLogMethod · 0.95
getManagerMethod · 0.95

Tested by

no test coverage detected