Skip to content

Commit 71f4767

Browse files
committed
Fix new Sonar issues
1 parent ab344af commit 71f4767

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/AbstractMessageListenerContainer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ public void onPartitionsAssigned(Collection<TopicPartition> partitions) {
367367
}
368368

369369
protected void publishContainerStoppedEvent() {
370-
ApplicationEventPublisher applicationEventPublisher = getApplicationEventPublisher();
371-
if (applicationEventPublisher != null) {
372-
applicationEventPublisher.publishEvent(new ContainerStoppedEvent(this, parentOrThis()));
370+
ApplicationEventPublisher eventPublisher = getApplicationEventPublisher();
371+
if (eventPublisher != null) {
372+
eventPublisher.publishEvent(new ContainerStoppedEvent(this, parentOrThis()));
373373
}
374374
}
375375

spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@
112112
* @author Yang Qiju
113113
* @author Tom van den Berge
114114
*/
115-
public class KafkaMessageListenerContainer<K, V>
116-
extends AbstractMessageListenerContainer<K, V> { // NOSONAR comment density
115+
public class KafkaMessageListenerContainer<K, V> // NOSONAR comment density
116+
extends AbstractMessageListenerContainer<K, V> {
117117

118118
private static final int DEFAULT_ACK_TIME = 5000;
119119

@@ -383,6 +383,8 @@ public String toString() {
383383

384384
private final class ListenerConsumer implements SchedulingAwareRunnable, ConsumerSeekCallback {
385385

386+
private static final String UNCHECKED = "unchecked";
387+
386388
private static final String RAWTYPES = "rawtypes";
387389

388390
private static final String RAW_TYPES = RAWTYPES;
@@ -486,7 +488,7 @@ private final class ListenerConsumer implements SchedulingAwareRunnable, Consume
486488

487489
private volatile long lastPoll = System.currentTimeMillis();
488490

489-
@SuppressWarnings("unchecked")
491+
@SuppressWarnings(UNCHECKED)
490492
ListenerConsumer(GenericMessageListener<?> listener, ListenerType listenerType) {
491493
Assert.state(!this.isAnyManualAck || !this.autoCommit,
492494
() -> "Consumer cannot be configured for auto commit for ackMode "
@@ -947,7 +949,7 @@ private void invokeBatchListener(final ConsumerRecords<K, V> records) {
947949
}
948950
}
949951

950-
@SuppressWarnings({ "unchecked", RAW_TYPES })
952+
@SuppressWarnings({ UNCHECKED, RAW_TYPES })
951953
private void invokeBatchListenerInTx(final ConsumerRecords<K, V> records,
952954
final List<ConsumerRecord<K, V>> recordList) {
953955
try {
@@ -1100,7 +1102,7 @@ private void invokeRecordListener(final ConsumerRecords<K, V> records) {
11001102
* Invoke the listener with each record in a separate transaction.
11011103
* @param records the records.
11021104
*/
1103-
@SuppressWarnings({ "unchecked", RAW_TYPES })
1105+
@SuppressWarnings({ UNCHECKED, RAW_TYPES })
11041106
private void invokeRecordListenerInTx(final ConsumerRecords<K, V> records) {
11051107
Iterator<ConsumerRecord<K, V>> iterator = records.iterator();
11061108
while (iterator.hasNext()) {
@@ -1317,7 +1319,7 @@ else if (!this.isAnyManualAck && !this.autoCommit) {
13171319
}
13181320
}
13191321

1320-
@SuppressWarnings({ "unchecked", RAW_TYPES })
1322+
@SuppressWarnings({ UNCHECKED, RAW_TYPES })
13211323
private void sendOffsetsToTransaction(Producer producer) {
13221324
handleAcks();
13231325
Map<TopicPartition, OffsetAndMetadata> commits = buildCommits();
@@ -1674,7 +1676,7 @@ public void onPartitionsAssigned(Collection<TopicPartition> partitions) {
16741676
ListenerConsumer.this.transactionTemplate
16751677
.execute(new TransactionCallbackWithoutResult() {
16761678

1677-
@SuppressWarnings({"unchecked", RAWTYPES})
1679+
@SuppressWarnings({UNCHECKED, RAWTYPES})
16781680
@Override
16791681
protected void doInTransactionWithoutResult(TransactionStatus status) {
16801682
KafkaResourceHolder holder =

0 commit comments

Comments
 (0)