@@ -626,23 +626,31 @@ public boolean removePostProcessor(ProducerPostProcessor<K, V> postProcessor) {
626
626
627
627
@ Override
628
628
public void updateConfigs (Map <String , Object > updates ) {
629
- updates .entrySet ().forEach (entry -> {
630
- if (entry .getKey ().equals (ProducerConfig .TRANSACTIONAL_ID_CONFIG )) {
631
- Assert .isTrue (entry .getValue () instanceof String , () -> "'" + ProducerConfig .TRANSACTIONAL_ID_CONFIG
632
- + "' must be a String, not a " + entry .getClass ().getName ());
633
- Assert .isTrue (this .transactionIdPrefix != null
634
- ? entry .getValue () != null
635
- : entry .getValue () == null ,
636
- "Cannot change transactional capability" );
637
- this .transactionIdPrefix = (String ) entry .getValue ();
629
+ updates .forEach ((key , value ) -> {
630
+ if (key == null ) {
631
+ return ;
638
632
}
639
- else if (entry .getKey ().equals (ProducerConfig .CLIENT_ID_CONFIG )) {
640
- Assert .isTrue (entry .getValue () instanceof String , () -> "'" + ProducerConfig .CLIENT_ID_CONFIG
641
- + "' must be a String, not a " + entry .getClass ().getName ());
642
- this .clientIdPrefix = (String ) entry .getValue ();
633
+ if (key .equals (ProducerConfig .TRANSACTIONAL_ID_CONFIG )) {
634
+ Assert .isTrue (
635
+ value == null || value instanceof String ,
636
+ () -> "'" + ProducerConfig .TRANSACTIONAL_ID_CONFIG
637
+ + "' must be null or a String, not a " + value .getClass ().getName ()
638
+ );
639
+ Assert .isTrue (
640
+ (this .transactionIdPrefix != null ) == (value != null ),
641
+ "Cannot change transactional capability"
642
+ );
643
+ this .transactionIdPrefix = (String ) value ;
643
644
}
644
- else {
645
- this .configs .put (entry .getKey (), entry .getValue ());
645
+ else if (key .equals (ProducerConfig .CLIENT_ID_CONFIG )) {
646
+ Assert .isTrue (
647
+ value == null || value instanceof String ,
648
+ () -> "'" + ProducerConfig .CLIENT_ID_CONFIG
649
+ + "' must be null or a String, not a " + value .getClass ().getName ());
650
+ this .clientIdPrefix = (String ) value ;
651
+ }
652
+ else if (value != null ) {
653
+ this .configs .put (key , value );
646
654
}
647
655
});
648
656
}
0 commit comments