Skip to content

Commit

Permalink
No throw from read
Browse files Browse the repository at this point in the history
Fixes #11363 by ensuring that read never throws, but instead returns an Error chunk.
  • Loading branch information
gregw committed Feb 2, 2024
1 parent 2584eb0 commit a38e1a9
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -867,20 +867,27 @@ public long getLength()
@Override
public Content.Chunk read()
{
HttpStream stream;
try (AutoLock ignored = _lock.lock())
Content.Chunk chunk;
try
{
HttpChannelState httpChannel = lockedGetHttpChannelState();
HttpStream stream;
try (AutoLock ignored = _lock.lock())
{
HttpChannelState httpChannel = lockedGetHttpChannelState();

Content.Chunk error = httpChannel._readFailure;
httpChannel._readFailure = Content.Chunk.next(error);
if (error != null)
return error;
Content.Chunk error = httpChannel._readFailure;
httpChannel._readFailure = Content.Chunk.next(error);
if (error != null)
return error;

stream = httpChannel._stream;
stream = httpChannel._stream;
}
chunk = stream.read();
}
catch (Throwable t)
{
return Content.Chunk.from(t, true);
}

Content.Chunk chunk = stream.read();

if (LOG.isDebugEnabled())
LOG.debug("read {}", chunk);
Expand Down

0 comments on commit a38e1a9

Please sign in to comment.