@Override public boolean release(int decrement) { return content.release(decrement); } }
@Override public boolean release() { return content.release(); }
@Override public boolean release() { return content.release(); }
@Override public boolean release(int decrement) { return content.release(decrement); } }
@Override public void disposeBufferedBody() { bodyChunks.forEach(chunk -> { if ((chunk != null) && (chunk.refCnt() > 0)) { chunk.release(); } }); bodyChunks.clear(); }
@Override public void runBufferedBodyContentThroughFilter(ZuulFilter filter) { //Loop optimized for the common case: Most filters' processContentChunk() return // original chunk passed in as is without any processing for (int i=0; i < bodyChunks.size(); i++) { final HttpContent origChunk = bodyChunks.get(i); final HttpContent filteredChunk = filter.processContentChunk(this, origChunk); if ((filteredChunk != null) && (filteredChunk != origChunk)) { //filter actually did some processing, set the new chunk in and release the old chunk. bodyChunks.set(i, filteredChunk); final int refCnt = origChunk.refCnt(); if (refCnt > 0) { origChunk.release(refCnt); } } } }
public void write(final HttpContent chunk) { try { write(chunk.content()); gzos.flush(); } catch(IOException ioEx) { throw new ZuulException(ioEx, "Error Gzipping response content chunk", true); } finally { chunk.release(); } }
@Override public void disposeBufferedBody() { bodyChunks.forEach(chunk -> { if ((chunk != null) && (chunk.refCnt() > 0)) { chunk.release(); } }); bodyChunks.clear(); }
@Override public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof HttpResponse) { if (edgeProxy != null) { edgeProxy.responseFromOrigin((HttpResponse) msg); } ctx.channel().read(); } else if (msg instanceof HttpContent) { final HttpContent chunk = (HttpContent) msg; if (edgeProxy != null) { edgeProxy.invokeNext(chunk); } else { chunk.release(); } ctx.channel().read(); } else { //should never happen ReferenceCountUtil.release(msg); final Exception error = new IllegalStateException("Received invalid message from origin"); if (edgeProxy != null) { edgeProxy.errorFromOrigin(error); } ctx.fireExceptionCaught(error); } }
@Override public void runBufferedBodyContentThroughFilter(ZuulFilter filter) { //Loop optimized for the common case: Most filters' processContentChunk() return // original chunk passed in as is without any processing for (int i=0; i < bodyChunks.size(); i++) { final HttpContent origChunk = bodyChunks.get(i); final HttpContent filteredChunk = filter.processContentChunk(this, origChunk); if ((filteredChunk != null) && (filteredChunk != origChunk)) { //filter actually did some processing, set the new chunk in and release the old chunk. bodyChunks.set(i, filteredChunk); final int refCnt = origChunk.refCnt(); if (refCnt > 0) { origChunk.release(refCnt); } } } }
public void write(final HttpContent chunk) { try { write(chunk.content()); gzos.flush(); } catch(IOException ioEx) { throw new ZuulException(ioEx, "Error Gzipping response content chunk", true); } finally { chunk.release(); } }
channel.writeAndFlush(chunk); } else { chunk.release(); channel.close();
content.release();
content.release();
@Override public void filter(final HttpRequestMessage zuulReq, final HttpContent chunk) { if (zuulReq.getContext().isCancelled()) { chunk.release(); return; } String endpointName = "-"; try { ZuulFilter<HttpRequestMessage, HttpResponseMessage> endpoint = Preconditions.checkNotNull( getEndpoint(zuulReq), "endpoint"); endpointName = endpoint.filterName(); final HttpContent newChunk = endpoint.processContentChunk(zuulReq, chunk); if (newChunk != null) { //Endpoints do not directly forward content chunks to next stage in the filter chain. zuulReq.bufferBodyContents(newChunk); //deallocate original chunk if necessary if (newChunk != chunk) { chunk.release(); } if (isFilterAwaitingBody(zuulReq) && zuulReq.hasCompleteBody() && !(endpoint instanceof ProxyEndpoint)) { //whole body has arrived, resume filter chain invokeNextStage(filter(endpoint, zuulReq)); } } } catch (Exception ex) { handleException(zuulReq, endpointName, ex); } }
@Override public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof HttpResponse) { if (edgeProxy != null) { edgeProxy.responseFromOrigin((HttpResponse) msg); } ctx.channel().read(); } else if (msg instanceof HttpContent) { final HttpContent chunk = (HttpContent) msg; if (edgeProxy != null) { edgeProxy.invokeNext(chunk); } else { chunk.release(); } ctx.channel().read(); } else { //should never happen ReferenceCountUtil.release(msg); final Exception error = new IllegalStateException("Received invalid message from origin"); if (edgeProxy != null) { edgeProxy.errorFromOrigin(error); } ctx.fireExceptionCaught(error); } }
channel.writeAndFlush(chunk); } else { chunk.release(); channel.close();
@Override public void filter(final HttpRequestMessage zuulReq, final HttpContent chunk) { if (zuulReq.getContext().isCancelled()) { chunk.release(); return; } String endpointName = "-"; try { ZuulFilter<HttpRequestMessage, HttpResponseMessage> endpoint = Preconditions.checkNotNull( getEndpoint(zuulReq), "endpoint"); endpointName = endpoint.filterName(); final HttpContent newChunk = endpoint.processContentChunk(zuulReq, chunk); if (newChunk != null) { //Endpoints do not directly forward content chunks to next stage in the filter chain. zuulReq.bufferBodyContents(newChunk); //deallocate original chunk if necessary if (newChunk != chunk) { chunk.release(); } if (isFilterAwaitingBody(zuulReq) && zuulReq.hasCompleteBody() && !(endpoint instanceof ProxyEndpoint)) { //whole body has arrived, resume filter chain invokeNextStage(filter(endpoint, zuulReq)); } } } catch (Exception ex) { handleException(zuulReq, endpointName, ex); } }
chunk.release(chunk.refCnt());
chunk.release(chunk.refCnt());