code: @SuppressWarnings("unchecked")
      public <X> X iface() throws ThriftException {
          ThriftClient<T> client;
          try {
              client = pool.borrowObject();
          } catch (Exception e) {
              if (e instanceof ThriftException) {
                  throw (ThriftException) e;
              }
              throw new ThriftException("Get client from pool failed.", e);
          }
          AtomicBoolean returnToPool = new AtomicBoolean(false);
          return (X) Proxy.newProxyInstance(this.getClass().getClassLoader(), client.iFace()
                  .getClass().getInterfaces(), (proxy, method, args) -> {
              if (returnToPool.get()) {
                  throw new IllegalStateException("Object returned via iface can only used once!");
              }
              boolean success = false;
              try {
                  Object result = method.invoke(client.iFace(), args);
                  success = true;
                  return result;
              } catch (Throwable e) {
                  logger.warn("invoke fail", e);
                  throw e;
              } finally {
                  if (success) {
                      pool.returnObject(client);
                  } else {
                      client.closeClient();
                      pool.invalidateObject(client);
                  }
                  returnToPool.set(true);
              }
          });
      }
docs: get a client's IFace from pool
  <p/>
  <ul>
  <li>
  <span style="color:red">Important: Iface is totally generated by
  thrift, a ClassCastException will be thrown if assign not
  match!</span></li>
  <li>
  <span style="color:red">Limitation: The return object can only used
  once.</span></li>
  </ul>
  
  @return
  @throws ThriftException
  @throws NoBackendServiceException if
  {@link PoolConfig#setFailover(boolean)} is set and no
  service can connect to
  @throws ConnectionFailException if
  {@link PoolConfig#setFailover(boolean)} not set and
  connection fail
  @throws IllegalStateException if call method on return object twice