mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '3.2.x'
Closes gh-40869
This commit is contained in:
commit
3858a33162
@ -137,7 +137,7 @@ final class PulsarPropertiesMapper {
|
|||||||
try {
|
try {
|
||||||
return sortedParams.entrySet()
|
return sortedParams.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
.map((entry) -> "\"%s\":\"%s\"".formatted(entry.getKey(), entry.getValue()))
|
.map((entry) -> "\"%s\":\"%s\"".formatted(entry.getKey(), escapeJson(entry.getValue())))
|
||||||
.collect(Collectors.joining(",", "{", "}"));
|
.collect(Collectors.joining(",", "{", "}"));
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
@ -145,6 +145,17 @@ final class PulsarPropertiesMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String escapeJson(String raw) {
|
||||||
|
return raw.replace("\\", "\\\\")
|
||||||
|
.replace("\"", "\\\"")
|
||||||
|
.replace("/", "\\/")
|
||||||
|
.replace("\b", "\\b")
|
||||||
|
.replace("\t", "\\t")
|
||||||
|
.replace("\n", "\\n")
|
||||||
|
.replace("\f", "\\f")
|
||||||
|
.replace("\r", "\\r");
|
||||||
|
}
|
||||||
|
|
||||||
<T> void customizeProducerBuilder(ProducerBuilder<T> producerBuilder) {
|
<T> void customizeProducerBuilder(ProducerBuilder<T> producerBuilder) {
|
||||||
PulsarProperties.Producer properties = this.properties.getProducer();
|
PulsarProperties.Producer properties = this.properties.getProducer();
|
||||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||||
|
@ -81,8 +81,10 @@ class PulsarPropertiesMapperTests {
|
|||||||
@Test
|
@Test
|
||||||
void customizeClientBuilderWhenHasAuthentication() throws UnsupportedAuthenticationException {
|
void customizeClientBuilderWhenHasAuthentication() throws UnsupportedAuthenticationException {
|
||||||
PulsarProperties properties = new PulsarProperties();
|
PulsarProperties properties = new PulsarProperties();
|
||||||
Map<String, String> params = Map.of("param", "name");
|
Map<String, String> params = Map.of("simpleParam", "foo", "complexParam",
|
||||||
String authParamString = "{\"param\":\"name\"}";
|
"{\n\t\"k1\" : \"v1\",\n\t\"k2\":\"v2\"\n}");
|
||||||
|
String authParamString = "{\"complexParam\":\"{\\n\\t\\\"k1\\\" : \\\"v1\\\",\\n\\t\\\"k2\\\":\\\"v2\\\"\\n}\""
|
||||||
|
+ ",\"simpleParam\":\"foo\"}";
|
||||||
properties.getClient().getAuthentication().setPluginClassName("myclass");
|
properties.getClient().getAuthentication().setPluginClassName("myclass");
|
||||||
properties.getClient().getAuthentication().setParam(params);
|
properties.getClient().getAuthentication().setParam(params);
|
||||||
ClientBuilder builder = mock(ClientBuilder.class);
|
ClientBuilder builder = mock(ClientBuilder.class);
|
||||||
@ -166,8 +168,10 @@ class PulsarPropertiesMapperTests {
|
|||||||
@Test
|
@Test
|
||||||
void customizeAdminBuilderWhenHasAuthentication() throws UnsupportedAuthenticationException {
|
void customizeAdminBuilderWhenHasAuthentication() throws UnsupportedAuthenticationException {
|
||||||
PulsarProperties properties = new PulsarProperties();
|
PulsarProperties properties = new PulsarProperties();
|
||||||
Map<String, String> params = Map.of("param", "name");
|
Map<String, String> params = Map.of("simpleParam", "foo", "complexParam",
|
||||||
String authParamString = "{\"param\":\"name\"}";
|
"{\n\t\"k1\" : \"v1\",\n\t\"k2\":\"v2\"\n}");
|
||||||
|
String authParamString = "{\"complexParam\":\"{\\n\\t\\\"k1\\\" : \\\"v1\\\",\\n\\t\\\"k2\\\":\\\"v2\\\"\\n}\""
|
||||||
|
+ ",\"simpleParam\":\"foo\"}";
|
||||||
properties.getAdmin().getAuthentication().setPluginClassName("myclass");
|
properties.getAdmin().getAuthentication().setPluginClassName("myclass");
|
||||||
properties.getAdmin().getAuthentication().setParam(params);
|
properties.getAdmin().getAuthentication().setParam(params);
|
||||||
PulsarAdminBuilder builder = mock(PulsarAdminBuilder.class);
|
PulsarAdminBuilder builder = mock(PulsarAdminBuilder.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user