https://bz.apache.org/bugzilla/show_bug.cgi?id=59048

            Bug ID: 59048
           Summary: ClassCastException when opening Excelfile in Android 5
                    with POI 3.13/3.14
           Product: POI
           Version: 3.13-FINAL
          Hardware: Other
                OS: other
            Status: NEW
          Severity: major
          Priority: P2
         Component: SS Common
          Assignee: [email protected]
          Reporter: [email protected]

POI version 3.12 works OK. 
But 3.13 and 3.14-beta1 gives the same failure

java.lang.ClassCastException:
org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream cannot be cast
to java.util.zip.ZipFile$RAFStream


---- 
The error occurs every time we try to open simple excel files (xlsx, created
with MS Excel)
The app runs on Android 5.1.1, Samsung Galaxy Note (SM-P605).
Developed with Android Studio 2.0, beta 5, targetSdkVersion 22, minSdkVersion
21.

It is a little bit tricky to get POI to run on Android since Android lacks the
package javax.xml.stream/**
The following project is very similar to how we have succeeded.
https://github.com/andruhon/android5xlsx


We have been using POI 3.11 with the same excel files for a while on Android 4
as well without problems.
----
The class org.apache.poi.openxml4j.util.ZipSecureFile seems to have been
introduced for bugfix 50090 - 'zip' bomb prevention.
---
The row number mentioned in the Android Studio logcat window, does not seem to
indicate correct line numbers in ZipSecureFile.java compared to 
https://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/util/ZipSecureFile.java?view=markup&pathrev=1687148

It's in a read statement that the exception occurs, but the latest test (with
POI 3.14-beta1 indicates ZipSecureFile.java:208 and earlier tests with 3.13
indicates ZipSecureFile.java:162. 
See the logs below.


/Mats

----
Logs (when testing with POI version 3.14-beta1)
java.lang.RuntimeException: An error occured while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:304)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:818)
 Caused by: java.lang.ClassCastException:
org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream cannot be cast
to java.util.zip.ZipFile$RAFStream
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:191)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:153)
    at java.util.zip.ZipFile$ZipInflaterInputStream.read(ZipFile.java:538)
    at libcore.io.Streams.readSingleByte(Streams.java:41)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:130)
    at
org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.read(ZipSecureFile.java:208)
    at org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1642)
    at
org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:111)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:107)
    at org.apache.poi.util.DocumentHelper.readDocument(DocumentHelper.java:96)
    at
org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:377)
    at
org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:103)
    at
org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.<init>(ZipContentTypeManager.java:54)
    at
org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:190)
    at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:696)
    at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:259)
    at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:284)
    at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:252)
    at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:231)

-----
Logs with POI 3.13.
  java.lang.RuntimeException: An error occured while executing doInBackground()
      at android.os.AsyncTask$3.done(AsyncTask.java:304)
      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
      at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
      at java.util.concurrent.FutureTask.run(FutureTask.java:242)
      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
      at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
      at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
      at java.lang.Thread.run(Thread.java:818)
   Caused by: java.lang.ClassCastException:
org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream cannot be cast
to java.util.zip.ZipFile$RAFStream
      at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:191)
      at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:153)
      at java.util.zip.ZipFile$ZipInflaterInputStream.read(ZipFile.java:538)
      at libcore.io.Streams.readSingleByte(Streams.java:41)
      at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:130)
      at
org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.read(ZipSecureFile.java:162)
      at org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1642)
      at
org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:111)
      at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:107)
      at
org.apache.poi.util.DocumentHelper.readDocument(DocumentHelper.java:96)
      at
org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:377)
      at
org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:103)
      at
org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.<init>(ZipContentTypeManager.java:54)
      at
org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:190)
      at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:684)
      at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:254)
      at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:282)
      at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:250)
      at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:229)

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to