eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
382 stars 143 forks source link

IllegalStateException if the async thread completed before the servlet thread #20239

Closed glassfishrobot closed 11 years ago

glassfishrobot commented 11 years ago
An exception or error occurred in the container during the request processing
java.lang.IllegalStateException: Internal org.glassfish.grizzly.http.server.Response has not been set
    at org.glassfish.grizzly.http.server.Response.checkResponse(Response.java:1840)
    at org.glassfish.grizzly.http.server.Response.getStatus(Response.java:968)
    at org.apache.catalina.connector.Response.getStatus(Response.java:1070)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:364)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:722)
import java.io.*;
import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;

@WebServlet(urlPatterns = {"/foo"}, asyncSupported=true)
public class MyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("MyServlet");

        final AsyncContext asyncContext = req.startAsync();
        new Thread() {
            @Override
            public void run() {
    asyncContext.complete();
            }
        }.start();

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            //
        }

        System.out.println("MyServlet - leaving");
    }
}
glassfishrobot commented 6 years ago
glassfishrobot commented 11 years ago

@glassfishrobot Commented @shingwaichan said: The actual async complete should be delay until the servlet is completed in this case. Similar issue is identified for async dispatch.

glassfishrobot commented 11 years ago

@glassfishrobot Commented @shingwaichan said: According to Servlet spec, the async complete should not take effect at that point.

glassfishrobot commented 11 years ago

@glassfishrobot Commented tmueller said: Approved for 4.0.

glassfishrobot commented 11 years ago

@glassfishrobot Commented @shingwaichan said: Sending web-core/src/main/java/org/apache/catalina/connector/AsyncContextImpl.java Sending web-core/src/main/java/org/apache/catalina/connector/Request.java Transmitting file data .. Committed revision 61411.

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-20239

glassfishrobot commented 11 years ago

@glassfishrobot Commented Reported by @shingwaichan

glassfishrobot commented 11 years ago

@glassfishrobot Commented Marked as fixed on Friday, April 12th 2013, 10:33:34 pm