View | Details | Raw Unified | Return to bug 65757
Collapse All | Expand All

(-)a/java/org/apache/catalina/connector/CoyoteAdapter.java (+2 lines)
Lines 130-135 Link Here
130
        AsyncContextImpl asyncConImpl = request.getAsyncContextInternal();
130
        AsyncContextImpl asyncConImpl = request.getAsyncContextInternal();
131
131
132
        req.getRequestProcessor().setWorkerThreadName(THREAD_NAME.get());
132
        req.getRequestProcessor().setWorkerThreadName(THREAD_NAME.get());
133
        req.setRequestThread();
133
134
134
        try {
135
        try {
135
            if (!request.isAsync()) {
136
            if (!request.isAsync()) {
Lines 341-346 Link Here
341
        boolean postParseSuccess = false;
342
        boolean postParseSuccess = false;
342
343
343
        req.getRequestProcessor().setWorkerThreadName(THREAD_NAME.get());
344
        req.getRequestProcessor().setWorkerThreadName(THREAD_NAME.get());
345
        req.setRequestThread();
344
346
345
        try {
347
        try {
346
            // Parse and set Catalina and configuration specific
348
            // Parse and set Catalina and configuration specific
(-)a/java/org/apache/catalina/connector/InputBuffer.java (-2 / +1 lines)
Lines 32-38 Link Here
32
32
33
import org.apache.catalina.security.SecurityUtil;
33
import org.apache.catalina.security.SecurityUtil;
34
import org.apache.coyote.ActionCode;
34
import org.apache.coyote.ActionCode;
35
import org.apache.coyote.ContainerThreadMarker;
36
import org.apache.coyote.Request;
35
import org.apache.coyote.Request;
37
import org.apache.juli.logging.Log;
36
import org.apache.juli.logging.Log;
38
import org.apache.juli.logging.LogFactory;
37
import org.apache.juli.logging.LogFactory;
Lines 266-272 Link Here
266
            // If this is a non-container thread, need to trigger a read
265
            // If this is a non-container thread, need to trigger a read
267
            // which will eventually lead to a call to onAllDataRead() via a
266
            // which will eventually lead to a call to onAllDataRead() via a
268
            // container thread.
267
            // container thread.
269
            if (!ContainerThreadMarker.isContainerThread()) {
268
            if (!coyoteRequest.isRequestThread()) {
270
                coyoteRequest.action(ActionCode.DISPATCH_READ, null);
269
                coyoteRequest.action(ActionCode.DISPATCH_READ, null);
271
                coyoteRequest.action(ActionCode.DISPATCH_EXECUTE, null);
270
                coyoteRequest.action(ActionCode.DISPATCH_EXECUTE, null);
272
            }
271
            }
(-)a/java/org/apache/coyote/Request.java (-1 / +15 lines)
Lines 172-177 Link Here
172
    private long bytesRead=0;
172
    private long bytesRead=0;
173
    // Time of the request - useful to avoid repeated calls to System.currentTime
173
    // Time of the request - useful to avoid repeated calls to System.currentTime
174
    private long startTimeNanos = -1;
174
    private long startTimeNanos = -1;
175
    private long threadId = 0;
175
    private int available = 0;
176
    private int available = 0;
176
177
177
    private final RequestInfo reqProcessorMX=new RequestInfo(this);
178
    private final RequestInfo reqProcessorMX=new RequestInfo(this);
Lines 238-244 Link Here
238
                fireListener = true;
239
                fireListener = true;
239
            }
240
            }
240
            action(ActionCode.DISPATCH_READ, null);
241
            action(ActionCode.DISPATCH_READ, null);
241
            if (!ContainerThreadMarker.isContainerThread()) {
242
            if (!isRequestThread()) {
242
                // Not on a container thread so need to execute the dispatch
243
                // Not on a container thread so need to execute the dispatch
243
                action(ActionCode.DISPATCH_EXECUTE, null);
244
                action(ActionCode.DISPATCH_EXECUTE, null);
244
            }
245
            }
Lines 737-742 Link Here
737
        this.startTimeNanos = startTimeNanos;
738
        this.startTimeNanos = startTimeNanos;
738
    }
739
    }
739
740
741
    public long getThreadId() {
742
        return threadId;
743
    }
744
745
    public void setRequestThread() {
746
        threadId = Thread.currentThread().getId();
747
    }
748
749
    public boolean isRequestThread() {
750
        return Thread.currentThread().getId() == threadId;
751
    }
752
740
    // -------------------- Per-Request "notes" --------------------
753
    // -------------------- Per-Request "notes" --------------------
741
754
742
755
Lines 828-833 Link Here
828
        allDataReadEventSent.set(false);
841
        allDataReadEventSent.set(false);
829
842
830
        startTimeNanos = -1;
843
        startTimeNanos = -1;
844
        threadId = 0;
831
    }
845
    }
832
846
833
    // -------------------- Info  --------------------
847
    // -------------------- Info  --------------------
(-)a/java/org/apache/coyote/Response.java (-1 / +1 lines)
Lines 737-743 Link Here
737
                fireListener = true;
737
                fireListener = true;
738
            }
738
            }
739
            action(ActionCode.DISPATCH_WRITE, null);
739
            action(ActionCode.DISPATCH_WRITE, null);
740
            if (!ContainerThreadMarker.isContainerThread()) {
740
            if (!req.isRequestThread()) {
741
                // Not on a container thread so need to execute the dispatch
741
                // Not on a container thread so need to execute the dispatch
742
                action(ActionCode.DISPATCH_EXECUTE, null);
742
                action(ActionCode.DISPATCH_EXECUTE, null);
743
            }
743
            }
(-)a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java (-3 / +1 lines)
Lines 52-58 Link Here
52
import jakarta.servlet.http.HttpServletResponse;
52
import jakarta.servlet.http.HttpServletResponse;
53
53
54
import org.junit.Assert;
54
import org.junit.Assert;
55
import org.junit.Ignore;
56
import org.junit.Test;
55
import org.junit.Test;
57
56
58
import org.apache.catalina.Context;
57
import org.apache.catalina.Context;
Lines 929-935 Link Here
929
    }
928
    }
930
929
931
930
932
    @Ignore
933
    @Test
931
    @Test
934
    public void testDelayedNBWrite() throws Exception {
932
    public void testDelayedNBWrite() throws Exception {
935
        Tomcat tomcat = getTomcatInstance();
933
        Tomcat tomcat = getTomcatInstance();
Lines 979-985 Link Here
979
            try {
977
            try {
980
                ByteChunk result = new ByteChunk();
978
                ByteChunk result = new ByteChunk();
981
                int rc = getUrl(url, result, null);
979
                int rc = getUrl(url, result, null);
982
                Assert.assertTrue(rc == HttpServletResponse.SC_OK);
980
                Assert.assertEquals(HttpServletResponse.SC_OK, rc);
983
                Assert.assertTrue(result.toString().contains("OK"));
981
                Assert.assertTrue(result.toString().contains("OK"));
984
            } catch (Throwable e) {
982
            } catch (Throwable e) {
985
                e.printStackTrace();
983
                e.printStackTrace();

Return to bug 65757