156357 2018-01-15 14:20:17,172 WARN [LittleProxy-0-ClientToProxyWorker-2] concurrent.DefaultPromise (Slf4JLogger.java:151).warn() - An exception was thrown by org.littleshoot.proxy.impl.ConnectionFlow$2.operationComplete()
io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
at io.netty.buffer.AbstractReferenceCountedByteBuf.release0(AbstractReferenceCountedByteBuf.java:91)
at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:79)
at io.netty.handler.codec.http.HttpObjectAggregator$AggregatedFullHttpMessage.release(HttpObjectAggregator.java:417)
at org.littleshoot.proxy.impl.ProxyToServerConnection.connectionSucceeded(ProxyToServerConnection.java:938)
at org.littleshoot.proxy.impl.ConnectionFlow.succeed(ConnectionFlow.java:168)
at org.littleshoot.proxy.impl.ConnectionFlow.advance(ConnectionFlow.java:88)
at org.littleshoot.proxy.impl.ConnectionFlowStep.onSuccess(ConnectionFlowStep.java:83)
at org.littleshoot.proxy.impl.ConnectionFlow$2.operationComplete(ConnectionFlow.java:149)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:500)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:479)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420)
at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104)
at io.netty.handler.ssl.SslHandler.setHandshakeSuccess(SslHandler.java:1324)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1172)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1039)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:643)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:566)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:131)
at java.lang.Thread.run(Thread.java:745)
public class DummyCredsMappingFilterSource extends HttpFiltersSourceAdapter
{
@Override
public int getMaximumRequestBufferSizeInBytes()
{
return 512 * 1024;
}
}
public class Launcher
{
...
public static void main(final String... args)
{
...
bootstrap.withFiltersSource(new DummyCredsMappingFilterSource());
...
}
...
}
My filtering code works fine, and has been doing so for some time, but I'd really like to not have to live with this spewage of warnings, both for utility and correctness.Is this a bug, or by returning a non-zero max buffer size, am I supposed to increment a reference count somewhere, or otherwise add some additional logic? The home page mentions this method, but says no such thing. Can anyone fill me in on what's going on here. It seems crazy for this to be an uncaught bug, so I really wonder if I'm missing something. TIA for any info....and btw, thanks to all contributors for this wonderful bit of code!StevePS: I am up to date with the latest code. I just did a merge, which consisted of a very small 4 character change that I knew wouldn't fix this when I first saw it.
public class ExternalProxyManager implements ChainedProxyManager
{
private static final String proxyIP = "67.220.228.92";
private static final int proxyPort = 21234;
protected class ExternalProxy extends ChainedProxyAdapter
{
private InetSocketAddress proxyAddress;
ExternalProxy(@SuppressWarnings("unused") HttpRequest request)
{
try
{
proxyAddress = new InetSocketAddress(InetAddress.getByName(proxyIP), proxyPort);
}
catch (UnknownHostException e)
{
throw new RuntimeException("Unable to resolve proxyIP?!");
}
}
@Override
public InetSocketAddress getChainedProxyAddress()
{
return proxyAddress;
}
}
@Override
public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies)
{
chainedProxies.add(new ExternalProxy(httpRequest));
}
}
public class Launcher
{
...
public static void main(final String... args)
{
...
bootstrap.withFiltersSource(new DummyCredsMappingFilterSource());
bootstrap.withChainProxyManager(new ExternalProxyManager());
...
}
...
}
// we're now done with the initialRequest: it's either been forwarded to the upstream server (HTTP requests), or
// completely dropped (HTTPS CONNECTs). if the initialRequest is reference counted (typically because the HttpObjectAggregator is in
// the pipeline to generate FullHttpRequests), we need to manually release it to avoid a memory leak.
if (initialRequest instanceof ReferenceCounted)
{
ReferenceCounted rcir = (ReferenceCounted) initialRequest;
// steve@inlet - added check of the reference count here because the ref count can be zero here, causing an
// exception when this release() call is made. After adding this, I'll have to see if we still have an
// underflow problem if the ref count can be decremented in a different order and so ultimately have an
// underrun at a different place in the code.
if (rcir.refCnt() > 0)
rcir.release();
}