We try to avoid throwing NullPointerException, but it was possible to trigger one here git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912281 13f79535-47bb-0310-9956-ffa450edef68tags/REL_5_2_4
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); | XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); | ||||
xmlOptions.setSaveSyntheticDocumentElement( | xmlOptions.setSaveSyntheticDocumentElement( | ||||
new QName(CTChartsheet.type.getName().getNamespaceURI(), "chartsheet")); | new QName(CTChartsheet.type.getName().getNamespaceURI(), "chartsheet")); | ||||
chartsheet.save(out, xmlOptions); | |||||
if (chartsheet != null) { | |||||
chartsheet.save(out, xmlOptions); | |||||
} | |||||
} | } | ||||
private static byte[] blankWorksheet(){ | private static byte[] blankWorksheet(){ |
return false; | return false; | ||||
} | } | ||||
} | } | ||||
@Test | |||||
void testEncryptionNullPointerException() throws IOException { | |||||
assertThrows(IllegalArgumentException.class, | |||||
() -> WorkbookFactory.create(POIDataSamples.getSpreadSheetInstance(). | |||||
openResourceAsStream( | |||||
"crash-9bf3cd4bd6f50a8a9339d363c2c7af14b536865c.xlsx"))); | |||||
} | |||||
} | } |
if (cipherAlgorithm == CipherAlgorithm.rc4) { | if (cipherAlgorithm == CipherAlgorithm.rc4) { | ||||
cipher = Cipher.getInstance(cipherAlgorithm.jceId); | cipher = Cipher.getInstance(cipherAlgorithm.jceId); | ||||
} else if (cipherAlgorithm.needsBouncyCastle) { | } else if (cipherAlgorithm.needsBouncyCastle) { | ||||
if (chain == null) { | |||||
throw new IllegalArgumentException("Did not have a chain for cipher " + cipherAlgorithm); | |||||
} | |||||
registerBouncyCastle(); | registerBouncyCastle(); | ||||
cipher = Cipher.getInstance(cipherAlgorithm.jceId + "/" + chain.jceId + "/" + padding, "BC"); | cipher = Cipher.getInstance(cipherAlgorithm.jceId + "/" + chain.jceId + "/" + padding, "BC"); | ||||
} else { | } else { | ||||
if (chain == null) { | |||||
throw new IllegalArgumentException("Did not have a chain for cipher " + cipherAlgorithm); | |||||
} | |||||
cipher = Cipher.getInstance(cipherAlgorithm.jceId + "/" + chain.jceId + "/" + padding); | cipher = Cipher.getInstance(cipherAlgorithm.jceId + "/" + chain.jceId + "/" + padding); | ||||
} | } | ||||