@Test
  public void testRunThriftServer() throws Exception {
    // Add retries in case we see stuff like connection reset
    Exception clientSideException = null;
    for (int i = 0; i < 10; i++) {
      clientSideException = null;
      ThriftServerRunner thriftServerRunner = createBoundServer(getThriftServerSupplier(),
        this.implType, this.specifyFramed, this.specifyCompact, this.specifyBindIP);
      try {
        talkToThriftServer(thriftServerRunner.getThriftServer().listenPort);
        break;
      } catch (Exception ex) {
        clientSideException = ex;
        LOG.info("Exception", ex);
      } finally {
        LOG.debug("Stopping " + this.implType.simpleClassName() + " Thrift server");
        thriftServerRunner.close();
        thriftServerRunner.join();
        if (thriftServerRunner.getRunException() != null) {
          LOG.error("Command-line invocation of HBase Thrift server threw exception",
            thriftServerRunner.getRunException());
          throw thriftServerRunner.getRunException();
        }
      }
    }

    if (clientSideException != null) {
      LOG.error("Thrift Client; parameters={}", getParametersString(), clientSideException);
      throw new Exception(clientSideException);
    }
  }
@param protocolPortClash This param is just so we can manufacture a port clash so we can test
                         the code does the right thing when this happens during actual test
                         runs. Ugly but works.
@see TestBindExceptionHandling#testProtocolPortClash()
hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java