diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheService.java index 4f742bd666..604e422bd5 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheService.java @@ -59,18 +59,21 @@ public EndpointDataReferenceStatus getEndpointDataReference(final String assetId final Optional endpointDataReferenceOptional = retrieveEndpointEndpointReferenceByAssetId( assetId); - if (endpointDataReferenceOptional.isPresent() && endpointDataReferenceOptional.get().getAuthCode() != null) { - final EndpointDataReference endpointDataReference = endpointDataReferenceOptional.get(); - if (isTokenExpired(endpointDataReferenceOptional.get().getAuthCode())) { - log.info("Endpoint data reference with expired token and id: {} for assetId: {} found in storage.", - endpointDataReference.getId(), assetId); - return new EndpointDataReferenceStatus(endpointDataReference, - EndpointDataReferenceStatus.TokenStatus.EXPIRED); - } else { - log.info("Endpoint data reference with id: {} for assetId: {} found in storage.", - endpointDataReference.getId(), assetId); - return new EndpointDataReferenceStatus(endpointDataReference, - EndpointDataReferenceStatus.TokenStatus.VALID); + if (endpointDataReferenceOptional.isPresent()) { + final String authCode = endpointDataReferenceOptional.get().getAuthCode(); + if (authCode != null) { + final EndpointDataReference endpointDataReference = endpointDataReferenceOptional.get(); + if (isTokenExpired(authCode)) { + log.info("Endpoint data reference with expired token and id: {} for assetId: {} found in storage.", + endpointDataReference.getId(), assetId); + return new EndpointDataReferenceStatus(endpointDataReference, + EndpointDataReferenceStatus.TokenStatus.EXPIRED); + } else { + log.info("Endpoint data reference with id: {} for assetId: {} found in storage.", + endpointDataReference.getId(), assetId); + return new EndpointDataReferenceStatus(endpointDataReference, + EndpointDataReferenceStatus.TokenStatus.VALID); + } } }