Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330074

Summary: null returns from SnapshotImpl methods
Product: [Tools] MAT Reporter: Andrew Johnson <andrew_johnson>
Component: CoreAssignee: Andrew Johnson <andrew_johnson>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: jlawrence
Version: 1.1   
Target Milestone: 1.11.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/157849
https://git.eclipse.org/c/mat/org.eclipse.mat.git/commit/?id=3d45e31e4485c49225601e1a40bb6520fd74e6fe
https://git.eclipse.org/r/165041
https://git.eclipse.org/c/mat/org.eclipse.mat.git/commit/?id=793ac4a027ad8e9815e71b2cad515665badd0b08
Whiteboard:

Description Andrew Johnson CLA 2010-11-12 06:32:08 EST
These methods can return null:

getClassesByName(String name, boolean includeSubClasses)
getHistogram(int[] objectIds, IProgressListener progressMonitor)
getInboundRefererIds(int[] objectIds, IProgressListener progressMonitor)

Should they be able to return null?
If so, do all uses check for null?
Comment 1 Andrew Johnson CLA 2011-06-02 05:46:23 EDT
Problem with CollectionFillRatio and and unknown -collection object

collections_grouped_by_size .*  -collection notfound -size_attribute notfound

java.lang.NullPointerException
at org.eclipse.mat.inspections.collections.CollectionsBySizeQuery.execute(CollectionsBySizeQuery.java:80)
at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
at org.eclipse.mat.ui.QueryExecution$ExecutionJob.run(QueryExecution.java:174)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 2 Jonathan Lawrence CLA 2012-03-23 12:48:17 EDT
All uses do not check for null.  Here's an example:

java.lang.NullPointerException
    at org.eclipse.mat.inspections.component.ComponentReportQuery.addOverviewNumbers(ComponentReportQuery.java:276)
    at org.eclipse.mat.inspections.component.ComponentReportQuery.addOverview(ComponentReportQuery.java:262)
    at org.eclipse.mat.inspections.component.ComponentReportQuery.execute(ComponentReportQuery.java:94)
    at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
    at org.eclipse.mat.snapshot.query.SnapshotQuery.execute(SnapshotQuery.java:192)
    at org.eclipse.mat.inspections.component.TopComponentsReportQuery.execute(TopComponentsReportQuery.java:67)
    at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
    at org.eclipse.mat.query.registry.CommandLine.execute(CommandLine.java:93)
    at org.eclipse.mat.report.internal.QueryPart.execute(QueryPart.java:96)
    at org.eclipse.mat.report.TestSuite.execute(TestSuite.java:138)
    at org.eclipse.mat.report.internal.RunRegisterdReport.execute(RunRegisterdReport.java:60)
    at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
    at org.eclipse.mat.ui.QueryExecution$ExecutionJob.run(QueryExecution.java:176)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

The above could have been caused by the user cancelling the progress monitor during an earlier getHistogram(int[] objectIds, IProgressListener progressMonitor) call.
Comment 3 Andrew Johnson CLA 2014-05-12 07:43:22 EDT
I've checked that calls to those methods now check the return for null.
Comment 4 Eclipse Genie CLA 2020-02-17 11:05:59 EST
New Gerrit change created: https://git.eclipse.org/r/157849
Comment 6 Eclipse Genie CLA 2020-06-17 06:21:22 EDT
New Gerrit change created: https://git.eclipse.org/r/165041
Comment 8 Andrew Johnson CLA 2020-06-17 06:56:51 EDT
Let's close this one now as we have fixed all the problems we can see.