Skip to content

Commit

Permalink
feat(irs-apiirs-edc-client):[#256] fix for potential null pointer exc…
Browse files Browse the repository at this point in the history
…eptions
  • Loading branch information
ds-psosnowski committed Dec 4, 2023
1 parent bf1f6b7 commit 645ee4f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public NegotiationResponse negotiate(final String providerConnectorUrl, final Ca
}
case EXPIRED -> {
contractAgreementId = EDRAuthCode.fromAuthCodeToken(
endpointDataReferenceStatus.endpointDataReference().getAuthKey()).getCid();
Objects.requireNonNull(endpointDataReferenceStatus.endpointDataReference().getAuthKey())).getCid();
log.info(
"Cached endpoint data reference has expired token. Refreshing token without new contract negotiation for contractAgreementId: {}",
contractAgreementId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.eclipse.tractusx.irs.edc.client.util;

import java.time.Instant;
import java.util.Objects;
import java.util.Optional;

import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -78,7 +79,7 @@ private Optional<EndpointDataReference> retrieveEndpointEndpointReferenceByAsset
}

private static boolean isTokenExpired(final EndpointDataReference endpointDataReference) {
final Instant tokenExpirationInstant = extractTokenExpiration(endpointDataReference.getAuthCode());
final Instant tokenExpirationInstant = extractTokenExpiration(Objects.requireNonNull(endpointDataReference.getAuthCode()));
return Instant.now().isAfter(tokenExpirationInstant);
}

Expand Down

0 comments on commit 645ee4f

Please sign in to comment.