Align instanceId calculation with the one done on the client
The Angel client has an idiosyncratic way of calculating an instance id, and the Brixton client aligned with that already, but the Brixton server did not. This change should make Brixton Eureka Servers work with Angel clients. See gh-978
This commit is contained in:
@@ -123,12 +123,21 @@ public class CloudJacksonJson extends LegacyJacksonJson {
|
||||
SerializerProvider provider) throws IOException {
|
||||
|
||||
if (info.getInstanceId() == null && info.getMetadata() != null) {
|
||||
String instanceId = info.getMetadata().get("instanceId");
|
||||
String instanceId = calculateInstanceId(info);
|
||||
info = new InstanceInfo.Builder(info).setInstanceId(instanceId).build();
|
||||
}
|
||||
|
||||
super.serialize(info, jgen, provider);
|
||||
}
|
||||
|
||||
private String calculateInstanceId(InstanceInfo info) {
|
||||
String instanceId = info.getMetadata().get("instanceId");
|
||||
String hostName = info.getHostName();
|
||||
if (instanceId != null && !instanceId.startsWith(hostName)) {
|
||||
instanceId = hostName + ":" + instanceId;
|
||||
}
|
||||
return instanceId == null ? hostName : instanceId;
|
||||
}
|
||||
}
|
||||
|
||||
static class CloudInstanceInfoDeserializer extends InstanceInfoDeserializer {
|
||||
|
||||
Reference in New Issue
Block a user