diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java index 9f6ebe65a6..73dec957ed 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java @@ -194,7 +194,8 @@ public final class PackageRelationshipCollection implements */ public void addRelationship(PackageRelationship relPart) { if (relPart == null || relPart.getId() == null || relPart.getId().isEmpty()) { - throw new IllegalArgumentException("invalid relationship part/id"); + throw new IllegalArgumentException("invalid relationship part/id: " + + (relPart == null ? "" : relPart.getId()) + " for relationship: " + relPart); } relationshipsByID.put(relPart.getId(), relPart); relationshipsByType.put(relPart.getRelationshipType(), relPart); @@ -216,7 +217,7 @@ public final class PackageRelationshipCollection implements */ public PackageRelationship addRelationship(URI targetUri, TargetMode targetMode, String relationshipType, String id) { - if (id == null) { + if (id == null || id.length() == 0) { // Generate a unique ID is id parameter is null. if (nextRelationshipId == -1) { nextRelationshipId = size() + 1; @@ -354,8 +355,7 @@ public final class PackageRelationshipCollection implements addRelationship(target, targetMode, type, id); } } catch (Exception e) { - logger.log(POILogger.ERROR, e); - throw new InvalidFormatException(e.getMessage()); + throw new InvalidFormatException("Failed to parse relationships", e); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index a50d1832b7..7f17019844 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -3660,4 +3660,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals(1, sheet.getDataValidations().size()); } } + + @Test + public void test64450() throws IOException { + try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("64450.xlsx")) { + assertNotNull(wb); + } + } } diff --git a/test-data/spreadsheet/64450.xlsx b/test-data/spreadsheet/64450.xlsx new file mode 100644 index 0000000000..f96b179412 Binary files /dev/null and b/test-data/spreadsheet/64450.xlsx differ