You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/12/13 12:23:14 UTC
svn commit: r1895877 - /poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
Author: fanningpj
Date: Mon Dec 13 12:23:13 2021
New Revision: 1895877
URL: http://svn.apache.org/viewvc?rev=1895877&view=rev
Log:
[bug-65741] issue with null date values causing npes
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java?rev=1895877&r1=1895876&r2=1895877&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java Mon Dec 13 12:23:13 2021
@@ -428,10 +428,12 @@ public final class PackagePropertiesPart
*/
@Override
public void setCreatedProperty(String created) {
- try {
- this.created = setDateValue(created);
- } catch (InvalidFormatException e) {
- throw new IllegalArgumentException("Date for created could not be parsed: " + created, e);
+ if (created != null) {
+ try {
+ this.created = setDateValue(created);
+ } catch (InvalidFormatException e) {
+ throw new IllegalArgumentException("Date for created could not be parsed: " + created, e);
+ }
}
}
@@ -550,11 +552,13 @@ public final class PackagePropertiesPart
*/
@Override
public void setLastPrintedProperty(String lastPrinted) {
- try {
- this.lastPrinted = setDateValue(lastPrinted);
- } catch (InvalidFormatException e) {
- throw new IllegalArgumentException("lastPrinted : "
- + e.getLocalizedMessage(), e);
+ if (lastPrinted != null) {
+ try {
+ this.lastPrinted = setDateValue(lastPrinted);
+ } catch (InvalidFormatException e) {
+ throw new IllegalArgumentException("lastPrinted : "
+ + e.getLocalizedMessage(), e);
+ }
}
}
@@ -575,11 +579,13 @@ public final class PackagePropertiesPart
*/
@Override
public void setModifiedProperty(String modified) {
- try {
- this.modified = setDateValue(modified);
- } catch (InvalidFormatException e) {
- throw new IllegalArgumentException("modified : "
- + e.getLocalizedMessage(), e);
+ if (modified != null) {
+ try {
+ this.modified = setDateValue(modified);
+ } catch (InvalidFormatException e) {
+ throw new IllegalArgumentException("modified : "
+ + e.getLocalizedMessage(), e);
+ }
}
}
@@ -670,7 +676,7 @@ public final class PackagePropertiesPart
* Convert a string value represented a date into a {@code Optional<Date>}
*
* @throws InvalidFormatException
- * Throws if the date format isnot valid.
+ * Throws if the date format is not valid.
*/
private Optional<Date> setDateValue(String dateStr) throws InvalidFormatException {
if (dateStr == null || dateStr.isEmpty()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org