-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
If an async servlet is in a loop like:
ServletOutputStream out = response.getOutputStream();
out.setWriteListener(new WriteListener()
{
public void onWritePossible()
{
try
{
while (out.isReady())
out.write(someBuffer);
}
catch(Throwable t)
{
t.printStackTrace();
}
}
public void onError(Throwable t)
{
t.printStackTrace();
}
});and the client receiving the response closes the connection at some point, then we see different behaviors from Jetty, Tomcat and Undertow:
- Jetty throws from write and calls onError with a different exception. If
isReady()is called it returns true. - Tomcat throws from write and calls onError with the cause of the original exception. If
isReady()is called it returns false. - Undertow throws from the write, but never calls onError. If
isReady()is called it return false, but thenonErroris still not called.
I'm not sure any of these behaviors is strictly correct:
- should onError be called for an exception that has already been thrown to the application?
- should onError every be called if
isReady()has not been called and has not returned false? - should the write every actually throw? instead should
isReady()return false and thenonErroris called with the problem? - if the write has thrown, what should
isReady()return?
Metadata
Metadata
Assignees
Labels
No labels