|
75 | 75 | */ |
76 | 76 | public abstract class AbstractMessageListenerContainer<K, V> |
77 | 77 | implements GenericMessageListenerContainer<K, V>, BeanNameAware, ApplicationEventPublisherAware, |
78 | | - ApplicationContextAware { |
| 78 | + ApplicationContextAware { |
79 | 79 |
|
80 | 80 | /** |
81 | 81 | * The default {@link org.springframework.context.SmartLifecycle} phase for listener |
@@ -143,7 +143,6 @@ public abstract class AbstractMessageListenerContainer<K, V> |
143 | 143 | @Nullable |
144 | 144 | private KafkaAdmin kafkaAdmin; |
145 | 145 |
|
146 | | - |
147 | 146 | /** |
148 | 147 | * Construct an instance with the provided factory and properties. |
149 | 148 | * @param consumerFactory the factory. |
@@ -609,28 +608,36 @@ public final void stop() { |
609 | 608 | * @since 2.3.8 |
610 | 609 | */ |
611 | 610 | public final void stop(boolean wait) { |
612 | | - this.lifecycleLock.lock(); |
613 | | - try { |
614 | | - if (isRunning()) { |
615 | | - if (wait) { |
616 | | - final CountDownLatch latch = new CountDownLatch(1); |
| 611 | + if (isRunning()) { |
| 612 | + if (wait) { |
| 613 | + final CountDownLatch latch = new CountDownLatch(1); |
| 614 | + this.lifecycleLock.lock(); |
| 615 | + try { |
| 616 | + |
617 | 617 | doStop(latch::countDown); |
618 | | - try { |
619 | | - latch.await(this.containerProperties.getShutdownTimeout(), TimeUnit.MILLISECONDS); // NOSONAR |
620 | | - publishContainerStoppedEvent(); |
621 | | - } |
622 | | - catch (@SuppressWarnings("unused") InterruptedException e) { |
623 | | - Thread.currentThread().interrupt(); |
624 | | - } |
625 | 618 | } |
626 | | - else { |
| 619 | + finally { |
| 620 | + this.lifecycleLock.unlock(); |
| 621 | + } |
| 622 | + try { |
| 623 | + latch.await(this.containerProperties.getShutdownTimeout(), TimeUnit.MILLISECONDS); // NOSONAR |
| 624 | + publishContainerStoppedEvent(); |
| 625 | + } |
| 626 | + catch (@SuppressWarnings("unused") InterruptedException e) { |
| 627 | + Thread.currentThread().interrupt(); |
| 628 | + } |
| 629 | + } |
| 630 | + else { |
| 631 | + this.lifecycleLock.lock(); |
| 632 | + try { |
627 | 633 | doStop(this::publishContainerStoppedEvent); |
628 | 634 | } |
| 635 | + finally { |
| 636 | + this.lifecycleLock.unlock(); |
| 637 | + } |
| 638 | + |
629 | 639 | } |
630 | 640 | } |
631 | | - finally { |
632 | | - this.lifecycleLock.unlock(); |
633 | | - } |
634 | 641 | } |
635 | 642 |
|
636 | 643 | @Override |
@@ -706,7 +713,7 @@ public void onPartitionsAssigned(Collection<TopicPartition> partitions) { |
706 | 713 | @Override |
707 | 714 | public void onPartitionsLost(Collection<TopicPartition> partitions) { |
708 | 715 | AbstractMessageListenerContainer.this.logger.info(() -> |
709 | | - getGroupId() + ": partitions lost: " + partitions); |
| 716 | + getGroupId() + ": partitions lost: " + partitions); |
710 | 717 | } |
711 | 718 |
|
712 | 719 | }; |
|
0 commit comments