Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f960da

Browse files
authored
Merge pull request Netflix#1155 from mgtriffid/eureka-1154
EUREKA-1154 Return 404 if instance is not found when updating metadata
2 parents 41bc0a1 + a760664 commit 0f960da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

eureka-core/src/main/java/com/netflix/eureka/resources/InstanceResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public Response renewLease(
118118
}
119119
// Check if we need to sync based on dirty time stamp, the client
120120
// instance might have changed some value
121-
Response response = null;
121+
Response response;
122122
if (lastDirtyTimestamp != null && serverConfig.shouldSyncWhenTimestampDiffers()) {
123123
response = this.validateDirtyTimestamp(Long.valueOf(lastDirtyTimestamp), isFromReplicaNode);
124124
// Store the overridden status since the validation found out the node that replicates wins
@@ -239,15 +239,15 @@ public Response updateMetadata(@Context UriInfo uriInfo) {
239239
InstanceInfo instanceInfo = registry.getInstanceByAppAndId(app.getName(), id);
240240
// ReplicationInstance information is not found, generate an error
241241
if (instanceInfo == null) {
242-
logger.error("Cannot find instance while updating metadata for instance {}", id);
243-
return Response.serverError().build();
242+
logger.warn("Cannot find instance while updating metadata for instance {}/{}", app.getName(), id);
243+
return Response.status(Status.NOT_FOUND).build();
244244
}
245245
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
246246
Set<Entry<String, List<String>>> entrySet = queryParams.entrySet();
247247
Map<String, String> metadataMap = instanceInfo.getMetadata();
248248
// Metadata map is empty - create a new map
249249
if (Collections.emptyMap().getClass().equals(metadataMap.getClass())) {
250-
metadataMap = new ConcurrentHashMap<String, String>();
250+
metadataMap = new ConcurrentHashMap<>();
251251
InstanceInfo.Builder builder = new InstanceInfo.Builder(instanceInfo);
252252
builder.setMetadata(metadataMap);
253253
instanceInfo = builder.build();

0 commit comments

Comments
 (0)