Skip to content

NumberFormatException when configuring spring.rabbitmq.addresses with an IPv6 address #28133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bantu opened this issue Sep 26, 2021 · 6 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@bantu
Copy link

bantu commented Sep 26, 2021

This yaml works

spring:
  rabbitmq:
    host: "[aaaa:bbbb:cccc::d]"
    port: 5672
    username: foo
    password: "bar

but this yaml

spring:
  rabbitmq:
    addresses: "amqp://foo:bar@[aaaa:bbbb:cccc::d]:5672"

fails with

Failed to bind properties under 'spring.rabbitmq' to org.springframework.boot.autoconfigure.amqp.RabbitProperties:
    Property: spring.rabbitmq.addresses
    Value: amqp://foo:bar@[aaaa:bbbb:cccc::d]:5672
    Origin: REDACTED
    Reason: java.lang.NumberFormatException: For input string: "bbbb:cccc::d]:5672"
@bantu
Copy link
Author

bantu commented Sep 26, 2021

This issue is somewhat similar to #6401 which concerns amqps in spring.rabbitmq.addresses.

@bantu
Copy link
Author

bantu commented Sep 26, 2021

rabbitmq/rabbitmq-java-client#385 is also similar. Maybe this work can be reused somehow.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 26, 2021
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 26, 2021
@philwebb philwebb self-assigned this Sep 26, 2021
@philwebb philwebb added this to the 2.4.x milestone Sep 26, 2021
@philwebb
Copy link
Member

philwebb commented Sep 26, 2021

That NumberFormatException is from our own parsing logic. I've refined parseHostAndPort so that the last : instead of the first one is used to locate the port number.

@bantu When the next CI build finishes (should be about an hour) could you give the latest SNAPSHOT a try to see if it solves it?

@philwebb philwebb modified the milestones: 2.4.x, 2.4.12 Sep 26, 2021
@bantu
Copy link
Author

bantu commented Sep 28, 2021

@philwebb Thank you for the quick patch. Is there an easy way to use SNAPSHOT by altering my build.gradle?

@snicoll
Copy link
Member

snicoll commented Sep 28, 2021

@bantu generate a sample project on start.spring.io with the Spring Boot version you want to test.

@bantu
Copy link
Author

bantu commented Sep 28, 2021

@snicoll Excellent. Thanks.

@philwebb I can confirm that this works:

spring:
  rabbitmq:
    addresses: "amqp://foo:bar@[aaaa:bbbb:cccc::d]:5672"

as well as

spring:
  rabbitmq:
    addresses: "foo:bar@[aaaa:bbbb:cccc::d]:5672"

but omitting the port like

spring:
  rabbitmq:
    addresses: "foo:bar@[aaaa:bbbb:cccc::d]"

fails with java.lang.NumberFormatException: For input string: "d]". I am not sure whether that is a regression from your patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants