0
votes

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?

Hello, can you give us the exception that occurs in native mode ? - loicmathieu
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
OK, this seems like a bug, can you open on issue in the Quarkus Github repo github.com/quarkusio/quarkus/issues ideally with a reproducer ? - loicmathieu
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