From 6674bf0273a81159232ff1d419e3d1d09abc3745 Mon Sep 17 00:00:00 2001 From: jasonk000 Date: Sun, 3 May 2026 21:59:57 -0700 Subject: [PATCH] nit: more spotbugs fixes --- .../org.eclipse.mat.api/META-INF/MANIFEST.MF | 2 +- .../mat/inspections/LeakHunterQuery.java | 2 +- .../inspections/threads/ThreadInfoImpl.java | 2 ++ .../inspections/util/ObjectTreeFactory.java | 21 ++----------------- .../mat/tests/CreateCollectionDump.java | 8 ++----- 5 files changed, 8 insertions(+), 27 deletions(-) diff --git a/plugins/org.eclipse.mat.api/META-INF/MANIFEST.MF b/plugins/org.eclipse.mat.api/META-INF/MANIFEST.MF index 69267bd0..43a34603 100644 --- a/plugins/org.eclipse.mat.api/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.mat.api/META-INF/MANIFEST.MF @@ -23,7 +23,7 @@ Bundle-Activator: org.eclipse.mat.internal.MATPlugin Eclipse-LazyStart: true Bundle-ActivationPolicy: lazy Eclipse-BuddyPolicy: registered -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-21 Bundle-Localization: plugin Bundle-Copyright: Copyright (c) 2008, 2022 SAP AG, IBM Corporation and others. All rights reserved. This program and the accompanying materials diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/LeakHunterQuery.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/LeakHunterQuery.java index aa7e173b..509e4778 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/LeakHunterQuery.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/LeakHunterQuery.java @@ -645,7 +645,7 @@ private String getRetainedHeapTopConsumersDescription(int[] objects, IProgressLi boolean multipleItems = entries.size() > 1 && topItems > 1; PriorityQueue> pq = new PriorityQueue>(entries.size(), (e1, e2) -> e2.getValue().compareTo(e1.getValue())); - pq.addAll(entries); + entries.forEach(e -> pq.add(Map.entry(e.getKey(), e.getValue()))); int maxItems = Math.min(pq.size(), topItems); while (maxItems-- > 0 && pq.size() > 0) { diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/threads/ThreadInfoImpl.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/threads/ThreadInfoImpl.java index d4adc001..3e62d329 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/threads/ThreadInfoImpl.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/threads/ThreadInfoImpl.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.function.Supplier; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.eclipse.mat.SnapshotException; import org.eclipse.mat.collect.ArrayInt; import org.eclipse.mat.internal.Messages; @@ -157,6 +158,7 @@ private static IObject resolveContextClassLoader(ThreadInfoImpl info) return null; } + @CheckForNull private static Boolean resolveIsDaemon(IObject thread) { try diff --git a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/util/ObjectTreeFactory.java b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/util/ObjectTreeFactory.java index 92547db1..03beff88 100644 --- a/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/util/ObjectTreeFactory.java +++ b/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/util/ObjectTreeFactory.java @@ -106,7 +106,7 @@ public TreePathBuilder addSibling(int objectId, boolean select) public IResultTree build(ISnapshot snapshot) { - return new NodeResult(snapshot, root, base, false, incoming); + return new NodeResult(snapshot, root, base, incoming); } } @@ -117,7 +117,6 @@ public IResultTree build(ISnapshot snapshot) private static class Node { int ownId; - String attributeName; List children; boolean isExpanded; boolean isSelected; @@ -175,15 +174,13 @@ private static Column col_percent() private ISnapshot snapshot; private Node invisibleRoot; private long base; - private boolean decorateWithAttributeName; private Boolean incoming; - private NodeResult(ISnapshot snapshot, Node root, long base, boolean decorateWithAttributeName, Boolean incoming) + private NodeResult(ISnapshot snapshot, Node root, long base, Boolean incoming) { this.snapshot = snapshot; this.invisibleRoot = root; this.base = base; - this.decorateWithAttributeName = decorateWithAttributeName; this.incoming = incoming; } @@ -195,20 +192,6 @@ public ResultMetaData getResultMetaData() public Column[] getColumns() { Column classNameCol = new Column(Messages.Column_ClassName, String.class); - if (decorateWithAttributeName) - classNameCol.decorator(new IDecorator() - { - public String prefix(Object row) - { - return ((Node) row).attributeName; - } - - public String suffix(Object row) - { - return null; - } - }); - if (base > 0) return new Column[] { classNameCol, COL_HEAP, COL_RETAINED, col_percent() }; else diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/CreateCollectionDump.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/CreateCollectionDump.java index 62dc12d2..cdc5ee71 100644 --- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/CreateCollectionDump.java +++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/CreateCollectionDump.java @@ -1042,19 +1042,15 @@ private Object[][] buildArgs(Map mapVals, Map enum enumVals.put(Month.of(i), values[i]); } SimpleType st[] = Collections.nCopies(COUNT, SimpleType.STRING).toArray(new SimpleType[COUNT]); - CompositeType ct1; - TabularType tt1; try { // keys[], values[] is 1-offset, we need 0-offset - ct1 = new CompositeType("composite test", "a composite type", mapVals.keySet().toArray(new String[COUNT]), mapVals.values().toArray(new String[COUNT]), st); - tt1 = new TabularType("tabular test", "testing tabular types with strings", ct1, mapVals.keySet().toArray(new String[COUNT])); + CompositeType ct1 = new CompositeType("composite test", "a composite type", mapVals.keySet().toArray(new String[COUNT]), mapVals.values().toArray(new String[COUNT]), st); + new TabularType("tabular test", "testing tabular types with strings", ct1, mapVals.keySet().toArray(new String[COUNT])); } catch (OpenDataException e) { e.printStackTrace(); - ct1 = null; - tt1 = null; } MapmapVals2 = new HashMap(mapVals); // Arguments