Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340763 - NullPointerException with csv format SystemPropertiesQuery and PHD
Summary: NullPointerException with csv format SystemPropertiesQuery and PHD
Status: RESOLVED FIXED
Alias: None
Product: MAT
Classification: Tools
Component: Core (show other bugs)
Version: 1.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Andrew Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-23 10:25 EDT by Andrew Johnson CLA
Modified: 2011-04-06 08:05 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Johnson CLA 2011-03-23 10:25:58 EDT
Modifying overview.xml
with
	<query name="%overview.system_properties">
		<param key="format" value="csv" />
and running it on a PHD gives

java.lang.NullPointerException
	at org.eclipse.mat.report.internal.HtmlOutputter.process(HtmlOutputter.java:88)
	at org.eclipse.mat.report.internal.ResultRenderer.doProcessAlien(ResultRenderer.java:274)
	at org.eclipse.mat.report.internal.ResultRenderer.process(ResultRenderer.java:240)
	at org.eclipse.mat.report.internal.QueryPart.execute(QueryPart.java:160)
	at org.eclipse.mat.report.internal.SectionPart.execute(SectionPart.java:53)
	at org.eclipse.mat.report.TestSuite.execute(TestSuite.java:131)
	at org.eclipse.mat.report.internal.RunExternalTest.execute(RunExternalTest.java:39)
	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)

Is null an acceptable return from a query? The GUI says "Query did not return any result".
Comment 1 Andrew Johnson CLA 2011-03-23 12:52:51 EDT
This can also be demonstrated by running the regression.xml report from a development version of MAT with the org.eclipse.mat.test plugin loaded.

doProcess will chose another outputter if required, but in this case will leave it as HtmlOutputter as we do not know which type to use for a null result.

The easiest solution is to change ResultRenderer.process() to call doProcess if the outputter is HtmlOutputter rather than if the type is "html" as the alternative of doProcessAlien will always fail if the outputter is actually HtmlOutputter.
Comment 2 Andrew Johnson CLA 2011-03-23 13:17:35 EDT
We also should consider what happens if a new outputter of type "html" is created to handle a specific type of output.

@Renderer(target = "html", result = IResultTree.class)
public class HtmlOutputter2 extends HtmlOutputter
{
    public void embedd(Context context, IResult result, Writer writer) throws IOException
    {
        writer.append("<p>A special table</p>");
        super.embedd(context, result, writer);
    }
}

We don't want to use doProcessAlien for these as we want it all embedded in the same report.

The test therefore is:
        if ("html".equals(format) || outputter.equals(html)) //$NON-NLS-1$
Comment 3 Andrew Johnson CLA 2011-04-06 08:05:34 EDT
The fix solved the problem.