Source:
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getDeclaringClass() == Object.class) { switch (method.getName()) { case "toString": return clientDescription; case "equals": return equals(Proxy.getInvocationHandler(args[0])); case "hashCode": return hashCode(); default: throw new UnsupportedOperationException(); } } if (args == null) { args = NO_ARGS; } if (args.length == 0 && "close".equals(method.getName())) { channel.close(); return null; } ThriftMethodHandler methodHandler = methods.get(method); try { if (methodHandler == null) { throw new TApplicationException(UNKNOWN_METHOD, "Unknown method : '" + method + "'"); } if (channel.hasError()) { throw new TTransportException(channel.getError()); } SocketAddress remoteAddress = null; try { NiftyClientChannel niftyClientChannel = NiftyClientChannel.class.cast(channel); remoteAddress = niftyClientChannel.getNettyChannel().getRemoteAddress(); } catch (ClassCastException e) { throw new IllegalArgumentException("The swift client uses a channel that is not a NiftyClientChannel", e); } ClientRequestContext requestContext = new NiftyClientRequestContext(getInputProtocol(), getOutputProtocol(), remoteAddress); ClientContextChain context = new ClientContextChain(eventHandlers, methodHandler.getQualifiedName(), requestContext); return methodHandler.invoke(channel, inputTransport, outputTransport, inputProtocol, outputProtocol, sequenceId.getAndIncrement(), context, args); } catch (TException e) { Class<? extends TException> thrownType = e.getClass(); for (Class<?> exceptionType : method.getExceptionTypes()) { if (exceptionType.isAssignableFrom(thrownType)) { throw e; } } if (e instanceof TApplicationException) { throw new RuntimeTApplicationException(e.getMessage(), (TApplicationException) e); } if (e instanceof TProtocolException) { throw new RuntimeTProtocolException(e.getMessage(), (TProtocolException) e); } if (e instanceof TTransportException) { throw new RuntimeTTransportException(e.getMessage(), (TTransportException) e); } throw new RuntimeTException(e.getMessage(), e); } }

Target:
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getDeclaringClass() == Object.class) { switch (method.getName()) { case "toString": return clientDescription; case "equals": return equals(Proxy.getInvocationHandler(args[0])); case "hashCode": return hashCode(); default: throw new UnsupportedOperationException(); } } if (args == null) { args = NO_ARGS; } if (args.length == 0 && "close".equals(method.getName())) { channel.close(); return null; } ThriftMethodHandler methodHandler = methods.get(method); try { if (methodHandler == null) { throw new TApplicationException(UNKNOWN_METHOD, "Unknown method : '" + method + "'"); } if (channel.hasError()) { throw new TTransportException(channel.getError()); } SocketAddress remoteAddress = null; try { NiftyClientChannel niftyClientChannel = (NiftyClientChannel)channel; remoteAddress = niftyClientChannel.getNettyChannel().getRemoteAddress(); } catch (ClassCastException e) { throw new IllegalArgumentException("The swift client uses a channel that is not a NiftyClientChannel", e); } ClientRequestContext requestContext = new NiftyClientRequestContext(getInputProtocol(), getOutputProtocol(), remoteAddress); ClientContextChain context = new ClientContextChain(eventHandlers, methodHandler.getQualifiedName(), requestContext); return methodHandler.invoke(channel, inputTransport, outputTransport, inputProtocol, outputProtocol, sequenceId.getAndIncrement(), context, args); } catch (TException e) { Class<? extends TException> thrownType = e.getClass(); for (Class<?> exceptionType : method.getExceptionTypes()) { if (exceptionType.isAssignableFrom(thrownType)) { throw e; } } if (e instanceof TApplicationException) { throw new RuntimeTApplicationException(e.getMessage(), (TApplicationException) e); } if (e instanceof TProtocolException) { throw new RuntimeTProtocolException(e.getMessage(), (TProtocolException) e); } if (e instanceof TTransportException) { throw new RuntimeTTransportException(e.getMessage(), (TTransportException) e); } throw new RuntimeTException(e.getMessage(), e); } }