]> source.dussan.org Git - poi.git/commitdiff
bug 59858: describe why VBA macro reading failed
authorJaven O'Neal <onealj@apache.org>
Fri, 15 Jul 2016 06:12:37 +0000 (06:12 +0000)
committerJaven O'Neal <onealj@apache.org>
Fri, 15 Jul 2016 06:12:37 +0000 (06:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1752778 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java

index b221d3e39f47c35291ca3560ff11718e956b662c..66ebab97dce4d1212a880ca7e065aa7eae4e500b 100644 (file)
@@ -218,6 +218,10 @@ public class VBAMacroReader implements Closeable {
             modules.put(name, module);
             module.read(dis);
         } else {
+            if (module.offset == null) {
+                //This should not happen. bug 59858
+                throw new IOException("Module offset for '" + name + "' was never read.");
+            }
             // we know the offset already, so decompress immediately on-the-fly
             long skippedBytes = dis.skip(module.offset);
             if (skippedBytes != module.offset) {
index 6d2e9fe40d9f0a1f3f41e8438507e0a3b088bb0e..2d98a4f38da8e174798f65e335f8fecfb153d3a4 100644 (file)
@@ -269,10 +269,15 @@ public class TestVBAMacroReader {
         try {
             fromFile(POIDataSamples.getSpreadSheetInstance(), "59858.xls");
             fail("This test passes now. Please update the unit test and bug 59858.");
-        } catch (NullPointerException e) {
-            e.printStackTrace();
-            // NPE when reading module.offset in VBAMacroReader.readMacros (approx line 258)
-            assumeTrue("This test currently fails with an NPE. See stdout.", false);
+        } catch (IOException e) {
+            if (e.getMessage().matches("Module offset for '.+' was never read.")) {
+                //e.printStackTrace();
+                // NPE when reading module.offset in VBAMacroReader.readMacros (approx line 258)
+                assumeTrue("This test currently fails. See stdout.", false);
+            } else {
+                // something unexpected failed
+                throw e;
+            }
         }
     }
 }