mirror of https://github.com/apache/poi.git
[bug-65741] issue with null date values causing npes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895877 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e5722ef4e2
commit
bbef66dee3
|
@ -428,10 +428,12 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCreatedProperty(String created) {
|
public void setCreatedProperty(String created) {
|
||||||
try {
|
if (created != null) {
|
||||||
this.created = setDateValue(created);
|
try {
|
||||||
} catch (InvalidFormatException e) {
|
this.created = setDateValue(created);
|
||||||
throw new IllegalArgumentException("Date for created could not be parsed: " + created, e);
|
} catch (InvalidFormatException e) {
|
||||||
|
throw new IllegalArgumentException("Date for created could not be parsed: " + created, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,11 +552,13 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setLastPrintedProperty(String lastPrinted) {
|
public void setLastPrintedProperty(String lastPrinted) {
|
||||||
try {
|
if (lastPrinted != null) {
|
||||||
this.lastPrinted = setDateValue(lastPrinted);
|
try {
|
||||||
} catch (InvalidFormatException e) {
|
this.lastPrinted = setDateValue(lastPrinted);
|
||||||
throw new IllegalArgumentException("lastPrinted : "
|
} catch (InvalidFormatException e) {
|
||||||
+ e.getLocalizedMessage(), e);
|
throw new IllegalArgumentException("lastPrinted : "
|
||||||
|
+ e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,11 +579,13 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModifiedProperty(String modified) {
|
public void setModifiedProperty(String modified) {
|
||||||
try {
|
if (modified != null) {
|
||||||
this.modified = setDateValue(modified);
|
try {
|
||||||
} catch (InvalidFormatException e) {
|
this.modified = setDateValue(modified);
|
||||||
throw new IllegalArgumentException("modified : "
|
} catch (InvalidFormatException e) {
|
||||||
+ e.getLocalizedMessage(), e);
|
throw new IllegalArgumentException("modified : "
|
||||||
|
+ e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,7 +676,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
|
||||||
* Convert a string value represented a date into a {@code Optional<Date>}
|
* Convert a string value represented a date into a {@code Optional<Date>}
|
||||||
*
|
*
|
||||||
* @throws InvalidFormatException
|
* @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 {
|
private Optional<Date> setDateValue(String dateStr) throws InvalidFormatException {
|
||||||
if (dateStr == null || dateStr.isEmpty()) {
|
if (dateStr == null || dateStr.isEmpty()) {
|
||||||
|
|
Loading…
Reference in New Issue