You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/06/12 22:56:45 UTC

[Bug 53404] New: IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

          Priority: P2
            Bug ID: 53404
          Assignee: dev@poi.apache.org
           Summary: IllegalArgumentException: calculated end index is out
                    of allowable range when using HSSFWorkbook#write()
          Severity: critical
    Classification: Unclassified
          Reporter: ebridges@eqbridges.com
          Hardware: Macintosh
            Status: NEW
           Version: 3.8
         Component: HSSF
           Product: POI

Created attachment 28922
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28922&action=edit
example test program

When writing to a file using HSSFWorkbook.write() the write fails with the
below stack trace, and wipes out any data existing in the file.

This functionality was introduced in version 3.7b1, and has been confirmed to
exist in the most recent production version as well (v3.8).

I've attached a test program that reliably reproduces this.  To use it unzip
the attachment and review the README file.

-----------------------

Exception in thread "main" java.lang.IllegalArgumentException: calculated end
index (29228) is out of allowable range (29224..29226)
    at
org.apache.poi.util.LittleEndianByteArrayOutputStream.<init>(LittleEndianByteArrayOutputStream.java:41)
    at
org.apache.poi.hssf.record.StandardRecord.serialize(StandardRecord.java:38)
    at
org.apache.poi.hssf.usermodel.HSSFWorkbook$SheetRecordCollector.serialize(HSSFWorkbook.java:1215)
    at
org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:1261)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1160)
    at poifseditor.PoifsEditor.addSomeRows(PoifsEditor.java:45)
    at poifseditor.PoifsEditor.main(PoifsEditor.java:62)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

Edward Q. Bridges <eb...@eqbridges.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|Macintosh                   |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #7 from Yegor Kozlov <ye...@dinom.ru> ---
I don't see a bug here. POI-3.6 is more than 2 years old and many bugs have
been fixed since then. 

can you try a simple workaround: if poifs-writer fails with
IllegalArgumentException which indicates that the file was created by a old
version of POI then write it to a byte array and read back. Something like
this:

 wb = new HSSFWorkbook("created by POI-3.6.xls");
 try {
   // do stuff
 } catch (IllegalArgumentException e){

   ByteArrayOutputStream out = new ByteArrayOutputStream();
   wb.write(out);
   wb = new HSSFWorkbook(new ByteArrayOutputStream(out.toByteArray()));

   // do stuff
 }

Let us know if it worked for you.

Cheers,
Yegor

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #6 from Edward Q. Bridges <eb...@eqbridges.com> ---
FYI, using the attached test harness it's easy to swap versions by changing the
version numbers in poifs-writer/pom.xml and poifs-editor/pom.xml and then
running 'mvn -U clean package'  before running 'runTest.sh'

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
                 OS|                            |All

--- Comment #1 from Nick Burch <ni...@alfresco.com> ---
Can you narrow down which record is triggering the problem? Does the file pass
the Microsoft Binary File Format Validator before being loaded in POI?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #8 from Edward Q. Bridges <eb...@eqbridges.com> ---
i've been able to address the issue with what you describe (n.b.: with a fix
for the typo to use ByteArrayInputStream as an argument to the HSSFWorksheet
ctor).

is there a more reliable way to determine the version other than by exception
handling?  e.g. is there a metadata property somewhere that would reflect this?

i've toyed with the idea of using getImplementationVersion() (as the test
program uses for printing)...

all this said, i'm surprised by the reluctance to try to address this issue. 
as it happens we have several thousand legacy spreadsheets in pre-3.6 format. 
can you be more specific why it won't be fixed?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #2 from Edward Q. Bridges <eb...@eqbridges.com> ---
I don't have access to a Windows machine currently to run the Microsoft Binary
File Format Validator.  I've attached a copy of the excel file that is
generated, so perhaps someone who is capable of running the validator can do
so.

I did not try to narrow down to which record is causing it because all of the
records are identical -- they are all inserted by the "poifs-writer" module in
the attached test harness.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #12 from Yegor Kozlov <ye...@dinom.ru> ---
Should be fixed in r1402186. Please try with the latest build from trunk.

Yegor

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #10 from Edward Q. Bridges <eb...@eqbridges.com> ---
Is this still expected to be released in late 2012?  If so, what's the target
milestone for it?  Thanks

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #11 from Yegor Kozlov <ye...@dinom.ru> ---
This bug is open which means we plan to address it in the future. 

POI is a volunteer project. If this bug is important for you, please do work on
it and submit a patch. Otherwise please wait. 

We plan to release POI-3.9 in late 2012, hope this problem will be fixed by
then.

Yegor

(In reply to comment #10)
> Is this still expected to be released in late 2012?  If so, what's the
> target milestone for it?  Thanks

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #4 from Yegor Kozlov <ye...@dinom.ru> ---
Just to make it clear:

 POI-3.6 (write) + POI-3.6 (edit) is success.

 POI-3.6 (write) + POI-3.7-beta1 (edit) fails. 

what is the result of using POI-3.8 (write) + POI-3.8 (edit) ?  

POI-3.6 (write) + POI-3.8 (edit) ?

Yegor

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #3 from Edward Q. Bridges <eb...@eqbridges.com> ---
Created attachment 28933
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28933&action=edit
sample source xls file.

this sample file was generated by the poifs-writer module of the attached test
program.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #14 from Yegor Kozlov <ye...@dinom.ru> ---
Yes, the fix will be included in POI-3.9. I plan to roll it some time Dec 2012.

(In reply to comment #13)
> Thanks much.  Will this be going out with the next release?  Or will it need
> to be scheduled?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #5 from Edward Q. Bridges <eb...@eqbridges.com> ---
POI-3.6 (write) + POI-3.6 (edit) is success.

--> confirmed success

POI-3.6 (write) + POI-3.7-beta1 (edit) fails. 

--> confirmed fails

POI-3.8 (write) + POI-3.8 (edit)

--> confirmed successful

POI-3.6 (write) + POI-3.8 (edit)

--> confirmed fails

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |---

--- Comment #9 from Yegor Kozlov <ye...@dinom.ru> ---
(In reply to comment #8)
> i've been able to address the issue with what you describe (n.b.: with a fix
> for the typo to use ByteArrayInputStream as an argument to the HSSFWorksheet
> ctor).
> 
> is there a more reliable way to determine the version other than by
> exception handling?  e.g. is there a metadata property somewhere that would
> reflect this?
> 

No, HSSF does not write version info in the output.

> i've toyed with the idea of using getImplementationVersion() (as the test
> program uses for printing)...
> 
> all this said, i'm surprised by the reluctance to try to address this issue.
> as it happens we have several thousand legacy spreadsheets in pre-3.6
> format.  can you be more specific why it won't be fixed?

It wasn't clear that you have several thousand legacy spreadsheets in pre-3.6
format. I thought tha tall you need is to upgrade both writer and editor parts
to the latest and greatest POI-3.8. 

I re-opened the bug. Hope to have it fixed by POI-3.9 (late 2012). 

Yegor

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53404] IllegalArgumentException: calculated end index is out of allowable range when using HSSFWorkbook#write()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53404

--- Comment #13 from Edward Q. Bridges <eb...@eqbridges.com> ---
Thanks much.  Will this be going out with the next release?  Or will it need to
be scheduled?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org