Skip to content

Commit

Permalink
PAGOPA-2442 using old cache version in memory when failing
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoRuzzier committed Dec 2, 2024
1 parent 36cea97 commit 15a24bb
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ public void refreshCache() {
it.gov.pagopa.gen.wispconverter.client.cache.api.CacheApi apiInstance = new it.gov.pagopa.gen.wispconverter.client.cache.api.CacheApi(configCacheClient);
if (configData == null) {
configData = apiInstance.cache(false);
log.debug("loadCache from cache api...done");
log.debug("loadCache from cache api...done. Version: %s", configData.getVersion());
} else {
CacheVersionDto id = apiInstance.idV1();
if (!configData.getVersion().equals(id)) {
if (!configData.getVersion().equals(id.getVersion())) {
configData = apiInstance.cache(false);
log.debug("loadCache from cache api...done");
log.debug("loadCache from cache api...done. Version: %s", configData.getVersion());
}
}

} catch (RestClientException e) {
throw new AppException(AppErrorCodeMessageEnum.CLIENT_APICONFIGCACHE,
String.format("RestClientException ERROR [%s] - %s", e.getCause().getClass().getCanonicalName(), e.getMessage()));
if (configData != null) {
log.debug("loadCache from cache api failed, using old version. Version: %s", configData.getVersion());
} else {
throw new AppException(AppErrorCodeMessageEnum.CLIENT_APICONFIGCACHE,
String.format("RestClientException ERROR [%s] - %s", e.getCause().getClass().getCanonicalName(), e.getMessage()));
}
}
}

Expand Down

0 comments on commit 15a24bb

Please sign in to comment.