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

Method process

java/org/apache/coyote/http2/StreamProcessor.java:84–166  ·  view source on GitHub ↗
(SocketEvent event)

Source from the content-addressed store, hash-verified

82
83
84 final void process(SocketEvent event) {
85 try {
86 // Note: The regular processor uses the socketWrapper lock, but using that here triggers a deadlock
87 processLock.lock();
88 try {
89 /*
90 * In some scenarios, error handling may trigger multiple ERROR events for the same stream. The first
91 * ERROR event processed will close the stream, replace it and recycle it. Once the stream has been
92 * replaced it should not be used for processing any further events. When it is known that processing is
93 * going to be a NO-OP, exit early.
94 */
95 if (!stream.equals(handler.getStream(stream.getIdAsInt()))) {
96 return;
97 }
98 // HTTP/2 equivalent of AbstractConnectionHandler#process() without the
99 // socket <-> processor mapping
100 SocketState state = SocketState.CLOSED;
101 try {
102 state = process(socketWrapper, event);
103
104 if (state == SocketState.LONG) {
105 handler.getProtocol().getHttp11Protocol().addWaitingProcessor(this);
106 } else if (state == SocketState.CLOSED) {
107 handler.getProtocol().getHttp11Protocol().removeWaitingProcessor(this);
108 if (!stream.isInputFinished() && getErrorState().isIoAllowed()) {
109 // The request has been processed but the request body has not been
110 // fully read. This typically occurs when Tomcat rejects an upload
111 // of some form (e.g. PUT or POST). Need to tell the client not to
112 // send any more data on this stream (reset).
113 StreamException se =
114 new StreamException(sm.getString("streamProcessor.cancel", stream.getConnectionId(),
115 stream.getIdAsString()), Http2Error.NO_ERROR, stream.getIdAsInt());
116 stream.close(se);
117 } else if (!getErrorState().isConnectionIoAllowed()) {
118 ConnectionException ce = new ConnectionException(
119 sm.getString("streamProcessor.error.connection", stream.getConnectionId(),
120 stream.getIdAsString()),
121 Http2Error.INTERNAL_ERROR);
122 stream.close(ce);
123 } else if (!getErrorState().isIoAllowed()) {
124 StreamException se = stream.getResetException();
125 if (se == null) {
126 se = new StreamException(
127 sm.getString("streamProcessor.error.stream", stream.getConnectionId(),
128 stream.getIdAsString()),
129 Http2Error.INTERNAL_ERROR, stream.getIdAsInt());
130 }
131 stream.close(se);
132 } else {
133 if (!stream.isActive()) {
134 // Close calls replace() so need the same call here
135 stream.replace();
136 }
137 }
138 }
139 } catch (Exception e) {
140 String msg = sm.getString("streamProcessor.error.connection", stream.getConnectionId(),
141 stream.getIdAsString());

Callers 1

processSocketEventMethod · 0.95

Calls 15

recycleMethod · 0.95
getIdAsIntMethod · 0.80
addWaitingProcessorMethod · 0.80
getHttp11ProtocolMethod · 0.80
isInputFinishedMethod · 0.80
isIoAllowedMethod · 0.80
getErrorStateMethod · 0.80
getIdAsStringMethod · 0.80
isConnectionIoAllowedMethod · 0.80
getResetExceptionMethod · 0.80
executeQueuedStreamMethod · 0.80

Tested by

no test coverage detected