You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "caigy (via GitHub)" <gi...@apache.org> on 2023/01/26 13:37:28 UTC

[GitHub] [rocketmq] caigy commented on a diff in pull request #5925: [ISSUE #5924]Optimize UtilAll#sleep method

caigy commented on code in PR #5925:
URL: https://github.com/apache/rocketmq/pull/5925#discussion_r1087865912


##########
common/src/main/java/org/apache/rocketmq/common/UtilAll.java:
##########
@@ -83,15 +84,18 @@ public static int getPid() {
     }
 
     public static void sleep(long sleepMs) {
-        if (sleepMs < 0) {
+        sleep(sleepMs, TimeUnit.MILLISECONDS);
+    }
+
+    public static void sleep(long timeOut, TimeUnit timeUnit) {
+        if (null == timeUnit) {
             return;
         }
         try {
-            Thread.sleep(sleepMs);
-        } catch (Throwable ignored) {
+            timeUnit.sleep(timeOut);
+        } catch (InterruptedException ignored) {

Review Comment:
   The new version is not equivalent to current version. IMO more relevant analysis is necessary to confirm this modification will not cause unexpected effects. 



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org