uber / tchannel-java

A Java implementation of the TChannel protocol.
MIT License
134 stars 65 forks source link

Make Tfuture.get more resilient #221

Closed denyska closed 4 years ago

denyska commented 4 years ago

Make code resilient when Tfuture.get() called directly and not thru the listener, i.e.

TFuture<ThriftResponse<Abcd>> future= serviceChannel.send(thriftRequest);
thriftResponse = future.get();
[2020-03-12 21:55:21.449] [WARN ] com.uber.tchannel.api.TFuture [TFuture.java:110] No handler is set when response is set. Resource leak may occur.
java.lang.IllegalStateException: null
    at com.uber.tchannel.api.TFuture.set(TFuture.java:110)
    at com.uber.tchannel.handlers.OutRequest.setResponseFuture(OutRequest.java:187)
    at com.uber.tchannel.handlers.OutRequest.setFuture(OutRequest.java:157)
    at com.uber.tchannel.handlers.OutRequest.handleResponse(OutRequest.java:166)
    at com.uber.tchannel.handlers.ResponseRouter.handleResponse(ResponseRouter.java:189)
    at com.uber.tchannel.handlers.ResponseRouter.channelRead0(ResponseRouter.java:194)
    at com.uber.tchannel.handlers.ResponseRouter.channelRead0(ResponseRouter.java:49)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:108)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:682)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:617)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:534)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)
codecov[bot] commented 4 years ago

Codecov Report

Merging #221 into master will increase coverage by 0.31%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #221      +/-   ##
============================================
+ Coverage     74.29%   74.60%   +0.31%     
  Complexity       11       11              
============================================
  Files            88       88              
  Lines          2898     2902       +4     
  Branches        370      370              
============================================
+ Hits           2153     2165      +12     
+ Misses          515      510       -5     
+ Partials        230      227       -3     
Impacted Files Coverage Δ Complexity Δ
...e/src/main/java/com/uber/tchannel/api/TFuture.java 76.92% <100.00%> (+1.92%) 0.00 <0.00> (ø)
...java/com/uber/tchannel/handlers/RequestRouter.java 78.38% <0.00%> (+1.80%) 0.00% <0.00%> (ø%)
...java/com/uber/tchannel/messages/ErrorResponse.java 88.24% <0.00%> (+5.88%) 0.00% <0.00%> (ø%)
...m/uber/tchannel/hyperbahn/api/HyperbahnClient.java 63.86% <0.00%> (+6.02%) 8.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3a37ad6...cceb6d1. Read the comment docs.

JigarJoshi commented 4 years ago

LGTM 👍