@@ -130,26 +130,34 @@ protected KafkaConsumer<K, V> createKafkaConsumer(@Nullable String groupId, @Nul
130130 return createKafkaConsumer (this .configs );
131131 }
132132 else {
133- Map <String , Object > modifiedConfigs = new HashMap <>(this .configs );
134- if (groupId != null ) {
135- modifiedConfigs .put (ConsumerConfig .GROUP_ID_CONFIG , groupId );
136- }
137- if (shouldModifyClientId ) {
138- modifiedConfigs .put (ConsumerConfig .CLIENT_ID_CONFIG ,
139- (overrideClientIdPrefix ? clientIdPrefix
140- : modifiedConfigs .get (ConsumerConfig .CLIENT_ID_CONFIG )) + clientIdSuffix );
141- }
142- if (properties != null ) {
143- properties .forEach ((k , v ) -> {
144- if (!k .equals (ConsumerConfig .CLIENT_ID_CONFIG ) && !k .equals (ConsumerConfig .GROUP_ID_CONFIG )) {
145- modifiedConfigs .put ((String ) k , v );
146- }
147- });
148- }
149- return createKafkaConsumer (modifiedConfigs );
133+ return createConsumerWithAdjustedProperties (groupId , clientIdPrefix , properties , overrideClientIdPrefix ,
134+ clientIdSuffix , shouldModifyClientId );
150135 }
151136 }
152137
138+ private KafkaConsumer <K , V > createConsumerWithAdjustedProperties (String groupId , String clientIdPrefix ,
139+ Properties properties , boolean overrideClientIdPrefix , String clientIdSuffix ,
140+ boolean shouldModifyClientId ) {
141+
142+ Map <String , Object > modifiedConfigs = new HashMap <>(this .configs );
143+ if (groupId != null ) {
144+ modifiedConfigs .put (ConsumerConfig .GROUP_ID_CONFIG , groupId );
145+ }
146+ if (shouldModifyClientId ) {
147+ modifiedConfigs .put (ConsumerConfig .CLIENT_ID_CONFIG ,
148+ (overrideClientIdPrefix ? clientIdPrefix
149+ : modifiedConfigs .get (ConsumerConfig .CLIENT_ID_CONFIG )) + clientIdSuffix );
150+ }
151+ if (properties != null ) {
152+ properties .forEach ((k , v ) -> {
153+ if (!k .equals (ConsumerConfig .CLIENT_ID_CONFIG ) && !k .equals (ConsumerConfig .GROUP_ID_CONFIG )) {
154+ modifiedConfigs .put ((String ) k , v );
155+ }
156+ });
157+ }
158+ return createKafkaConsumer (modifiedConfigs );
159+ }
160+
153161 protected KafkaConsumer <K , V > createKafkaConsumer (Map <String , Object > configs ) {
154162 return new KafkaConsumer <>(configs , this .keyDeserializer , this .valueDeserializer );
155163 }
0 commit comments