Support IPv6 addresses in spring.rabbitmq.addresses

Refine parsing logic in `RabbitProperties` so that IPv6 addresses can
be used.

Fixes gh-28133
This commit is contained in:
Phillip Webb
2021-09-26 13:04:13 -07:00
parent 5957dfeea4
commit 01a39aaf6a
2 changed files with 10 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1083,7 +1083,7 @@ public class RabbitProperties {
}
private void parseHostAndPort(String input, boolean sslEnabled) {
int portIndex = input.indexOf(':');
int portIndex = input.lastIndexOf(':');
if (portIndex == -1) {
this.host = input;
this.port = (determineSslEnabled(sslEnabled)) ? DEFAULT_PORT_SECURE : DEFAULT_PORT;