Bug 13076 - [PATCH] NullPointerException in FormulaRecord
Summary: [PATCH] NullPointerException in FormulaRecord
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-dev
Hardware: PC All
: P3 normal with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-27 14:01 UTC by Dennis Doubleday
Modified: 2005-03-20 17:06 UTC (History)
1 user (show)



Attachments
Excel document that caused the bug report (52.50 KB, application/octet-stream)
2002-09-27 14:03 UTC, Dennis Doubleday
Details
Patch file that fixes the problem (9.10 KB, patch)
2002-11-12 16:45 UTC, Dennis Doubleday
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Doubleday 2002-09-27 14:01:24 UTC
The version is actually 1.8.0-dev, but I didn't see that in the list.

I got the following exception when running BiffViewer on the file attached to
this bug:

============================================
Offset 0x20db (8411)
[WARNING] Unknown Ptg 12 (18) at cell (10,1)
recordid = 0x6, size =30
java.lang.NullPointerException
        at org.apache.poi.hssf.record.FormulaRecord.toString(FormulaRecord.java:
548)
        at org.apache.poi.hssf.dev.BiffViewer.createRecord(BiffViewer.java:638)
        at org.apache.poi.hssf.dev.BiffViewer.createRecords(BiffViewer.java:158)

        at org.apache.poi.hssf.dev.BiffViewer.run(BiffViewer.java:110)
        at org.apache.poi.hssf.dev.BiffViewer.main(BiffViewer.java:687)
Comment 1 Dennis Doubleday 2002-09-27 14:03:14 UTC
Created attachment 3259 [details]
Excel document that caused the bug report
Comment 2 Dennis Doubleday 2002-11-11 22:06:56 UTC
I found what causes the NPE. In FormulaRecord.fillFields(), if an
UnsupportedOperationException is thrown while parsing, the field
field_8_parsed_expr is set to null, but then the following appears in
FormulaRecord.toString() (line 548):

buffer.append("    .numptgsinarray  = ").append(field_8_parsed_expr.size())
                .append("\n");
            
for (int k = 0; k < field_8_parsed_expr.size(); k++ ) {

Either reference to field_8_parsed_expr.size() will cause an NPE because the
field was set to null.
Comment 3 Dennis Doubleday 2002-11-12 16:45:37 UTC
Created attachment 3821 [details]
Patch file that fixes the problem
Comment 4 Dennis Doubleday 2002-11-12 16:46:01 UTC
Patch attached. Note that this patch means that BiffViewer will not fail with an
exception when a formula doesn't parse--you'll just see a WARNING in the output.
Maybe that means you want to change BiffViewer, but this is the right patch for
this problem, anyway.
Comment 5 Andy Oliver 2002-11-28 18:59:00 UTC
applied and committed.  Please crosscheck.  It would be good if we could signal
an error in a recoverable way.