Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Null pointer exception in ChartItemUtil.checkChartBindingComplete()
emil_m
Hi,<br />
<br />
I'm using birt 2.5.2 deployed in JBoss.<br />
<br />
Inside an area chart we have a beforeGeneration(chart, icsc) function having the following:<br />
<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var xAxis = chart.getAxes().get(0);
var yAxis1 = xAxis.getAssociatedAxes().get(0);
var sdNew = SeriesDefinitionImpl.create();
for (...) {
//business logic
sdNew.getSeries().add(...);
}
yAxis1.getSeriesDefinitions().add( sdNew );
</pre>
<br />
At the last line, the server throws a null pointer exception at org.eclipse.birt.chart.reportitem.api.ChartItemUtil.checkChartBindingComplete(ChartItemUtil.java:1186).<br />
<br />
The crash occurs in <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public static boolean checkChartBindingComplete( Chart cm )
{
Series bs = ChartUtil.getBaseSeriesDefinitions( cm )
.get( 0 )
.getDesignTimeSeries( );
if ( bs.getDataDefinition( ).size( ) == 0
|| ChartUtil.isEmpty( bs.getDataDefinition( )
.get( 0 )
.getDefinition( ) ) )
{
return false;
}
for ( SeriesDefinition vsd : ChartUtil.getAllOrthogonalSeriesDefinitions( cm ) )
{
Series vs = vsd.getDesignTimeSeries( );
if ( vs.getDataDefinition( ).size( ) == 0
|| ChartUtil.isEmpty( vs.getDataDefinition( )
.get( 0 )
.getDefinition( ) ) )
{
return false;
}
}
return true;
}
</pre>
<br />
So, because the vs variable comes null at a certain point inside the for each, the null pointer exception is thrown. <br />
<br />
I've checked the last committed CheckItemUtil class from birt 2.6.1 and the checkChartBindingComplete method is unchanged. <br />
<br />
Would it be OK to add a check to see if vs variable is not null inside the <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if (vs.getDataDefinition().size() == 0 || ChartUtil.isEmpty(vs.getDataDefinition().get(0).getDefinition())</pre>?<br />
<br />
I would also like to mention that the initial code of the beforeGeneration function from the chart is not mine and I cannot track the initial business logic, I just have to make this not crash.<br />
<br />
Regards,<br />
Emil
Find more posts tagged with
Comments
mwilliams
Hi Emil,
Could you try to catch the null values with a check? Just an idea.