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

Bug 326692

Summary: NPE in BubbleDataSetProcessorImpl.getMinimum()
Product: z_Archived Reporter: Jim Garrison <jgarrison>
Component: BIRTAssignee: Birt-Chart-inbox <Birt-Chart-inbox>
Status: NEW --- QA Contact: Xiaoying Gu <bluesoldier>
Severity: major    
Priority: P3 CC: bluesoldier
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Proposed patch jgarrison: review?

Description Jim Garrison CLA 2010-09-30 13:05:58 EDT
Build Identifier: BIRT 2.6.1

BubbleDataSetProcessorImpl#getMinimum (and #getMaximum) contains code looking like this:

    Number bnMin = null;
    for ( int i = 0; dsi.hasNext( ); i++ )
    {
        bde = (BubbleEntry) dsi.next( );
        if ( bde != null )
        {
            Object oValue = bde.getValue( );
            if ( NumberUtil.isBigNumber( oValue ) )
            {
                BigNumber bnValue = (BigNumber)oValue;
                bnValue = bnValue.subtract(  (BigNumber) bde.getSizeNumber( ) );
                if ( i == 0 )
                {
                    bnMin = bnValue;
                }
                else
                {
NPE ===>                bnMin = ( (BigNumber) bnMin ).min( bnValue );
                }
            }
            else if ( oValue instanceof BigDecimal )
            {
                BigDecimal bnValue = (BigDecimal)oValue;
                bnValue = bnValue.subtract(  (BigDecimal) bde.getSizeNumber( ) );
                if ( i == 0 )
                {
                    bnMin = bnValue;
                }
                else
                {
NPE ===>                bnMin = ( (BigDecimal) bnMin ).min( bnValue );
                }
            }
            else if ( oValue instanceof java.math.BigDecimal )
            {
                . . . same as above
            }
            else if ( oValue instanceof Number )
            {
                . . . same as above
            }
            else if ( oValue instanceof CDateTime )
            {
                . . . same as above
            }
        }
    }


The problem here is it assumes that the incoming dataset's first entry will always be non-null.  We are seeing a case where the dataset contains

    [null, 969, null, null]

Since the initialization of bnMin is based on the index being zero, an NPE occurs when the index value is 1 since bnMin was not previously set.

I don't know enough about BIRT internals to determine if the incoming dataset
is correct.  This problem started occurring after updating BIRT from 2.5.0 to 2.6.1, with no changes to the report definition or queries.

Reproducible: Sometimes
Comment 1 Jim Garrison CLA 2010-10-08 12:52:53 EDT
Created attachment 180501 [details]
Proposed patch

This patch fixes the immediate problem, which results from the input array of values containing a null at offset [0] (and non-null value(s) later on).  If that input configuration is invalid, then the real problem lies in upstream code that set up the array.  I don't know enough about BIRT internals to make that decision.
Comment 2 Jim Garrison CLA 2010-10-25 11:43:44 EDT
Has anybody had a chance to look at this bug and my possible patch?
Comment 3 Jim Garrison CLA 2011-02-22 13:43:12 EST
Anybody?