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

--- Comment #8 from Han Li <li...@apache.org> ---
(In reply to Mark Thomas from comment #7)
> The original bug report was for two JSON responses in a single HTTP
> response. Is that still an issue?
> 
> Is the error message regarding the response already being committed in
> addition to the multiple JSON bodies or instead of the mutliple JSON bodies?
Hmm, I don't think it's a matter of how many JSON responses in a signle HTTP
response, but of exception handling.

I dug a little deeper and have written a simple unit test[1] to simulate this
scenario. 

To put it simply, Spring encapsulates the exception into JSON and responds
normally, and at the same time sets the RequestDispatcher.ERROR_EXCEPTION
attribute. I am not sure whether this behavior is reasonable, but I don't think
it's a tomcat problem, the way I see it the handling is very reasonable. On the
other hand, spring's behavior is very odd.

There is a simple way to fix this issue, we can see whether the response is
committed, if true, do not deal with RequestDispatcher.ERROR_EXCEPTION.
---
if (request.isAsyncDispatching()) {
   
connector.getService().getContainer().getPipeline().getFirst().invoke(request,
response);
    Throwable t = (Throwable)
request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
    if (t != null && !response.isCommitted()) { <-------- here
        asyncConImpl.setErrorState(t, true);
    }
}
---

Since I am not familiar with this specification, still need Mark to judge...

Hope this helps! ; )

[1].https://gist.github.com/aooohan/b4fd3e1bce5ddda09b51e45173b5ed33

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to