Skip to content

Commit

Permalink
Bug 582556 Leak suspects should include group of objects for remaining
Browse files Browse the repository at this point in the history
Fix SpotBugs for hashCode and equals

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=582556
Change-Id: Ic4ba57aa6e057769c5780c0552b4a233315251de
  • Loading branch information
ajohnson1 committed Oct 21, 2023
1 parent 3a6703e commit 4b32556
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;

Expand Down Expand Up @@ -113,12 +114,10 @@ public IResult execute(IProgressListener listener) throws Exception
listener.subTask(Messages.FindLeaksQuery_SearchingSingleObjects);

ArrayInt suspiciousObjects = new ArrayInt();
Set<String> suspectNames = new HashSet<String>();
int i = 0;
while (i < topDominators.length && snapshot.getRetainedHeapSize(topDominators[i]) > threshold)
{
suspiciousObjects.add(topDominators[i]);
suspectNames.add(snapshot.getClassOf(topDominators[i]).getName());
i++;
}

Expand Down Expand Up @@ -498,6 +497,25 @@ public int[] getSuspectInstances()

public static class SuspectRecord implements Comparable<SuspectRecord>
{
@Override
public int hashCode()
{
return Objects.hash(suspect.getObjectId(), suspectRetained);
}

@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SuspectRecord other = (SuspectRecord) obj;
return Objects.equals(suspect.getObjectId(), other.suspect.getObjectId()) && Objects.equals(suspectRetained, other.suspectRetained);
}

IObject suspect;

Bytes suspectRetained;
Expand Down

0 comments on commit 4b32556

Please sign in to comment.