0

Having the following code running on Quarkus:

@Singleton
@RegisterForReflection
public class StoreService {

    private static final Logger LOGGER = Logger.getLogger(StoreService.class);

    @Inject
    @RestClient
    StoresApiClient client;

    @CacheResult(cacheName = "stores")
    @Fallback(fallbackMethod = "allFallbackStores")
    public List<Store> allStores() {
        // call REST API using client
    }

    @SuppressWarnings("unused")
    public List<Store> allFallbackStores() {
        try {
            LOGGER.info("Falling back to internal stores list");
            ...
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

the fallback mechanism is working properly in regular JDK mode. On the other hand in native image mode, @Fallback annotation is not being respected and an exception is thrown after unsuccessful API call. What might be a reason for that if @RegisterForReflection annotation is in place?

Tomek Zaremba
  • 353
  • 1
  • 4
  • 7
  • Hello, can you give us the exception that occurs in native mode ? – loicmathieu Feb 17 '20 at 09:12
  • There is no exception related to `@Fallback` itself. If the `allStores` call ends with any exception the flow is just not redirected to `allFallbackStores` method (in regular JDK mode it works fine and `allFallbackStores` is executed) – Tomek Zaremba Feb 19 '20 at 09:21
  • OK, this seems like a bug, can you open on issue in the Quarkus Github repo https://github.com/quarkusio/quarkus/issues ideally with a reproducer ? – loicmathieu Feb 19 '20 at 09:58
  • I can't reproduce the problem using `Quarkus 1.2.1.Final`, maybe it was fixed already in this release. Thanks for your time @loicmathieu – Tomek Zaremba Feb 20 '20 at 06:39

0 Answers0