Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2733#discussion_r197836264
  
    --- Diff: storm-client/src/jvm/org/apache/storm/utils/Time.java ---
    @@ -185,8 +173,17 @@ public static void advanceTimeNanos(long nanos) {
             if (nanos < 0) {
                 throw new IllegalArgumentException("advanceTime only accepts 
positive time as an argument");
             }
    -        long newTime = SIMULATED_CURR_TIME_NANOS.addAndGet(nanos);
    -        LOG.debug("Advanced simulated time to {}", newTime);
    +        synchronized (SLEEP_TIMES_LOCK) {
    +            long newTime = SIMULATED_CURR_TIME_NANOS.addAndGet(nanos);
    +            Iterator<AtomicLong> sleepTimesIter = 
THREAD_SLEEP_TIMES_NANOS.values().iterator();
    +            while (sleepTimesIter.hasNext()) {
    +                AtomicLong curr = sleepTimesIter.next();
    +                if (SIMULATED_CURR_TIME_NANOS.get() >= curr.get()) {
    +                    sleepTimesIter.remove();
    +                }
    +            }
    +            LOG.debug("Advanced simulated time to {}", newTime);
    +        }
    --- End diff --
    
    nit: I don't think this change is needed.  every time we add in a thread to 
the THREAD_SLEEP_TIMES_NANOS, there is a finally to remove it at the end.


---

Reply via email to