ddupg commented on a change in pull request #2286:
URL: https://github.com/apache/hbase/pull/2286#discussion_r474396182



##########
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXConnectorServer.java
##########
@@ -56,39 +58,47 @@
   private static Configuration conf = null;
   private static Admin admin;
   // RMI registry port
-  private static int rmiRegistryPort = 61120;
+  private static int rmiRegistryPort;
   // Switch for customized Accesscontroller to throw ACD exception while 
executing test case
-  static boolean hasAccess;
+  private volatile static boolean hasAccess;
 
-  @Before
-  public void setUp() throws Exception {
-    UTIL = new HBaseTestingUtility();
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
     conf = UTIL.getConfiguration();
+    String cps = JMXListener.class.getName() + "," + 
MyAccessController.class.getName();
+    conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, cps);
+    conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, cps);
+    rmiRegistryPort = UTIL.randomFreePort();

Review comment:
       Thank @saintstack for reviewing.
   
   For JMXConnectorServer starting, only use the default port or specifying 
port, can't find a free port by retrying. So I use 
HBaseTestingUtility#randomFreePort to get a free port, which mark ports as 
taken and don't return repeated ports. This patch may not completely avoid port 
clash, but at least it can reduce the possibility ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to