Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix incorrect use of weak reference #31

Merged
merged 1 commit into from Mar 30, 2023
Merged

fix incorrect use of weak reference #31

merged 1 commit into from Mar 30, 2023

Conversation

Glease
Copy link

@Glease Glease commented Mar 30, 2023

Fix GTNewHorizons/GT-New-Horizons-Modpack#13079

if unfortunate things can happen, it will happen. gc kick in after CachedPatternInventory is created, but before cache.inventory.get() has returned and cleared the WeakReference before it is ever used.

TBH it's highly questionable to use WeakReference as a cache. SoftReference combined with a expiration time or more complex custom cache clearing mechanism is a much better choice, or just simply guava cache, but I'm too lazy 馃槢

@Glease Glease requested a review from a team March 30, 2023 04:38
Copy link

@Pilzinsel64 Pilzinsel64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me. If someone wants another ways, it can still be changed afterwards.

@Pilzinsel64 Pilzinsel64 merged commit bbffeae into master Mar 30, 2023
1 check passed
@Pilzinsel64 Pilzinsel64 deleted the fix/weakref branch March 30, 2023 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants