Failed to parse ipv6 addresses due to assumption of ipv4 addresses.

I think the regression was introduced in https://github.com/spring-projects/spring-boot/issues/34657

Comment From: pivotal-cla

@jonasfugedi Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@jonasfugedi Thank you for signing the Contributor License Agreement!

Comment From: scottfrederick

@jonasfugedi Thanks very much for your first contribution to Spring Boot. I've merged it along with a polishing commit for style and a small bit of additional testing.

Comment From: mjustin

public List<Address> getAddresses() { List<Address> addresses = new ArrayList<>(); for (String address : this.properties.determineAddresses().split(",")) { int portSeparatorIndex = address.lastIndexOf(':'); String host = address.substring(0, portSeparatorIndex); String port = address.substring(portSeparatorIndex + 1); addresses.add(new Address(host, Integer.parseInt(port))); } return addresses; }

Is it possible for an IPv6 address to be specified without a port (i.e. use the default port)? Wouldn't this code fail in that scenario, since it'd split on a colon that's part of the IP address, and not related to the port?

Comment From: jonasfugedi

public List<Address> getAddresses() { List<Address> addresses = new ArrayList<>(); for (String address : this.properties.determineAddresses().split(",")) { int portSeparatorIndex = address.lastIndexOf(':'); String host = address.substring(0, portSeparatorIndex); String port = address.substring(portSeparatorIndex + 1); addresses.add(new Address(host, Integer.parseInt(port))); } return addresses; }

Is it possible for an IPv6 address to be specified without a port (i.e. use the default port)? Wouldn't this code fail in that scenario, since it'd split on a colon that's part of the IP address, and not related to the port?

Not if I read the code correct, the source of the addresses is

https://github.com/jonasfugedi/spring-boot/blob/bebca55a8ffee3b4cd4d099fb6be199655cf8c7d/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java#L207-L225

Which ensures a port is always appended to the host. Previous behavior was retained, i.e. I kept the same assumptions as the code did before except I needed it to work when using ipv6 addresses.