You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2011/04/26 11:32:33 UTC

DO NOT REPLY [Bug 51120] New: Nullpointer exception in CoyoteAdapter when the Client disconnects the socket abruptly.

https://issues.apache.org/bugzilla/show_bug.cgi?id=51120

           Summary: Nullpointer exception in CoyoteAdapter when the Client
                    disconnects the socket abruptly.
           Product: Tomcat 7
           Version: 7.0.12
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: saravananl@te-soft.com


The tomcat container throws an expception to the log , when the client
disconnects the socket abruptly. 
The exception is ,
SEVERE: An exception or error occurred in the container during the request
processing
java.lang.NullPointerException
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:426)
    at
org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:396)
    at
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:357)
    at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1531)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)


Steps, 
1. I have a desktop client written in python. It sends a HTTP request with
content length of 1000. 
2. Server responds with BEGIN
3. The desktop makes use of NIO to hold the connection for updates .
4. When i close the python client before the timeout (declared in server) ,
this exception is thrown .


I have put forth a simple testing server code, 
My server.xml 
  <Connector port="9000" 
               connectionTimeout="216000" 
               protocol="org.apache.coyote.http11.Http11NioProtocol"
               redirectPort="8443" />

My testing server code ,
@Override
    public void event(CometEvent ce) throws IOException, ServletException {
        if (ce.getEventType() == CometEvent.EventType.BEGIN) {

        } else if (ce.getEventType() == CometEvent.EventType.ERROR) {
            ce.close();
        } else if (ce.getEventType() == CometEvent.EventType.END) {
            ce.close();
        } else if (ce.getEventType() == CometEvent.EventType.READ) {
    }
}

Other details
JDK Used : 1.6

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51120] Nullpointer exception in CoyoteAdapter when the Client disconnects the socket abruptly.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51120

--- Comment #2 from Darryl Miles <da...@darrylmiles.org> 2011-04-27 12:28:35 EDT ---

Possible candidate, notice the if(ctxt != null) check in other code that does
the same thing.  From the 1st hunk in the patch.

Line 320 (as shown in the patch - does not check context!=null) but was also
recently added, might need audit.
Line 430 (which was line 426 in user exception, plus the recent changes below
applied - does not check context!=null)

git clone https://github.com/apache/tomcat70.git
git diff TOMCAT_7_0_12

diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java
b/java/org/apache/catalina/connector/CoyoteAdapter.java
index de2f7d2..10fb3c5 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -271,7 +271,7 @@ public class CoyoteAdapter implements Adapter {
             if (!request.isAsync() && !comet) {
                 // Error or timeout - need to tell listeners the request is
over
                 // Have to test this first since state may change while in
this
-                // method and this is only required if entering this methos in
+                // method and this is only required if entering this method in
                 // this state 
                 Context ctxt = (Context) request.getMappingData().context;
                 if (ctxt != null) {
@@ -317,6 +317,10 @@ public class CoyoteAdapter implements Adapter {
                 request.finishRequest();
                 response.finishResponse();
                 req.action(ActionCode.POST_REQUEST , null);
+                ((Context) request.getMappingData().context).logAccess(
+                        request, response,
+                        System.currentTimeMillis() - req.getStartTime(),
+                        false);
             }

         } catch (IOException e) {

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51120] Nullpointer exception in CoyoteAdapter when the Client disconnects the socket abruptly.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51120

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME

--- Comment #3 from Mark Thomas <ma...@apache.org> 2011-05-04 10:52:09 UTC ---
I can't reproduce this with the latest 7.0.x code.

If you still see this issue with the latest 7.0.x code, please provide the
simplest possible test case the demonstrates the issue in source code form. In
this case a servlet and a JUnit test case that accesses the servlet would be
ideal.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51120] Nullpointer exception in CoyoteAdapter when the Client disconnects the socket abruptly.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51120

--- Comment #1 from Saravanan <sa...@te-soft.com> 2011-04-27 03:39:20 EDT ---
I think this might help.

In the comet connection, when the client sends some data basically triggering
the read event, the NPE exception is not coming. 

But if the client disconnects the socket without writing data(not triggering
READ) this problem happens.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org