This is my code:
return repository.findFirstByFxDateAndTransCurrAndCrdhldBillCurr(
LocalDate.parse(request.getDate()), request.getTransactionCurrency(), request.getBillingCurrency())
.orElse(getCurrencyExchangeRateFromApi(request));
it not work, but I update .orElse to .orElseGet
return repository.findFirstByFxDateAndTransCurrAndCrdhldBillCurr(
LocalDate.parse(request.getDate()), request.getTransactionCurrency(), request.getBillingCurrency())
.orElseGet(() -> getCurrencyExchangeRateFromApi(request));
It's work perfectly, I don't know the reason, is that bug of java8 ?
I try to run again many times, nothing change, but I try to write an small example, optional of String instead of from repository, it's ok too.