Skip to content

Commit 41ed4d6

Browse files
onobcmhalbritter
authored andcommitted
Remove use of Pulsar ObjectMapperFactory
This commit removes the use of the Pulsar ObjectMapperFactory when converting the authentication config props map to a JSON string. The Pulsar factory operates on a shaded returned value of Jackson ObjectMapper which may not exist when users are using the non-shaded version of the Pulsar client lib. See spring-projects/spring-pulsar#562 See gh-39389
1 parent 976152b commit 41ed4d6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
import java.util.concurrent.TimeUnit;
2424
import java.util.function.BiConsumer;
2525
import java.util.function.Consumer;
26+
import java.util.stream.Collectors;
2627

2728
import org.apache.pulsar.client.admin.PulsarAdminBuilder;
2829
import org.apache.pulsar.client.api.ClientBuilder;
2930
import org.apache.pulsar.client.api.ConsumerBuilder;
3031
import org.apache.pulsar.client.api.ProducerBuilder;
3132
import org.apache.pulsar.client.api.PulsarClientException.UnsupportedAuthenticationException;
3233
import org.apache.pulsar.client.api.ReaderBuilder;
33-
import org.apache.pulsar.common.util.ObjectMapperFactory;
3434

3535
import org.springframework.boot.context.properties.PropertyMapper;
3636
import org.springframework.pulsar.listener.PulsarContainerProperties;
@@ -87,7 +87,10 @@ private void customizeAuthentication(AuthenticationConsumer authentication,
8787
private String getAuthenticationParamsJson(Map<String, String> params) {
8888
Map<String, String> sortedParams = new TreeMap<>(params);
8989
try {
90-
return ObjectMapperFactory.create().writeValueAsString(sortedParams);
90+
return sortedParams.entrySet()
91+
.stream()
92+
.map((e) -> "\"%s\":\"%s\"".formatted(e.getKey(), e.getValue()))
93+
.collect(Collectors.joining(",", "{", "}"));
9194
}
9295
catch (Exception ex) {
9396
throw new IllegalStateException("Could not convert auth parameters to encoded string", ex);

0 commit comments

Comments
 (0)