1

I'm using Spring boot (1.5.6.RELEASE) to supply a default property if none is set elsewhere. However, instead of the expected result, I get a leftover curly bracket "}" in the result.

I've created a github test case which reproduces it. See:

https://github.com/garethrandall/spring-boot-property-failure

In rabbitmq-context.xml, this line has a default value for the addresses property:

<rabbit:connection-factory id="rabbitmqConnectionFactory" addresses="${rabbit.host:localhost}:5672"/>

Expected result: addresses property ends up as:

"localhost:5672"

Actual result: addresses ends up as this:

"localhost}:5672"

which then causes a parse error later in Spring.

Exception message is:

 Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'addresses' threw exception; nested exception is java.lang.NumberFormatException: For input string: "localhost}:5672"
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1564)
    ... 37 more

Has anyone seen this before? There is a Spring Boot 2.0.0 but it's not a stable release yet, so I'm keen to fix this on 1.5.6.RELEASE.

[This is different from another question because the answer to that question does NOT work (surround default with single quotes).]

Gareth Randall
  • 153
  • 1
  • 6
  • The problem is the 2 `:` and it isn't Spring Boot that is replacing the placeholder as this is being done by the namespace itself. But if you are using Spring Boot wy not use the rabbit auto config? – M. Deinum Aug 31 '17 at 14:19
  • Possible duplicate of [Spring @Value escape colon(:) in default value](https://stackoverflow.com/questions/31711308/spring-value-escape-colon-in-default-value) – Andy Brown Aug 31 '17 at 15:12
  • 1
    Who uses Spring XML anymore? – Abhijit Sarkar Aug 31 '17 at 15:19

0 Answers0