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

    https://github.com/apache/activemq-artemis/pull/1596#discussion_r145455314
  
    --- Diff: 
artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java
 ---
    @@ -90,7 +90,7 @@ public 
ActiveMQScheduledComponent(ScheduledExecutorService scheduledExecutorServ
                                          long checkPeriod,
                                          TimeUnit timeUnit,
                                          boolean onDemand) {
    -      this(scheduledExecutorService, executor, checkPeriod, checkPeriod, 
timeUnit, onDemand);
    +      this(scheduledExecutorService, executor, -1, checkPeriod, timeUnit, 
onDemand);
    --- End diff --
    
    I'm receiving an error in the test `testVerifyDefaultInitialDelay`:
    ```
    java.lang.AssertionError: The initial delay must be defaulted to the period 
    Expected :100
    Actual   :-1
    ```
    Modifying things like this (and leaving the constructor as it is) doesn't 
break any tests:
    ```
       // this will restart the scheduled component upon changes
       private void restartIfNeeded() {
          if (isStarted()) {
             stop();
             //do not need to start with the initialDelay: the component was 
already running
             start(this.period);
          }
       }
    
       private void start(final long initialDelay) {
          if (future != null) {
             // already started
             return;
          }
    
          if (scheduledExecutorService == null) {
             scheduledExecutorService = new ScheduledThreadPoolExecutor(1, 
getThreadFactory());
             startedOwnScheduler = true;
    
          }
    
          if (onDemand) {
             return;
          }
    
          this.millisecondsPeriod = timeUnit.convert(period, 
TimeUnit.MILLISECONDS);
    
          if (period >= 0) {
             future = 
scheduledExecutorService.scheduleWithFixedDelay(runForScheduler, initialDelay, 
period, timeUnit);
          } else {
             logger.tracef("did not start scheduled executor on %s because 
period was configured as %d", this, period);
          }
       }
    
       @Override
       public synchronized void start() {
          start(this.initialDelay);
       }
    ```


---

Reply via email to