398467 Servlet 3.1 Non Blocking IO
fixed lock issue detected by Threadsafe from contemplateltd.com
This commit is contained in:
parent
987aa846cc
commit
9f5f7e9ead
|
@ -217,7 +217,28 @@ public abstract class HttpInput<T> extends ServletInputStream implements Runnabl
|
|||
}
|
||||
}
|
||||
|
||||
public abstract void consumeAll();
|
||||
/* ------------------------------------------------------------ */
|
||||
public void consumeAll()
|
||||
{
|
||||
synchronized (lock())
|
||||
{
|
||||
try
|
||||
{
|
||||
while (!isFinished())
|
||||
{
|
||||
T item = getNextContent();
|
||||
if (item==null)
|
||||
_state.waitForContent(this);
|
||||
else
|
||||
consume(item,remaining(item));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished()
|
||||
|
|
|
@ -155,53 +155,6 @@ class HttpInputOverHTTP extends HttpInput<ByteBuffer> implements Callback
|
|||
_content=item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeAll()
|
||||
{
|
||||
final HttpParser parser = _httpConnection.getParser();
|
||||
try
|
||||
{
|
||||
ByteBuffer requestBuffer = null;
|
||||
while (!parser.isComplete())
|
||||
{
|
||||
_content=null;
|
||||
_httpConnection.getParser().parseNext(requestBuffer==null?BufferUtil.EMPTY_BUFFER:requestBuffer);
|
||||
|
||||
if (parser.isComplete())
|
||||
break;
|
||||
|
||||
if (BufferUtil.isEmpty(requestBuffer))
|
||||
{
|
||||
if ( _httpConnection.getEndPoint().isInputShutdown())
|
||||
parser.atEOF();
|
||||
else
|
||||
{
|
||||
requestBuffer=_httpConnection.getRequestBuffer();
|
||||
|
||||
if (BufferUtil.isEmpty(requestBuffer))
|
||||
{
|
||||
int filled=_httpConnection.getEndPoint().fill(requestBuffer);
|
||||
if (filled==0)
|
||||
filled=_httpConnection.getEndPoint().fill(requestBuffer);
|
||||
|
||||
if (filled<0)
|
||||
_httpConnection.getParser().atEOF();
|
||||
else if (filled==0)
|
||||
{
|
||||
blockForContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
LOG.ignore(e);
|
||||
_httpConnection.getParser().atEOF();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unready()
|
||||
{
|
||||
|
|
|
@ -165,26 +165,4 @@ public abstract class QueuedHttpInput<T> extends HttpInput<T>
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void consumeAll()
|
||||
{
|
||||
synchronized (lock())
|
||||
{
|
||||
try
|
||||
{
|
||||
while (!isFinished())
|
||||
{
|
||||
T item = getNextContent();
|
||||
if (item==null)
|
||||
blockForContent();
|
||||
else
|
||||
consume(item,remaining(item));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue