resilience4j: ignoreExceptions spring boot configuration - possible to ignore unknown classes to not fail on startup?

Resilience4j version: 2.2.0 Java version: 17

Hi, this is a general question. We make use of the “ignoreExceptions” property for circuit breakers and our application exception classes underwent a package change. When we deployed the code (with the new package location) but the config with the old location, it failed on startup due to r4j calling out the class is not found (which makes sense).

com.sample.app.SampleException (old) com.sample.app.new.SampleException (new)

We have our app configuration externalized not part of the build, so it’s quite the timing issue trying to match up the code and configuration to ensure things so smooth. We have some ways to mitigate this, but my question is can we “tune” r4j to “ignore” an unknown classname in the “ignoreExceptions” list so it does not fail on startup?

resilience4j:
  circuitbreaker:
      global:
        ignoreExceptions:
          -  com.sample.app.SampleException
          -  com.sample.app.new.SampleException

Many thanks and I hope I was clear on the ask!

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 22 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@cabbonizio Yee, Swagger might be the case because I have developed Swagger2Markup some years ago to document Rest APIs in Asciidoc or Markdown 😃

I completely understand. Please let me know how else I can help.

Thank you for the kind words. The problem is that a fix is not that easy, since it would require a custom Spring Boot Converter. But @charb29 is looking into it.

@cabbonizio, a PR has been opened for the new feature.

@cabbonizio I updated the code, so it should work with global configuration now as well. Please keep me posted.

This is perfect @charb29! Will give it a try

Hi @cabbonizio, I added the feature and believe that it should work for your situation. Could you fork this branch and publish it to your local maven repository to use in your code? It should work.

The tests aren’t fully implemented yet, so when publishing to your local maven repository, use this command: ./gradlew publishToMavenLocal -x test

To use the feature, all you need to do is add the ignoreUnknownExceptions: true field in your configuration.

resilience4j.circuitbreaker:
  configs:
    default:
      ignoreUnknownExceptions: true

It only works for the default configuration at the moment, but I am working on making it work for multiple types.

@cabbonizio I’ll provide updates along the way, but if you’d like to track the progress, I’ll be working out of this branch.

Sounds good, I’ll start working on it. @cabbonizio

@cabbonizio When you get the error on the application startup, does it the output look similar to this? I’m working on replicating the error at the moment.

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'resilience4j.circuitbreaker.configs.default.ignore-exceptions[2]' to java.lang.Class<java.lang.Throwable>:

    Property: resilience4j.circuitbreaker.configs.default.ignore-exceptions[2]
    Value: "com.sample.app.SampleException"
    Origin: class path resource [application.yml] - 22:11
    Reason: failed to convert java.lang.String to java.lang.Class<java.lang.Throwable> (caused by java.lang.ClassNotFoundException: com.sample.app.SampleException)

Action:

Update your application's configuration

Yep @charb29 that’s exactly what happens

@cabbonizio I’m working on replicating the issue at the moment, so I’m not entirely sure yet how we’ll solve this. However, combining the default behaviour with a flag to try and provide the best of both worlds could be a solution.

After speaking with @RobWin though, it’s a priority that the new feature is backwards compatible.

@charb29 many thanks for offering to do this. It will help deal with compatibility issues. Please let me know how else I can help.

@cabbonizio no worries. I’ll keep you updated on the progress.