poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1857067 - in /poi/trunk/src: java/org/apache/poi/ss/usermodel/WorkbookFactory.java ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java
Date Sun, 07 Apr 2019 07:17:41 GMT
Author: centic
Date: Sun Apr  7 07:17:41 2019
New Revision: 1857067

URL: http://svn.apache.org/viewvc?rev=1857067&view=rev
Log:
Improve error message slightly and verify error when a File is passed in
as "Object"

Modified:
    poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java?rev=1857067&r1=1857066&r2=1857067&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java Sun Apr  7 07:17:41
2019
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.Arrays;
 
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.OldFileFormatException;
@@ -351,8 +352,8 @@ public class WorkbookFactory {
                 throw new IOException(t.getMessage(), t);
             }
         } catch (Exception e) {
-            throw new IOException(e);
+            throw new IOException("While trying to invoke 'createWorkbook' on factory " +
factoryClass +
+                    " and arguments " + Arrays.toString(args), e);
         }
     }
-
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java?rev=1857067&r1=1857066&r2=1857067&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java Sun Apr  7 07:17:41
2019
@@ -420,6 +420,16 @@ public final class TestWorkbookFactory {
         assertNotNull(wb);
         assertTrue(wb instanceof XSSFWorkbook);
         closeOrRevert(wb);
+
+        // check what happens if the file is passed as "Object"
+
+        try {
+            //noinspection deprecation
+            WorkbookFactory.create((Object)altXLSX);
+            fail("Will throw an exception");
+        } catch(IOException e) {
+            // expected here because create() in this case expects an object of type "OPCPackage"
+        }
     }
     
     private static class TestFile extends File {



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


Mime
View raw message