From dda8018b0fd2939f98c8c86158226202f4692333 Mon Sep 17 00:00:00 2001 From: huzheng Date: Wed, 9 May 2018 10:44:35 +0800 Subject: [PATCH] Revert "Fix the flaky TestThriftHttpServer" This reverts commit 4f7aa3b71d2ebfa57f890c5ebaaf166fb7128597. --- .../hbase/thrift/TestThriftHttpServer.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java index 2366ee70b5d..6117953772d 100644 --- a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java +++ b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java @@ -57,6 +57,7 @@ import org.apache.hbase.thirdparty.com.google.common.base.Joiner; * interface and talk to it from client side. */ @Category({ClientTests.class, LargeTests.class}) + public class TestThriftHttpServer { @ClassRule @@ -117,14 +118,18 @@ public class TestThriftHttpServer { LOG.info("Starting HBase Thrift server with HTTP server: " + Joiner.on(" ").join(args)); httpServerException = null; - httpServerThread = new Thread(() -> { - try { - thriftServer.doMain(args); - } catch (Exception e) { - httpServerException = e; + httpServerThread = new Thread(new Runnable() { + @Override + public void run() { + try { + thriftServer.doMain(args); + } catch (Exception e) { + httpServerException = e; + } } }); - httpServerThread.setName(ThriftServer.class.getSimpleName() + "-httpServer"); + httpServerThread.setName(ThriftServer.class.getSimpleName() + + "-httpServer"); httpServerThread.start(); } @@ -163,9 +168,13 @@ public class TestThriftHttpServer { startHttpServerThread(args.toArray(new String[args.size()])); // wait up to 10s for the server to start - HBaseTestingUtility.waitForHostPort(HConstants.LOCALHOST, port); + for (int i = 0; i < 100 + && (thriftServer.serverRunner == null || thriftServer.serverRunner.httpServer == + null); i++) { + Thread.sleep(100); + } - String url = "http://" + HConstants.LOCALHOST + ":" + port; + String url = "http://"+ HConstants.LOCALHOST + ":" + port; try { checkHttpMethods(url); talkToThriftServer(url, customHeaderSize); @@ -177,7 +186,7 @@ public class TestThriftHttpServer { if (clientSideException != null) { LOG.error("Thrift client threw an exception " + clientSideException); - if (clientSideException instanceof TTransportException) { + if (clientSideException instanceof TTransportException) { throw clientSideException; } else { throw new Exception(clientSideException);