Merge branch '2.7.x'

Closes gh-33753
pull/33770/merge
Moritz Halbritter 2 years ago
commit 46f09be1c0

@ -1127,17 +1127,20 @@ public class RabbitProperties {
}
private String parseUsernameAndPassword(String input) {
if (input.contains("@")) {
String[] split = StringUtils.split(input, "@");
String creds = split[0];
input = split[1];
split = StringUtils.split(creds, ":");
this.username = split[0];
if (split.length > 0) {
this.password = split[1];
}
String[] splitInput = StringUtils.split(input, "@");
if (splitInput == null) {
return input;
}
return input;
String credentials = splitInput[0];
String[] splitCredentials = StringUtils.split(credentials, ":");
if (splitCredentials == null) {
this.username = credentials;
}
else {
this.username = splitCredentials[0];
this.password = splitCredentials[1];
}
return splitInput[1];
}
private String parseVirtualHost(String input) {

@ -331,4 +331,11 @@ class RabbitPropertiesTests {
assertThat(container).hasFieldOrPropertyWithValue("deBatchingEnabled", direct.isDeBatchingEnabled());
}
@Test
void determineUsernameWithoutPassword() {
this.properties.setAddresses("user@rabbit1.example.com:1234/alpha");
assertThat(this.properties.determineUsername()).isEqualTo("user");
assertThat(this.properties.determinePassword()).isEqualTo("guest");
}
}

Loading…
Cancel
Save