wozhenbang2004 opened a new issue, #16567: URL: https://github.com/apache/dubbo/issues/16567
### Pre-check - [x] I am sure that all the content I provide is in English. ### Search before asking - [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues. ### Apache Dubbo Component Java SDK (apache/dubbo) ### Dubbo Version Dubbo 3.3.7-SNAPSHOT, branch 3.3 at 7ca3e29f4b48544b24fdfff6ccb9bc1b81132d44. Reproduced from the current source with Java 17.0.20 on Linux. ### Steps to reproduce this issue 1. Put a mapping into ExpiringMap and make its existing ExpiryObject expired. 2. In another thread, call get(key), or run the background processExpires() pass. Pause after it observes the expired object but before delegateMap.remove(key) takes effect. 3. Put a fresh value under the same key from the first thread. 4. Let the old expiration check continue. 5. Read the key again: it returns null because the old check deleted the new mapping. The deterministic regression pauses key.hashCode with two CountDownLatch instances: the second call on the get path, or the first on the background removal path. The old entry timestamp is set to zero through reflection, without waiting for wall-clock expiration. ### What you expected to happen The fresh mapping must remain cached. An expiration check should only remove the entry it observed, not a replacement from a concurrent put. The overlapping get may still return null for the expired entry. ExpiringCache uses the map for RPC results. The bug discards a valid replacement and causes unnecessary cache misses and repeated remote calls. ### Anything else The prepared fix uses computeIfPresent and strict wrapper identity in both removal paths. Payload equality is deliberately avoided because ExpiryObject.equals delegates to the stored value. Unmodified production source: six new concurrent-replacement regressions fail and two unchanged-entry guards pass. Patched source: all eight pass. Maven verify for the cache module plus reactor dependencies passes those eight tests and the five existing ExpiringCacheFactoryTest tests. Spotless and both Checkstyle audits pass. Minimal reproduction and regression tests: https://github.com/wozhenbang2004/dubbo/blob/fc828fa2899d3d50762cd1f854d14665c965f5a2/dubbo-plugin/dubbo-filter-cache/src/test/java/org/apache/dubbo/cache/support/expiring/ExpiringMapTest.java ### Do you have a (mini) reproduction demo? - [x] Yes, I have a minimal reproduction demo to help resolve this issue more effectively! ### Are you willing to submit a pull request to fix on your own? - [x] Yes I am willing to submit a pull request on my own! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
