Skip to content

Commit 1d0f41a

Browse files
committed
Make sure an initialized Progress (timer started) is always finished (timer stopped).
1 parent 2e1e87c commit 1d0f41a

File tree

6 files changed

+29
-31
lines changed

6 files changed

+29
-31
lines changed

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaFieldsPlugin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,10 @@ protected HeapViewerNode[] lazilyComputeChildren(Heap heap, String viewID, HeapV
363363
if ("object".equals(fieldTypeName)) { // NOI18N
364364
final InstanceCounter values = new InstanceCounter(instancesCount);
365365

366-
progress.setupKnownSteps(instancesCount);
367-
368-
Iterator<Instance> instances = instancesIterator();
369366
try {
367+
progress.setupKnownSteps(instancesCount);
368+
369+
Iterator<Instance> instances = instancesIterator();
370370
while (instances.hasNext()) {
371371
Instance instance = instances.next();
372372
progress.step();
@@ -412,10 +412,10 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
412412
} else {
413413
final PrimitiveCounter counter = PrimitiveCounter.create(fieldTypeName, instancesCount);
414414

415-
progress.setupKnownSteps(instancesCount);
416-
417-
Iterator<Instance> instances = instancesIterator();
418415
try {
416+
progress.setupKnownSteps(instancesCount);
417+
418+
Iterator<Instance> instances = instancesIterator();
419419
while (instances.hasNext()) {
420420
Instance instance = instances.next();
421421
progress.step();

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaReferencesPlugin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ private HeapViewerNode[] computeInstancesReferences(final InstancesWrapper insta
220220
HeapOperations.initializeReferences(heap);
221221

222222
final Map<Long, Integer> values = new HashMap();
223-
224-
progress.setupKnownSteps(instances.getInstancesCount());
223+
224+
try {
225+
progress.setupKnownSteps(instances.getInstancesCount());
225226

226-
InterruptibleIterator<Instance> instancesI = instancesIterator(instances);
227-
try {
227+
InterruptibleIterator<Instance> instancesI = instancesIterator(instances);
228228
while (instancesI.hasNext()) {
229229
Instance instance = instancesI.next();
230230
progress.step();

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/PathToGCRootPlugin.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,10 @@ private static Collection<HeapViewerNode> computeInstanceRoots(Instance instance
257257
HeapViewerNode firstNode = null;
258258
ToRoot previousNode = null;
259259

260-
Thread current = Thread.currentThread();
261-
262-
progress.setupUnknownSteps();
263-
264260
try {
261+
progress.setupUnknownSteps();
262+
263+
Thread current = Thread.currentThread();
265264
while (!current.isInterrupted() && instance != nextInstance) {
266265
List<Value> references = instance.getReferences();
267266
for (Value reference : references) {
@@ -296,11 +295,10 @@ private static Collection<HeapViewerNode> computeInstanceRoots(Instance instance
296295
private static Collection<HeapViewerNode> computeInstancesRoots(Iterator<Instance> instances, int count, Progress progress) throws InterruptedException {
297296
Map<Instance, HeapViewerNode> gcRoots = new HashMap();
298297

299-
Thread current = Thread.currentThread();
300-
301-
progress.setupKnownSteps(count);
302-
303298
try {
299+
progress.setupKnownSteps(count);
300+
301+
Thread current = Thread.currentThread();
304302
while (!current.isInterrupted() && instances.hasNext()) {
305303
Instance instance = instances.next();
306304
Instance gcRoot = getGCRoot(instance, current);

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/oql/OQLQueryExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
201201
HeapViewerNode[] nodes = computer.computeNodes(root, heap, viewID, viewFilter, dataTypes, sortOrders, progress);
202202
return nodes.length == 0 ? new HeapViewerNode[] { new TextNode(Messages.getNoObjectsString(viewFilter)) } : nodes;
203203
} else {
204-
progress.setupUnknownSteps();
205-
206204
try {
205+
progress.setupUnknownSteps();
206+
207207
List<InstancesContainer.Objects> cnodes = new ArrayList();
208208
Map<String, InstancesContainer.Objects> classes = new HashMap();
209209
for (Object object : queryObjects) {

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/utils/MoreObjectsNode.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ private T[] getObjects(int containerIndex, Heap heap, HeapViewerNodeFilter viewF
195195

196196
T object;
197197

198-
progress.setupUnknownSteps();
199-
200198
try {
199+
progress.setupUnknownSteps();
200+
201201
object = getPreviousObject(containerIndex, heap, viewFilter, dataType, sortOrder, progress);
202202
} finally {
203203
progress.finish();
@@ -210,9 +210,9 @@ private T[] getObjects(int containerIndex, Heap heap, HeapViewerNodeFilter viewF
210210

211211
T[] objects;
212212

213-
progress.setupKnownSteps(iteratorObjectsCount);
214-
215213
try {
214+
progress.setupKnownSteps(iteratorObjectsCount);
215+
216216
Iterator<T> objectsIt = objectsIterator(0, progress);
217217
while (objectsIt.hasNext()) buffer.add(objectsIt.next());
218218

@@ -247,9 +247,9 @@ private HeapViewerNode[] loadChildren(int containerIndex, Progress progress) thr
247247

248248
HeapViewerNode[] nodes;
249249

250-
progress.setupKnownSteps(end);
251-
252250
try {
251+
progress.setupKnownSteps(end);
252+
253253
int i = 0;
254254
nodes = new HeapViewerNode[end - start + 1];
255255
Iterator<T> objectsIt = objectsIterator(start, progress);
@@ -302,9 +302,9 @@ private HeapViewerNode[] computeSampleChildren(int count, Heap heap, String view
302302

303303
HeapViewerNode[] nodes;
304304

305-
progress.setupKnownSteps(iteratorObjectsCount);
306-
307305
try {
306+
progress.setupKnownSteps(iteratorObjectsCount);
307+
308308
int i = 0;
309309
nodes = new HeapViewerNode[count];
310310
Iterator<T> objectsIt = objectsIterator(0, progress);

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/utils/NodesComputer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
147147
ObjectsIterator objectsIt;
148148
T[] objects;
149149

150-
if (itemsCount == Integer.MAX_VALUE) progress.setupUnknownSteps();
151-
else progress.setupKnownSteps(itemsCount);
152-
153150
try {
151+
if (itemsCount == Integer.MAX_VALUE) progress.setupUnknownSteps();
152+
else progress.setupKnownSteps(itemsCount);
153+
154154
objectsIt = objectsIterator(0, 0, -1, viewFilter, heap, progress);
155155
while (objectsIt.hasNext()) buffer.add(objectsIt.next());
156156

0 commit comments

Comments
 (0)