Skip to content
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

Suport new Spring Boot 3 autoconfiguration imports file #1766

Closed
spencergibb opened this issue Sep 22, 2022 · 27 comments
Closed

Suport new Spring Boot 3 autoconfiguration imports file #1766

spencergibb opened this issue Sep 22, 2022 · 27 comments
Milestone

Comments

@spencergibb
Copy link

Spring Boot 2.7 added a new mechanism to specify auto-configuration. See spring-projects/spring-boot#29698

Spring Boot 3 removed the ability to load auto-configuration via spring.factories spring-projects/spring-boot#29699

https://github.com/spring-cloud/spring-cloud-circuitbreaker will add these temporarily until support is added here.

/cc @ryanjbaxter

spencergibb added a commit to spring-cloud/spring-cloud-circuitbreaker that referenced this issue Sep 22, 2022
@RobWin RobWin added this to the 2.0.0 milestone Sep 23, 2022
@RobWin RobWin closed this as completed Nov 21, 2022
@magnus-larsson
Copy link

Is this issue fixed in Resilience4J 2.0.0?

I tried using Spring Boot 3.0.0 with Resilience4J 2.0.0 in the project git@github.com:resilience4j/resilience4j-spring-boot2-demo.git.

I simply upgraded Spring Boot to 3.0.0 in the file build.gradle.kts and then run the command: ./gradlew clean build

It resulted in all tests failing on missing bean exceptions.

After adding a file described above, e.g. https://github.com/spring-cloud/spring-cloud-circuitbreaker/blob/main/spring-cloud-circuitbreaker-resilience4j/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports, all tests, and the build run ok.

@RobWin
Copy link
Member

RobWin commented Nov 25, 2022

aah
I missed this detail :(
The file must be in a spring folder?
Damn.

@magnus-larsson
Copy link

Yes, it has to.

@RobWin RobWin reopened this Nov 28, 2022
@RobWin
Copy link
Member

RobWin commented Nov 28, 2022

I added a new resilience4j-spring-boot3 module.
You can try 2.0.1-SNAPSHOT if it works for you.
I also created a new repo resilience4j-spring-boot3-demo.

@RobWin RobWin modified the milestones: 2.0.0, 2.0.1 Nov 28, 2022
@magnus-larsson
Copy link

Great, thanks!

I tried out the new resilience4j-spring-boot3 v2.0.1-SNAPSHOT - module, and it worked fine!

I'll try out the resilience4j-spring-boot3-demo - project as soon as I can find some time. I'll report issues, if any :-)

@RobWin
Copy link
Member

RobWin commented Nov 29, 2022

The module resilience4j-spring-boot3 currently has a new package structure so that code coverage does not argue about duplicate class names because of resilience4j-spring-boot2
@spencergibb Is this important for you in Spring Cloud Circuitbreaker?
Or do you know of a better fix for this? I don't want to split all modules into separate repos.

@ryanjbaxter
Copy link

@RobWin what should we be using instead of Vavr? I see the dependency was removed, but the documentation samples still show it being used.

@RobWin
Copy link
Member

RobWin commented Nov 29, 2022

Do you have a concrete example where you are using Vavr?
We still have resilience4j-vavr to support the decoration of Either, Try, CheckedFunction, ...

In most of the cases Vavr can still be used with some small adjustments.

@ryanjbaxter
Copy link

Similar to this example from the docs

// Given
CircuitBreaker circuitBreaker = CircuitBreaker.ofDefaults("testName");

// When I decorate my function
CheckedFunction0 decoratedSupplier = CircuitBreaker
.decorateCheckedSupplier(circuitBreaker, () -> "This can be any method which returns: 'Hello");

// and chain an other function with map
Try result = Try.of(decoratedSupplier)
.map(value -> value + " world'");

// Then the Try Monad returns a Success, if all functions ran successfully.
assertThat(result.isSuccess()).isTrue();
assertThat(result.get()).isEqualTo("This can be any method which returns: 'Hello world'");

@RobWin
Copy link
Member

RobWin commented Nov 29, 2022

Yes thanks. I need to fix the docs.
Here we have a non-backwards compatible change, because of the removal of Vavr.

Together with Vavr, it would look like this now.

CheckedSupplier is not backwards-compatible:

 // When I decorate my function
CheckedSupplier<String> decoratedSupplier = CircuitBreaker
    .decorateCheckedSupplier(circuitBreaker, () -> "This can be any method which returns: 'Hello");

// and chain an other function with map
Try<String> result = Try.of(decoratedSupplier::get)
    .map(value -> value + " world'");

Supplier is backwards-compatible:

Supplier<String> decoratedSupplier = CircuitBreaker
    .decorateSupplier(circuitBreaker, () -> "This can be any method which returns: 'Hello");

// and chain an other function with map
Try<String> result = Try.ofSupplier(decoratedSupplier)
    .map(value -> value + " world'");
Supplier<String> checkedSupplier =
  CircuitBreaker.decorateSupplier(circuitBreaker, () -> {
    throw new RuntimeException("BAM!");
  });
Try<String> result = Try.ofSupplier(checkedSupplier)
  .recover(throwable -> "Hello Recovery");

But of course a simple try/catch would also work :D

@ryanjbaxter
Copy link

But doesn't that imply we now need to include the Vavr dependency ourselves?

@RobWin
Copy link
Member

RobWin commented Nov 29, 2022

Yes, if you still want to make use of Vavr features.
Is Vavr part of the API of the Spring Cloud CircuitBreaker?

@ryanjbaxter
Copy link

No we were just using it because it was inherited through Resilience4J

@ryanjbaxter
Copy link

Correct, there are are a couple of other places as well, but they are all similar

@RobWin
Copy link
Member

RobWin commented Nov 29, 2022

I think I would drop Vavr in Cloud Circuitbreaker 3.x and replace it by a try/catch.

@ryanjbaxter
Copy link

OK thats simple enough.

FYI we won't be able to upgrade to 2.0.0 because of this
#1825

Can you point me to the snapshots repo so I can try 2.0.1?

@RobWin
Copy link
Member

RobWin commented Nov 29, 2022

Yes, I plan to release 2.0.1 as soon as the next PR is merged.
The PR provides a new feature to modify even shareable circuitbreaker configs with Customizer Beans.
Maybe it should be a 2.1.0

Repo is: https://oss.sonatype.org/content/repositories/snapshots

@ryanjbaxter
Copy link

OK I can confirm 2.0.1-SNAPSHOT works. We plan on doing our GA release of Spring Cloud CircuitBreaker based on Spring Boot 3.0.0 on December 14th. It would be great is we could have the next Resilience4J release included in that.

@RobWin
Copy link
Member

RobWin commented Nov 29, 2022

Should be possible :)

@ryanjbaxter
Copy link

Awesome! Thanks for the help! Just tag me when the new release is available.

@ryanjbaxter
Copy link

FYI might want to update docs here on snapshots https://resilience4j.readme.io/docs/gradle

@RobWin RobWin closed this as completed Dec 5, 2022
@RobWin
Copy link
Member

RobWin commented Dec 5, 2022

2.0.1 is released
@ryanjbaxter

@ryanjbaxter
Copy link

Thanks! I just pushed the changes to Spring Cloud CircuitBreaker!

@RobWin
Copy link
Member

RobWin commented Dec 9, 2022

@ryanjbaxter I have to release a 2.0.2 version, because of a bug :/

@ryanjbaxter
Copy link

Thanks, I have upgraded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants