Skip to content

Commit 4eb4d9d

Browse files
committed
GH-1983: Fix New Sonar Issues
1 parent 0535760 commit 4eb4d9d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,12 @@ public ProducerFactory<K, V> copyWithConfigurationOverride(Map<String, Object> o
470470
* @return the producerProperties or a copy with the transaction ID set
471471
*/
472472
private Map<String, Object> ensureExistingTransactionIdPrefixInProperties(Map<String, Object> producerProperties) {
473-
String transactionIdPrefix = getTransactionIdPrefix();
474-
if (StringUtils.hasText(transactionIdPrefix)) {
475-
if (!producerProperties.containsKey(ProducerConfig.TRANSACTIONAL_ID_CONFIG)) {
476-
Map<String, Object> producerPropertiesWithTxnId = new HashMap<>(producerProperties);
477-
producerPropertiesWithTxnId.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, transactionIdPrefix);
478-
return producerPropertiesWithTxnId;
479-
}
473+
String txIdPrefix = getTransactionIdPrefix();
474+
if (StringUtils.hasText(txIdPrefix)
475+
&& !producerProperties.containsKey(ProducerConfig.TRANSACTIONAL_ID_CONFIG)) {
476+
Map<String, Object> producerPropertiesWithTxnId = new HashMap<>(producerProperties);
477+
producerPropertiesWithTxnId.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, txIdPrefix);
478+
return producerPropertiesWithTxnId;
480479
}
481480

482481
return producerProperties;

0 commit comments

Comments
 (0)