diff --git a/extensions-core/druid-basic-security/src/main/java/io/druid/security/basic/authentication/BytesFullResponseHandler.java b/extensions-core/druid-basic-security/src/main/java/io/druid/security/basic/authentication/BytesFullResponseHandler.java index c548cfc0ac1a..a6d99714e067 100644 --- a/extensions-core/druid-basic-security/src/main/java/io/druid/security/basic/authentication/BytesFullResponseHandler.java +++ b/extensions-core/druid-basic-security/src/main/java/io/druid/security/basic/authentication/BytesFullResponseHandler.java @@ -22,6 +22,7 @@ import io.druid.java.util.http.client.response.ClientResponse; import io.druid.java.util.http.client.response.FullResponseHolder; import io.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 ClientResponse handleResponse(HttpResponse response) null ); - holder.addChunk(response.getContent().array()); + holder.addChunk(getContentBytes(response.getContent())); return ClientResponse.unfinished( holder @@ -55,7 +56,7 @@ public ClientResponse handleChunk( return ClientResponse.finished(null); } - holder.addChunk(chunk.getContent().array()); + holder.addChunk(getContentBytes(chunk.getContent())); return response; } @@ -72,4 +73,11 @@ public void exceptionCaught( { // 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; + } }