Skip to content

Commit

Permalink
Fix Race with Delayed Idle
Browse files Browse the repository at this point in the history
Defer setting the initial `lastReceive` until after the consumer is
created.

The `delayedIdleEvent()` test in `ConcurrentMessageListenerContainerMockTests`
could fail because the event might be published a few milliseconds before the
expected 500.
  • Loading branch information
garyrussell committed Jul 17, 2023
1 parent c7102f0 commit dc6a38f
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ private final class ListenerConsumer implements SchedulingAwareRunnable, Consume

private boolean taskSchedulerExplicitlySet;

private long lastReceive = System.currentTimeMillis();
private long lastReceive;

private long lastAlertAt = this.lastReceive;

Expand Down Expand Up @@ -1299,6 +1299,7 @@ public void run() {
initAssignedPartitions();
publishConsumerStartedEvent();
Throwable exitThrowable = null;
this.lastReceive = System.currentTimeMillis();
while (isRunning()) {
try {
pollAndInvoke();
Expand Down

0 comments on commit dc6a38f

Please sign in to comment.