Bug 63373

Summary: XSSFConditionalFormattingThreshold.getRangeType will cause NullPointException if the type is "formula"
Product: POI Reporter: Rex Rao <sohobloo>
Component: XSSFAssignee: POI Developers List <dev>
Status: NEEDINFO ---    
Severity: normal    
Priority: P2    
Version: 4.0.x-dev   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Rex Rao 2019-04-22 07:52:15 UTC
This function will call RangeType.byName("formula"), in which will traverse all the RangeType enum strings. But one of them is "UNALLOCATED(6, null)" which is behind the formula enum "FORMULA(7, "formula")". When calling null.equals("formula") the exception throws.
Comment 1 Dominik Stadler 2019-04-23 20:32:50 UTC
Any chance you can provide some code-snippet which allows to reproduce this? Ideally as self-sufficient unit-test so we can add it to our set of tests?
Comment 2 Rex Rao 2019-04-24 01:29:05 UTC
(In reply to Dominik Stadler from comment #1)
> Any chance you can provide some code-snippet which allows to reproduce this?
> Ideally as self-sufficient unit-test so we can add it to our set of tests?

Just call:
org.apache.poi.ss.usermodel.ConditionalFormattingThreshold.RangeType.byName("formula");

The OOXML looks like:
    <conditionalFormatting sqref="D1:D1048576">
        <cfRule type="dataBar" priority="4">
            <dataBar>
                <cfvo type="formula" val="$J$1"/>
                <cfvo type="formula" val="SUM(1,10)"/>
                <color rgb="FF638EC6"/>
            </dataBar>
            <extLst>
                <ext uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}"
                    xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main">
                    <x14:id>{8217E8C7-34F0-4144-BB9D-FCDC772EE7C7}</x14:id>
                </ext>
            </extLst>
        </cfRule>
    </conditionalFormatting>