From 5382a907333e9332b3eee2c16b1369b3b9ede208 Mon Sep 17 00:00:00 2001 From: Alexander Partsch Date: Mon, 24 Jan 2022 17:40:58 +0100 Subject: [PATCH] Fix NPE on Optional.orElseThrow in reading Placeholders in ExcelGenerator --- build.gradle | 2 +- .../jocument/impl/excel/implementations/ExcelGenerator.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index ecbd3975..8ff92ecb 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group 'com.docutools' -version = '1.3.1' +version = '1.3.2' sourceCompatibility = 17 targetCompatibility = 17 diff --git a/src/main/java/com/docutools/jocument/impl/excel/implementations/ExcelGenerator.java b/src/main/java/com/docutools/jocument/impl/excel/implementations/ExcelGenerator.java index cc540f01..797dd770 100644 --- a/src/main/java/com/docutools/jocument/impl/excel/implementations/ExcelGenerator.java +++ b/src/main/java/com/docutools/jocument/impl/excel/implementations/ExcelGenerator.java @@ -4,6 +4,7 @@ import com.docutools.jocument.PlaceholderResolver; import com.docutools.jocument.PlaceholderType; import com.docutools.jocument.impl.ParsingUtils; +import com.docutools.jocument.impl.ScalarPlaceholderData; import com.docutools.jocument.impl.excel.interfaces.ExcelWriter; import com.docutools.jocument.impl.excel.util.ExcelUtils; import com.google.common.collect.Lists; @@ -73,7 +74,8 @@ private void generate() { if (ExcelUtils.isSimpleCell(cell)) { excelWriter.addCell(cell); } else { - var newCellText = resolver.resolve(ExcelUtils.getPlaceholder(cell)).orElseThrow(); + var newCellText = resolver.resolve(ExcelUtils.getPlaceholder(cell)) + .orElse(new ScalarPlaceholderData("-")); excelWriter.addCell(cell, newCellText.toString()); } }