micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.09k stars 1.07k forks source link

@Fallback is not triggered when service return error status #3621

Open pgisslen opened 4 years ago

pgisslen commented 4 years ago

Steps to Reproduce

  1. Declarative Client annotated with @Recoverable
  2. @Fallback client implementing interface of the Client returning OK.
  3. Send request to an endpoint that always return 500

Expected Behaviour

Fallback is triggered and a successful response is returned

Actual Behaviour

Client throws HttpClientResponseException

Environment Information

Example Application

See testFallback()

graemerocher commented 4 years ago

Just to be clear, is this a regression in 2.0 you are seeing or a new issue report?

nchapon commented 4 years ago

I have the same behavior in case of UnkownHostException fallback is never triggered. Example : https://github.com/nchapon/hello-mn/blob/master/src/main/java/hello/mn/domain/FruityServiceFallback.java

Nicolas

graemerocher commented 4 years ago

@nchapon Add @Recoverable(api=FruityService.class) to FruityServiceClient

nchapon commented 4 years ago

@graemerocher Thanks !
Perhaps this should be documented because with @CircuitBreaker, fallback is triggered without using @Recoverable

graemerocher commented 4 years ago

Agreed better docs would be good. PRs are of course welcome