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) { private String parseUsernameAndPassword(String input) {
if (input.contains("@")) { String[] splitInput = StringUtils.split(input, "@");
String[] split = StringUtils.split(input, "@"); if (splitInput == null) {
String creds = split[0]; return input;
input = split[1];
split = StringUtils.split(creds, ":");
this.username = split[0];
if (split.length > 0) {
this.password = split[1];
}
} }
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) { private String parseVirtualHost(String input) {

@ -331,4 +331,11 @@ class RabbitPropertiesTests {
assertThat(container).hasFieldOrPropertyWithValue("deBatchingEnabled", direct.isDeBatchingEnabled()); 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