Skip to content

Commit 44e2c5c

Browse files
committed
report JMX exception only if the application is still alive
1 parent 86c942a commit 44e2c5c

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

visualvm/sampler.truffle/src/org/graalvm/visualvm/sampler/truffle/memory/MemorySamplerSupport.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
import javax.management.ReflectionException;
5151
import javax.swing.SwingUtilities;
5252
import javax.swing.Timer;
53+
import org.graalvm.visualvm.core.datasupport.Stateful;
5354
import org.graalvm.visualvm.lib.common.ProfilingSettings;
5455
import org.graalvm.visualvm.lib.jfluid.results.memory.SampledMemoryResultsSnapshot;
55-
import org.openide.util.Exceptions;
5656
import org.openide.util.NbBundle;
5757

5858
/**
@@ -188,6 +188,9 @@ public void run() {
188188
if (!timer.isRunning()) return;
189189
doRefreshImplImpl(takeHeapHistogram(), views);
190190
} catch (Exception e) {
191+
if (application.getState() == Stateful.STATE_AVAILABLE) {
192+
e.printStackTrace();
193+
}
191194
terminate();
192195
}
193196
}
@@ -197,21 +200,10 @@ public void run() {
197200
}
198201
}
199202

200-
private TruffleHeapHistogram takeHeapHistogram() {
201-
try {
202-
Map<String, Object>[] histo = histogramProvider.heapHistogram();
203-
204-
return new TruffleHeapHistogram(histo);
205-
} catch (InstanceNotFoundException ex) {
206-
Exceptions.printStackTrace(ex);
207-
} catch (MBeanException ex) {
208-
Exceptions.printStackTrace(ex);
209-
} catch (ReflectionException ex) {
210-
Exceptions.printStackTrace(ex);
211-
} catch (IOException ex) {
212-
Exceptions.printStackTrace(ex);
213-
}
214-
return null;
203+
private TruffleHeapHistogram takeHeapHistogram() throws InstanceNotFoundException, MBeanException, ReflectionException, IOException {
204+
Map<String, Object>[] histo = histogramProvider.heapHistogram();
205+
206+
return new TruffleHeapHistogram(histo);
215207
}
216208

217209
private void doRefreshImplImpl(final TruffleHeapHistogram heapHistogram, final MemoryView... views) {

0 commit comments

Comments
 (0)