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 2015/11/26 16:18:24 UTC

[Bug 58657] New: Spring DefferredResult errorResult response not returned in async servlet 3.1 mode

https://bz.apache.org/bugzilla/show_bug.cgi?id=58657

            Bug ID: 58657
           Summary: Spring DefferredResult errorResult response not
                    returned in async servlet 3.1 mode
           Product: Tomcat 8
           Version: 8.0.28
          Hardware: Macintosh
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Util
          Assignee: dev@tomcat.apache.org
          Reporter: jonathan.keenan@gmail.com

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #7 from Mark Thomas <ma...@apache.org> ---
Daft question. What URL do I need to request to see the issue?

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #6 from Jonathan <jo...@gmail.com> ---
Created attachment 33312
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33312&action=edit
Maven project of demo

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #10 from Mark Thomas <ma...@apache.org> ---
A little more information for anyone researching this in the future.

Once Tomcat encounters an error, it normally closes the connection. How quickly
it does this depends on the severity of the error. If the error appears to be
mild enough to allow a response to be written, Tomcat will:
- swallow any remaining input
- write the error response
- close the connection

There is a limit to how much input Tomcat will swallow (connector attribute
maxSwallowSize). If more data than this needs to be read, Tomcat will close the
connection immediately without writing an error response. This is because many
clients don't read the response until the request has been fully written.

-- 
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


[Bug 58657] Spring DefferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #3 from Jonathan <jo...@gmail.com> ---
I have attached two classes as part of a spring boot demo to show an issue we
are running into. (Would have attached whole war but for file size limit,
please contact if you would like it.)

With a simple Spring MVC controller using Springs DeferredResult object and
Servlet 3.1 asynchronous requests, there is an issue whereby if an error occurs
in the onDataAvailable() method and the onError() method is called, the error
response is never returned to the user.

With Jetty the exact same code returns the error response message and a HTTP
status code.

I have tried to look through both the Jetty code and Tomcat code to see where
the difference may lie and unfortunately it is unclear to me. The actual
dispatching of the async request seems to happen similarly in both containers
in that the Async state is set to DISPATCHING etc. but when the responses are
returned to the WebAsyncManager that Spring is using to
setConcurrentResultAndDispatch() that the problem appears to occur. I tried to
follow the code path but once the tomcat demo goes into NioEndPoint.class, its
here that the response is completely severed.

This issue does not occur if returning normal responses from a Spring
Controller, only when using DeferredResults.

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #9 from Mark Thomas <ma...@apache.org> ---
OK. I have this working now. Some additional details for other people who want
to try this test case:
- URL expects POST requests. I used JMeter to send one.
- The POST body needs to be big enough that it isn't all read at the same time.
I added an ~8MB text file to the POST

Tomcat is handling the error and immediately closing the connection. This is by
design. I need to dig further to understand what use case led to this approach
and if we can take a more relaxed approach and close the connection cleanly
rather than immediately.

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #5 from Jonathan <jo...@gmail.com> ---
Hi Mark,

Sorry about that. I've attached a zip there of the project. Its a maven project
and can be assembled with the usual mvn clean install to get the WAR

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

Jonathan <jo...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #8 from Jonathan <jo...@gmail.com> ---
(In reply to Mark Thomas from comment #7)
> Daft question. What URL do I need to request to see the issue?

Not daft at all, terrible naming convention on my part...

http://localhost:8080/demo-0.0.1-SNAPSHOT/demo/hello/test

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #4 from Mark Thomas <ma...@apache.org> ---
Your test case, while welcome, assumes the Tomcat developers are familiar with
Spring Boot.

A zip or tar.gz of the source tree, a pointer to a github project or similar to
build the WAR would be better. Assuming, of course, the build uses a standard
build tool like Ant, Maven, Gradle etc.

While the offer of the WAR is appreciated, cynical souls that we are, we aren't
too keen on running some random binary we know little about.

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

Jonathan <jo...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Spring DefferredResult      |Spring DeferredResult
                   |errorResult response not    |errorResult response not
                   |returned in async servlet   |returned in async servlet
                   |3.1 mode                    |3.1 mode

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

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

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

--- Comment #11 from Mark Thomas <ma...@apache.org> ---
Fixed in 9.0.x for 9.0.0.M2 and in 8.0.x for 8.0.30.

-- 
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


[Bug 58657] Spring DeferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #12 from Jonathan <jo...@gmail.com> ---
Thank you Mark.

-- 
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


[Bug 58657] Spring DefferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #2 from Jonathan <jo...@gmail.com> ---
Created attachment 33302
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33302&action=edit
Application config file for demo

App config file for Spring boot demo

-- 
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


[Bug 58657] Spring DefferredResult errorResult response not returned in async servlet 3.1 mode

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

--- Comment #1 from Jonathan <jo...@gmail.com> ---
Created attachment 33301
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33301&action=edit
Main class of demo

Spring boot java class showing demonstration of error

-- 
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