mirror of https://github.com/apache/druid.git
BytesFullResponseHandler should only consume readableBytes of ChannelBuffer (#6270)
This commit is contained in:
parent
9b04846e6b
commit
951b36e2bc
|
@ -22,6 +22,7 @@ package org.apache.druid.security.basic.authentication;
|
|||
import org.apache.druid.java.util.http.client.response.ClientResponse;
|
||||
import org.apache.druid.java.util.http.client.response.FullResponseHolder;
|
||||
import org.apache.druid.java.util.http.client.response.HttpResponseHandler;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.handler.codec.http.HttpChunk;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponse;
|
||||
|
||||
|
@ -36,7 +37,7 @@ public class BytesFullResponseHandler implements HttpResponseHandler<FullRespons
|
|||
null
|
||||
);
|
||||
|
||||
holder.addChunk(response.getContent().array());
|
||||
holder.addChunk(getContentBytes(response.getContent()));
|
||||
|
||||
return ClientResponse.unfinished(
|
||||
holder
|
||||
|
@ -55,7 +56,7 @@ public class BytesFullResponseHandler implements HttpResponseHandler<FullRespons
|
|||
return ClientResponse.finished(null);
|
||||
}
|
||||
|
||||
holder.addChunk(chunk.getContent().array());
|
||||
holder.addChunk(getContentBytes(chunk.getContent()));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -72,4 +73,11 @@ public class BytesFullResponseHandler implements HttpResponseHandler<FullRespons
|
|||
{
|
||||
// Its safe to Ignore as the ClientResponse returned in handleChunk were unfinished
|
||||
}
|
||||
|
||||
private byte[] getContentBytes(ChannelBuffer content)
|
||||
{
|
||||
byte[] contentBytes = new byte[content.readableBytes()];
|
||||
content.readBytes(contentBytes);
|
||||
return contentBytes;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue