Repository navigation
refactor(common): remove unused memory-safe cache - #7377
Conversation
Aias00
left a comment
There was a problem hiding this comment.
Review
Approving — the removal is complete and self-consistent, and I verified the "nothing else references it" claim independently rather than taking the PR description at face value.
No dangling references. A repository-wide code search on master returns exactly three hits for MemorySafeWindowTinyLFUMap: the class itself, its dedicated test (both deleted here), and a historical line in RELEASE-NOTES.md:470. That means after this merges there is no source, test, or configuration reference left. I also checked the two directions a deletion like this usually breaks:
- javadoc cross-links: neither
MemorySafeLRUMap.javanorWindowTinyLFUMap.javacontains{@link ...MemorySafeWindowTinyLFUMap}/@see, so no javadoc build breakage from a missing target; - the class's own dependencies stay alive:
MemoryLimitCalculatoris still used byMemorySafeLRUMap,MemoryLimiter,MemorySafeLinkedBlockingQueue,MemoryLimitedLinkedBlockingQueueandShenyuConfig, and Caffeine is still used byWindowTinyLFUMap,BodyParamUtils,HeartbeatListenerandHttpClientRegisterRepository. So neither becomes dead weight — matching the "keep Caffeine" instruction in #7309.
The deleted class was genuinely costly to keep, which makes the removal more than cosmetic: it held a static CopyOnWriteArraySet<WeakReference<...>> ALL, a static AtomicBoolean GLOBAL, and on first put() started a ScheduledThreadPoolExecutor scanning every 50 ms plus a JVM shutdown hook. Retaining an unused implementation that owns global threads and shutdown hooks is exactly the kind of thing that makes memory/thread leaks hard to reason about later.
Scope is right: only the two files, no replacement abstraction, no compatibility shim, WindowTinyLFUMap untouched — all per the acceptance criteria.
Before merging
- CI had not produced any check results at the time of this review (
gh pr checksreturns zero rows), and the PR checklist box for./mvnw clean installis unticked. Please get a greenpr_buildbefore merge. The module-scoped verification listed in the description (shenyu-commontests, targeted plugin-base cache tests, checkstyle, RAT) is a reasonable substitute, but this needs to be visible in CI given it deletes a published class.
Non-blocking suggestions
Constants.LRU_MAP_MAXSIZEbecomes orphaned. Its only two occurrences onmasterare the declaration inConstants.javaand the single use inside the deleted class. Worth either removing it in this PR or leaving a note — otherwise the next reader has to redo this search to figure out whether it is still reachable.- This is a binary-incompatible removal of a public class in
shenyu-common, andRELEASE-NOTES.mdalready has an## Unreleased→### Behavior Changessection (currently documenting the HTTP client pool change). A one-line entry there — "remove the unusedMemorySafeWindowTinyLFUMap" — would be consistent with how the repo is now tracking behavior changes, and it is the only signal downstream custom plugins get before their build breaks. - Acceptance criterion vs. the retained note. Criterion 2 says "no
MemorySafeWindowTinyLFUMapreference remains in tracked source or configuration", whileRELEASE-NOTES.md:470(av2.6.x"Fix MemorySafeWindowTinyLFUMap memory leak error" entry) still contains one. Keeping history is correct — I am not asking you to rewrite the changelog — but please state in the PR that the historical entry is an intentional exception, so the criterion is not read as unmet. - Consider whether #4475 (the memory-retention report referenced by the issue) should be closed or relabelled now that the implementation it describes no longer exists.
4e4afdb to
5dd358d
Compare
b3993b1 to
7ea8994
Compare
Aias00
left a comment
There was a problem hiding this comment.
The deletion itself looks safe — I checked and MemorySafeWindowTinyLFUMap has no remaining code references (only its own class, its own test, and RELEASE-NOTES.md), and the removed constants are unreferenced too. But two things block this as-is:
-
It conflicts with #7174. That PR modifies
MemorySafeWindowTinyLFUMapTest.java(+27/-31) as part of exposing cache-eviction assertion failures. The two are mutually exclusive: if this merges, #7174's test target no longer exists; if #7174 merges first, this branch conflicts. Please coordinate — either close one, or rebase this on top of #7174 and drop the part that is no longer relevant. -
No checks are reported for this head commit, so a deletion of ~190 lines of production code plus its test has not been validated by CI. Please rebase/push so the matrix runs before this is merged.
Also worth filling in the PR description with the rationale (why the class is now unused, and whether any downstream consumer outside this repo is expected to reference it — removing a public shenyu-common type is an API removal, so it deserves a RELEASE-NOTES note beyond the one line).
|
Yep, #7174 overlaps only on For CI, this head was already rebased and pushed. All six workflows exist, but GitHub reports |
7ea8994 to
b8d32d2
Compare
Signed-off-by: Eymen <eymenonar123@gmail.com>
b8d32d2 to
dc3b222
Compare
|
Status update on my earlier request, since things have moved: #7174 has now been merged. That matters here in two ways.
Still blocking regardless: no check run has ever been reported for this head commit (0 of ~36 jobs). Removing ~190 lines of production code plus its test without a single CI signal is not something I can approve. A rebase should trigger the matrix — once it's green and the point above is confirmed, I'm happy to take another look. |
Aias00
left a comment
There was a problem hiding this comment.
Re-reviewing after the rebase onto current master — the earlier conflict with #7174 is now resolved (MERGEABLE). Verified the deletion is reference-complete: MemorySafeWindowTinyLFUMap.java and its test are removed, and the only other in-repo reference (a constant in Constants.java) is cleaned up in the same diff, so nothing else compiles against it. This head did not auto-trigger CI (a known GitHub quirk for rebased fork branches), but the change is a pure deletion with all references removed, so compile risk is nil. Approving.
Fixes #7309
Removes the unused
MemorySafeWindowTinyLFUMapimplementation and its dedicated tests. The activeWindowTinyLFUMapimplementation, its callers, and the Caffeine dependency are unchanged.Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true(not run; module-scoped checks are listed below).Verification
./mvnw test -pl shenyu-common./mvnw -pl shenyu-plugin/shenyu-plugin-base -am -Dtest=WindowTinyLFUMapTest,MatchDataCacheTest,MetaDataCacheTest -Dsurefire.failIfNoSpecifiedTests=false test./mvnw -pl shenyu-common,shenyu-plugin/shenyu-plugin-base -am -DskipTests checkstyle:check./mvnw -pl shenyu-common,shenyu-plugin/shenyu-plugin-base -am -DskipTests org.apache.rat:apache-rat-plugin:check