Repository navigation
Fix MagazineManager evicting every other magazine on registration - #15
Merged
Merged
Conversation
added 9 commits
September 8, 2026 20:29
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The bug
MagazineManager.refresh(List<Magazine<?>>)replaced the entire registry instead of upserting into it. A caller registering magazines one at a time — the natural reading of "refresh", and what the method did in 1.x — unregistered every other magazine. The next access to one of them threwMAGAZINE_NOT_FOUND, and rebuilding the handle cost a shard configuration read, becauseMagazine's constructor ends with an unconditionalbaseMagazineStorage.initialize(magazineIdentifier).Nothing was deleted from storage — a
Magazineis a handle. The cost is latency, and under concurrent single-magazine registrations the miss rate approaches 100%.Why it regressed
magazines.forEach(m -> magazineMap.put(m.getMagazineIdentifier(), m))— upsertmagazineMap.set(magazines.stream().collect(toUnmodifiableMap(...)))— replace2.0.0 fixed a genuine thread-safety bug (unsynchronised
HashMapunder concurrent refresh/get) by publishing an immutable map through anAtomicReference. The semantic change came along with it, under an unchanged name and an unchanged javadoc.Changes
Removed
refresh(List<Magazine<?>>). This is source-breaking against 2.0.0, which is why it is called out here — but 2.0.0 has no adopters, and the name was the whole defect. Migration is a rename toreplaceAll, with no behaviour change.Added
register(Magazine<?>)getOrRegister(String, Supplier<Magazine<T>>)find(String)Optionalunregister(String)replaceAll(List<Magazine<?>>)