zsewasdsdsd opened a new pull request, #16503:
URL: https://github.com/apache/dubbo/pull/16503

   ## Summary
   
   Fixes #16500.
   
   This PR fixes an issue in `LRU2Cache.put()` where updating a key that has 
already been promoted to the main cache does not replace its existing value.
   
   ## Problem
   
   `LRU2Cache` uses a two-write admission policy:
   
   1. The first `put()` records the key in the history cache (`preCache`).
   2. The second `put()` promotes the key into the main cache.
   3. Subsequent `put()` calls should update the existing cached value.
   
   However, the current implementation only checks whether the key exists in 
`preCache`. Once a key has been promoted, it is removed from `preCache`, 
causing subsequent updates to be treated as new entries instead of updating the 
main cache.
   
   As a result, callers may continue receiving stale cached values.
   
   ## Changes
   
   - Check whether the key already exists in the main cache before applying the 
two-write admission policy.
   - Update existing entries while preserving the previous-value return 
behavior.
   - Preserve the existing locking mechanism and LRU eviction order.
   - Add regression tests covering promoted-entry updates, LRU ordering, and 
null-valued entries.
   
   ## Verification
   
   **RED — Before the fix**
   - Reproduced the issue against the original upstream Java implementation.
   - 3 expected regression failures; 1 existing-behavior check passed.
   
   **GREEN — After the fix**
   - All 4 standalone regression checks passed.
   - Ran `LRU2CacheTest` using Maven on Windows with Java 21.
   - Tests run: **7**
   - Failures: **0**
   - Errors: **0**
   - Skipped: **0**
   - Maven result: **BUILD SUCCESS**
   
   No full-repository test suite or distributed RPC integration tests were run.
   
   ## Impact
   
   This change ensures that already-admitted cache entries can be updated 
correctly without changing the admission policy for new keys or introducing new 
dependencies.


-- 
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]

Reply via email to