Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326692 - NPE in BubbleDataSetProcessorImpl.getMinimum()
Summary: NPE in BubbleDataSetProcessorImpl.getMinimum()
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Birt-Chart-inbox@eclipse.org CLA
QA Contact: Xiaoying Gu CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-30 13:05 EDT by Jim Garrison CLA
Modified: 2011-02-22 13:43 EST (History)
1 user (show)

See Also:


Attachments
Proposed patch (3.44 KB, patch)
2010-10-08 12:52 EDT, Jim Garrison CLA
jgarrison: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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?