443158 Fixed HttpOutput spin

This commit is contained in:
Greg Wilkins 2014-09-03 15:01:10 +10:00
parent e03b511415
commit c3647f9d9f
1 changed files with 7 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritePendingException; import java.nio.channels.WritePendingException;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener; import javax.servlet.WriteListener;
@ -780,11 +781,12 @@ public class HttpOutput extends ServletOutputStream implements Runnable
switch(_state.get()) switch(_state.get())
{ {
case READY:
case CLOSED: case CLOSED:
// even though a write is not possible, because a close has // even though a write is not possible, because a close has
// occurred, we need to call onWritePossible to tell async // occurred, we need to call onWritePossible to tell async
// producer that the last write completed. // producer that the last write completed.
// so fall through
case READY:
try try
{ {
_writeListener.onWritePossible(); _writeListener.onWritePossible();
@ -795,8 +797,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
_onError=e; _onError=e;
} }
break; break;
default:
default:
_onError=new IllegalStateException("state="+_state.get());
} }
} }
} }
@ -841,7 +844,7 @@ public class HttpOutput extends ServletOutputStream implements Runnable
@Override @Override
public void onCompleteFailure(Throwable e) public void onCompleteFailure(Throwable e)
{ {
_onError=e; _onError=e==null?new IOException():e;
_channel.getState().onWritePossible(); _channel.getState().onWritePossible();
} }
} }