handle review comments
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
parent
f5db5209f4
commit
d02d2eb8bd
|
@ -72,7 +72,6 @@ public class GzipResponseAndCallback extends Response.Wrapper implements Callbac
|
|||
private final int _bufferSize;
|
||||
private final boolean _syncFlush;
|
||||
private DeflaterPool.Entry _deflaterEntry;
|
||||
private RetainableByteBuffer _buffer;
|
||||
private boolean _last;
|
||||
|
||||
public GzipResponseAndCallback(GzipHandler handler, Request request, Response response, Callback callback)
|
||||
|
@ -303,6 +302,7 @@ public class GzipResponseAndCallback extends Response.Wrapper implements Callbac
|
|||
{
|
||||
private final ByteBuffer _content;
|
||||
private final boolean _last;
|
||||
private RetainableByteBuffer _buffer;
|
||||
|
||||
public GzipBufferCB(boolean complete, Callback callback, ByteBuffer content)
|
||||
{
|
||||
|
@ -321,15 +321,17 @@ public class GzipResponseAndCallback extends Response.Wrapper implements Callbac
|
|||
LOG.debug("GzipBufferCB(complete={}, callback={}, content={})", complete, callback, BufferUtil.toDetailString(content));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCompleteSuccess()
|
||||
{
|
||||
cleanup();
|
||||
super.onCompleteSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCompleteFailure(Throwable x)
|
||||
{
|
||||
if (_deflaterEntry != null)
|
||||
{
|
||||
_state.set(GZState.FINISHED);
|
||||
_deflaterEntry.release();
|
||||
_deflaterEntry = null;
|
||||
}
|
||||
cleanup();
|
||||
super.onCompleteFailure(x);
|
||||
}
|
||||
|
||||
|
@ -347,7 +349,6 @@ public class GzipResponseAndCallback extends Response.Wrapper implements Callbac
|
|||
// then the trailer has been generated and written below.
|
||||
// We have finished compressing the entire content, so
|
||||
// cleanup and succeed.
|
||||
cleanup();
|
||||
return Action.SUCCEEDED;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.eclipse.jetty.http.HttpStatus;
|
|||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.io.Content;
|
||||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Context;
|
||||
import org.eclipse.jetty.server.FormFields;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
|
@ -220,7 +221,7 @@ public class GzipHandlerTest
|
|||
@Override
|
||||
public void write(boolean last, ByteBuffer byteBuffer, Callback callback)
|
||||
{
|
||||
throw new StacklessException("expected");
|
||||
throw new ArithmeticException("expected");
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
|
@ -242,11 +243,14 @@ public class GzipHandlerTest
|
|||
request.setHeader("Host", "tester");
|
||||
request.setHeader("accept-encoding", "gzip");
|
||||
|
||||
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
|
||||
try (StacklessLogging ignore = new StacklessLogging(Response.class))
|
||||
{
|
||||
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
|
||||
}
|
||||
|
||||
assertThat(response.getStatus(), is(500));
|
||||
String content = response.getContent();
|
||||
assertThat(content, containsString("StacklessException: expected"));
|
||||
assertThat(content, containsString("ArithmeticException: expected"));
|
||||
assertThat(content, not(containsString("Suppressed: ")));
|
||||
}
|
||||
|
||||
|
@ -2109,18 +2113,4 @@ public class GzipHandlerTest
|
|||
return super.handle(request, response, callback);
|
||||
}
|
||||
}
|
||||
|
||||
public static class StacklessException extends RuntimeException
|
||||
{
|
||||
public StacklessException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Throwable fillInStackTrace()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue