Skip to content

Commit

Permalink
Remove code style changed
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudh9391 committed May 9, 2024
1 parent e6099b8 commit e7174a1
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,22 @@ public URI get(String accessKey, EndpointDiscoveryRequest request) {
if (endpoint == null) {
if (request.required()) {
return cache.computeIfAbsent(key, k -> getAndJoin(request)).endpoint();
}
EndpointDiscoveryEndpoint tempEndpoint = EndpointDiscoveryEndpoint.builder()
.endpoint(request.defaultEndpoint())
.expirationTime(Instant.now().plusSeconds(60))
.build();

EndpointDiscoveryEndpoint previousValue = cache.putIfAbsent(key, tempEndpoint);
if (previousValue != null) {
// Someone else primed the cache. Use that endpoint (which may be temporary).
return previousValue.endpoint();
} else {
// We primed the cache with the temporary endpoint. Kick off discovery in the background.
refreshCacheAsync(request, key);
EndpointDiscoveryEndpoint tempEndpoint = EndpointDiscoveryEndpoint.builder()
.endpoint(request.defaultEndpoint())
.expirationTime(Instant.now().plusSeconds(60))
.build();

EndpointDiscoveryEndpoint previousValue = cache.putIfAbsent(key, tempEndpoint);
if (previousValue != null) {
// Someone else primed the cache. Use that endpoint (which may be temporary).
return previousValue.endpoint();
} else {
// We primed the cache with the temporary endpoint. Kick off discovery in the background.
refreshCacheAsync(request, key);
}
return tempEndpoint.endpoint();
}
return tempEndpoint.endpoint();
}

if (endpoint.expirationTime().isBefore(Instant.now())) {
Expand Down

0 comments on commit e7174a1

Please sign in to comment.