8000 Clear the weak and soft references, rather than nulling fields by andrewaylett · Pull Request #108 · andrewaylett/arc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 1 commit into from
May 31, 2025

Conversation

andrewaylett
Copy link
Owner

This more accurately reflects what the GC would do.

@Copilot Copilot AI review requested due to automatic review settings May 29, 2025 22:17
Copy link
@Copilot Copilot AI left a 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;
Copy link
Preview
Copilot AI May 29, 2025

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")
Copy link
Preview
Copilot AI May 29, 2025

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.

Copy link
  • Surviving mutants in this change: 11
  • Killed mutants in this change: 3
class surviving killed
🧟eu.aylett.arc.internal.Element 7 2
🧟eu.aylett.arc.Arc 4 1

See https://pitest.org

This more accurately reflects what the GC would do.
Copy link
  • Surviving mutants in this change: 11
  • Killed mutants in this change: 3
class surviving killed
🧟eu.aylett.arc.internal.Element 7 2
🧟eu.aylett.arc.Arc 4 1

See https://pitest.org

@andrewaylett andrewaylett merged commit 98a56f2 into main May 31, 2025
6 checks passed
@andrewaylett andrewaylett deleted the push-vnwlllvovrqy branch May 31, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0