Missing property (BadRequest) for Groovy template expansion

2.4k Views Asked by At

I'm using Resilience4j and I need to ignore some exceptions when using Retry. One of the exceptions is the: org.springframework.web.reactive.function.client.WebClientResponseException$BadRequest

resilience4j.retry:
  instances:
    testA:
      maxAttempts: 5
      waitDuration: 100ms
      ignoreExceptions:
        - org.springframework.web.reactive.function.client.WebClientResponseException$BadRequest
        - java.net.ConnectException
        - java.lang.ArithmeticException

But I am not able to run the application because of the character $, the error occurs:

Missing property (BadRequest) for Groovy template expansion. Defined keys [parent, inspectClassesForKotlinIC, projects ...

How can I use/escape this character inside application.yml file? The exception I need to ignore is the Bad Request, its full name contains the $. If I remove the $ character the application runs normally, but I can't remove it because it's part of the exception's full name.

2

There are 2 best solutions below

1
Adriano On BEST ANSWER

I used what @injecteer suggested and it worked:

try escaping the symbol: $

0
Dario Seidl On

As mentioned in the comment, the dollar sign can be escaped with a backslash.

The Spring Boot docs explain why the error happens in the first place, in the note below:

You can automatically expand properties from the Gradle project by configuring the Java plugin’s processResources task to do so, as shown in the following example:

tasks.named('processResources') {
    expand(project.properties)
}

You can then refer to your Gradle project’s properties by using placeholders, as shown in the following example:

app.name=${name} app.description=${description}

Note: Gradle’s expand method uses Groovy’s SimpleTemplateEngine, which transforms ${..} tokens. The ${..} style conflicts with Spring’s own property placeholder mechanism. To use Spring property placeholders together with automatic expansion, escape the Spring property placeholders as follows: ${..}.

Source

This also applies to the dollar sign used in nested class names, as in OP's case: WebClientResponseException$BadRequest.