-
Notifications
You must be signed in to change notification settings - Fork 0
Clear the weak and soft references, rather than nulling fields #108
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 clickin 8000 g “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request updates the handling of weak references to more closely mimic the garbage collector behavior by clearing references rather than nulling fields.
- The access modifier for the key field in Element.java was changed from private to public.
- Weak reference handling in Element.java and Arc.java has been updated to use enqueue(), clear(), and improved checks.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
lib/src/main/java/eu/aylett/arc/internal/Element.java | Adjustments to weak reference management and access levels of key and getOwner(). |
lib/src/main/java/eu/aylett/arc/Arc.java | Added logic to clear element entries based on owner type and safety checks. |
Comments suppressed due to low confidence (1)
lib/src/main/java/aylett/arc/Arc.java:153
- [nitpick] The computeIfPresent lambda relies on in-place mutation (calling clear() on v). Adding a clarifying comment here would improve maintainability by explaining why the entry is kept in the map despite being cleared.
if (element.getOwner() instanceof UnownedElementList) {
@@ -45,7 +45,7 @@ | |||
public final class Element<K extends @NonNull Object, V extends @NonNull Object> { | |||
private final Lock lock = new ReentrantLock(); | |||
/** The key associated with this element. */ | |||
private final K key; | |||
public final K key; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the 'key' field from private to public exposes internal state. If this is intentional, please update the documentation to clarify its intended usage.
Copilot uses AI. Check for mistakes.
} | ||
|
||
@Pure | ||
@Holding("this.lock") | ||
ElementList getOwner() { | ||
@SuppressFBWarnings("EI") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifying the access level of the getOwner() method from package-private to public may affect encapsulation. Please ensure this change is intentional and document the new API behavior if needed.
Copilot uses AI. Check for mistakes.
|
This more accurately reflects what the GC would do.
40ea46c
to
13765b8
Compare
|
This more accurately reflects what the GC would do.