Decodes the response of an RPC and triggers its Deferred. This method is used by FrameDecoder when the channel gets disconnected. The buffer for that channel is passed to this method in case there's anything left in it. @param ctx Unused. @param chan The channel on which the res
(final ChannelHandlerContext ctx,
final Channel chan,
final ChannelBuffer buf,
final VoidEnum unused)
| 2002 | * @return {@code null}, always. |
| 2003 | */ |
| 2004 | @Override |
| 2005 | protected Object decodeLast(final ChannelHandlerContext ctx, |
| 2006 | final Channel chan, |
| 2007 | final ChannelBuffer buf, |
| 2008 | final VoidEnum unused) { |
| 2009 | // When we disconnect, decodeLast is called instead of decode. |
| 2010 | // We simply check whether there's any data left in the buffer, in which |
| 2011 | // case we attempt to process it. But if there's no data left, then we |
| 2012 | // don't even bother calling decode() as it'll complain that the buffer |
| 2013 | // doesn't contain enough data, which unnecessarily pollutes the logs. |
| 2014 | if (buf.readable()) { |
| 2015 | try { |
| 2016 | return decode(ctx, chan, buf, unused); |
| 2017 | } finally { |
| 2018 | if (buf.readable()) { |
| 2019 | LOG.error("After decoding the last message on " + chan |
| 2020 | + ", there was still some undecoded bytes in the channel's" |
| 2021 | + " buffer (which are going to be lost): " |
| 2022 | + buf + '=' + Bytes.pretty(buf)); |
| 2023 | } |
| 2024 | } |
| 2025 | } else { |
| 2026 | return null; |
| 2027 | } |
| 2028 | } |
| 2029 | |
| 2030 | /** |
| 2031 | * Package private method to allow the timeout timer or other methods |