ProducerConstructorMapInterceptor implements InstanceConstructorInterceptor { @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { Map<String, Object> config = (Map<String, Object>) allArguments[0]; if (objInst.getSkyWalkingDynamicField() == null) { Object bootstrapServers = config.get("bootstrap.servers"); if (bootstrapServers instanceof List) { objInst.setSkyWalkingDynamicField(String.join(";", (List<String>) bootstrapServers)); } else { objInst.setSkyWalkingDynamicField(StringUtil.join(';', COMMA_WITH_WHITESPACE.split((String) bootstrapServers, -1))); } } }  @Override void onConstruct(EnhancedInstance objInst, Object[] allArguments);  }
@Test public void givenListTypeBootstrapServers_whenConstructProducer_thenServersSaves() { constructorMapInterceptor.onConstruct(enhancedInstance, new Object[]{PRODUCER_CONFIG_WITH_LIST_BOOTSTRAP_SERVERS}); assertThat(enhancedInstance.getSkyWalkingDynamicField().toString(), is("localhost:9092;localhost:19092")); }
@Test public void givenStringTypeBootstrapServers_whenConstructProducer_thenServersSaves() { constructorMapInterceptor.onConstruct(enhancedInstance, new Object[]{PRODUCER_CONFIG_WITH_STRING_BOOTSTRAP_SERVERS}); assertThat(enhancedInstance.getSkyWalkingDynamicField().toString(), is("localhost:9092;localhost:19092")); }