]> source.dussan.org Git - poi.git/commitdiff
Try to adjust for strange null-message for ArrayIndexOutOfBoundsException
authorDominik Stadler <centic@apache.org>
Wed, 9 Aug 2023 09:53:54 +0000 (09:53 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 9 Aug 2023 09:53:54 +0000 (09:53 +0000)
Some CI runs seem to throw the exception with an empty message instead of
the expected text.

I could not reproduce this consistently and so we only can disable a
check in this case.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911572 13f79535-47bb-0310-9956-ffa450edef68

poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
test-data/spreadsheet/stress.xls

index b636459146c435f788e30924061d4e6644da231b..3972a8671be17a5bfa6b51c4b29249a5e68b9b1e 100644 (file)
@@ -265,14 +265,19 @@ public class TestAllFiles {
             // it sometimes has a message and sometimes not!
             if (NullPointerException.class.isAssignableFrom(exClass)) {
                 if (actMsg != null) {
-                    assertTrue(actMsg.contains(exMessage), errPrefix + "Message: "+actMsg+" - didn't contain: "+exMessage);
+                    assertTrue(actMsg.contains(exMessage), errPrefix + "Message: " + actMsg + " - didn't contain: " + exMessage);
                 }
             } else {
                 // verify that message is either null for both or set for both
                 assertTrue(actMsg != null || isBlank(exMessage),
-                        errPrefix + " for " + exClass + " expected message '" + exMessage + "' but had '" + actMsg + "'");
-
-                if (actMsg != null) {
+                        errPrefix + " for " + exClass + " expected message '" + exMessage + "' but had '" + actMsg + "': " + e);
+
+                if (actMsg != null &&
+                        // sometimes ArrayIndexOutOfBoundsException has null-message?!?
+                        // so skip the check for this type of exception if expected message is null
+                        (exMessage != null || !ArrayIndexOutOfBoundsException.class.isAssignableFrom(exClass))) {
+                    assertNotNull(exMessage,
+                            errPrefix + "Expected message was null, but actMsg wasn't: Message: " + actMsg + ": " + e);
                     assertTrue(actMsg.contains(exMessage),
                             errPrefix + "Message: " + actMsg + " - didn't contain: " + exMessage);
                 }
index f792d02ef355458bd06c866ebfdbe225c74686b1..76b80d3e770ee7d1f6981b1054b66c88caea02a9 100644 (file)
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ