Aias00 opened a new issue, #7439:
URL: https://github.com/apache/shenyu/issues/7439

   ## Is there an existing issue for this?
   
   - [x] I searched existing open and closed issues.
   
   ## Current Behavior
   
   The Eureka watcher checks whether an instance has changed using the 
following predicate:
   
   ```java
   currentInstance.getInstanceId().equals(previousInstance.getInstanceId())
       && !currentInstance.equals(previousInstance)
   ```
   
   Netflix Eureka `InstanceInfo.equals()` compares identity rather than all 
instance properties. For an instance retaining its identity, changes to 
upstream-relevant data do not satisfy the update predicate. The 
addition/deletion checks also see the instance as unchanged, so no event is 
emitted.
   
   ## Expected Behavior
   
   A stable instance identity with changed upstream information should emit 
`ChangedEventListener.Event.UPDATED` and refresh the gateway's upstream data.
   
   ## Steps To Reproduce
   
   1. Create two real Eureka `InstanceInfo` snapshots with the same explicit 
instance ID, application, address and port.
   2. Set the old snapshot's `metadata.weight` to `10` and the new snapshot's 
weight to `20`.
   3. Compare the snapshots through 
`EurekaInstanceRegisterRepository.compareInstances()`.
   4. Observe that no `UPDATED` event is delivered although 
`buildUpstreamJsonFromInstance()` would generate different weight data.
   
   Use real `InstanceInfo` objects in the regression so the dependency's 
identity-based equality is exercised; a plain Mockito mock uses different 
equality semantics.
   
   ## Environment
   
   ShenYu `2.7.2-SNAPSHOT`, `master` at 
`67596c1d228b62da75cd0a0ecb47d0ac5d995384`, Eureka instance discovery.
   
   ## Location And Impact
   
   - 
[EurekaInstanceRegisterRepository.java:215](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-registry/shenyu-registry-eureka/src/main/java/org/apache/shenyu/registry/eureka/EurekaInstanceRegisterRepository.java#L215):
 update detection uses identity equality.
   - 
[EurekaInstanceRegisterRepository.java:224](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-registry/shenyu-registry-eureka/src/main/java/org/apache/shenyu/registry/eureka/EurekaInstanceRegisterRepository.java#L224):
 upstream representation consumes mutable instance fields.
   
   Severity: Medium. Confidence: high. In-place changes to weight, protocol, 
props and other upstream fields can leave ShenYu discovery data stale despite 
successful ongoing polling. This report does not assume every Eureka status 
change remains present in the upstream fetch result.
   
   ## Suggested Fix And Regression Coverage
   
   Match snapshots by stable identity, then compare the upstream-relevant 
fields or their generated upstream representation. Preserve distinct ADDED and 
DELETED handling. Test same-ID weight/protocol/props changes using real 
dependency objects and assert an `UPDATED` event with the new payload.
   
   ## Validation And Related Issues
   
   Existing Eureka module tests passed 3 tests with zero failures, but do not 
cover real same-ID mutable-field comparison. No live Eureka cluster was started.
   
   Independent verification inspected the actual Eureka `2.0.2` dependency 
source and reproduced identity equality with two real `InstanceInfo` snapshots 
having the same ID but different metadata/status: equality remains true and 
hashes match.
   
   #6500/#7429 address keeping the polling task alive after errors. #6904 
concerns namespace filtering. This is the separate update-detection predicate 
used by otherwise successful polls.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to