diqiu50 commented on code in PR #12146:
URL: https://github.com/apache/gravitino/pull/12146#discussion_r3654226560


##########
integration-test-common/src/test/java/org/apache/gravitino/integration/test/MiniGravitino.java:
##########
@@ -216,31 +233,39 @@ public void start() throws Exception {
   public void stop() throws IOException, InterruptedException {
     LOG.debug("MiniGravitino shutDown...");
 
-    executor.shutdown();
-    sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
-    executor.shutdownNow();
-
-    long beginTime = System.currentTimeMillis();
-    boolean started = true;
-
-    String url = String.format("http://%s:%d/metrics";, host, port);
-    while (System.currentTimeMillis() - beginTime < 1000 * 60 * 3) {
+    Throwable failure = null;
+    try {
+      executor.shutdown();
       sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
-      started = HttpUtils.isHttpServerUp(url);
-      if (!started) {
-        break;
+      executor.shutdownNow();
+
+      // The HTTP port may be closed before GravitinoServer.main() finishes 
shutting down the
+      // singleton GravitinoEnv. Wait for the server task to terminate so the 
next embedded server
+      // cannot initialize the same environment while this shutdown is still 
in progress.
+      if (!executor.awaitTermination(3, TimeUnit.MINUTES)) {
+        throw new RuntimeException("Can not terminate MiniGravitino server 
task");
       }
-    }
 
-    restClient.close();
-    try {
-      FileUtils.deleteDirectory(mockConfDir);
-    } catch (Exception e) {
-      // Ignore
-    }
+      long beginTime = System.currentTimeMillis();
+      boolean started = true;
 
-    if (started) {
-      throw new RuntimeException("Can not stop Gravitino server");

Review Comment:
   executor.shutdown() guarantees that the min server has already been stopped. 
The following code is redundant



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to