You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/07/02 07:41:24 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #11165: [ Cleanup ] Use Awaitility to instead of Thread sleep

eolivelli commented on a change in pull request #11165:
URL: https://github.com/apache/pulsar/pull/11165#discussion_r662805507



##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/util/netty/EventLoopUtil.java
##########
@@ -65,8 +65,8 @@ public static EventLoopGroup newEventLoopGroup(int nThreads, boolean enableBusyW
                     try {
                         CpuAffinity.acquireCore();
                     } catch (Throwable t) {
-                        log.warn("Failed to acquire CPU core for thread {}", Thread.currentThread().getName(),
-                                t.getMessage(), t);
+                        log.warn("Failed to acquire CPU core for thread {}, the error message is {}",

Review comment:
       log.warn will print the stacktrace when you pass a Throwable argument, so no need for "the error message is {}"

##########
File path: pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/GrowableArrayBlockingQueueTest.java
##########
@@ -131,11 +132,8 @@ public void blockingTake() throws Exception {
                 queue.put(n);
                 ++n;
             }
-
             // Wait until all the entries are consumed
-            while (!queue.isEmpty()) {
-                Thread.sleep(1);
-            }
+            Awaitility.await().until(queue::isEmpty);

Review comment:
       Awaitility will not pool every millisecond by default
   this change will slow down the test and probably is is overwhelming
   this is a test about a BlockingQueue, it is fine to have a Thread.sleep here
   it is not a cause of flaky tests




-- 
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@pulsar.apache.org

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