This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6473bad372 Fixed: Survey PDF services throw a NullPointerException
when contentId matches no Content (OFBIZ-13692)
6473bad372 is described below
commit 6473bad3725e7d93c01c0d6d398530f4c80d5569
Author: Mridul Pathak <[email protected]>
AuthorDate: Fri Oct 16 19:06:21 2026 +0530
Fixed: Survey PDF services throw a NullPointerException when contentId
matches no Content (OFBIZ-13692)
PdfSurveyServices.getInputByteBuffer now returns no input when the
contentId matches no Content, or a Content without a DataResource, so the
survey PDF services return the "No PDF was given." error instead of failing
with a NullPointerException or an unexpected exception.
---
.../org/apache/ofbiz/content/survey/PdfSurveyServices.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git
a/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java
b/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java
index f4378927e2..9cca9fe0b1 100644
---
a/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java
+++
b/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java
@@ -525,8 +525,11 @@ public class PdfSurveyServices {
String webSiteId = (String) context.get("webSiteId");
String rootDir = (String) context.get("rootDir");
GenericValue content =
EntityQuery.use(delegator).from("Content").where("contentId",
contentId).cache().queryOne();
- String dataResourceId =
content.getString("dataResourceId");
- inputByteBuffer =
DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https,
webSiteId, locale, rootDir);
+ String dataResourceId = content != null ?
content.getString("dataResourceId") : null;
+ if (UtilValidate.isNotEmpty(dataResourceId)) {
+ inputByteBuffer =
DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https,
webSiteId, locale,
+ rootDir);
+ }
} catch (GenericEntityException | IOException e) {
throw(new GeneralException(e.getMessage()));
}
@@ -536,7 +539,8 @@ public class PdfSurveyServices {
}
/**
- * @return the PDF given by the inputByteBuffer or contentId parameter,
null if none of them is given
+ * @return the PDF given by the inputByteBuffer or contentId parameter,
null if none of them is given or the contentId
+ * matches no Content with a DataResource
*/
private static PDDocument loadInputPdf(Map<String, ? extends Object>
context, Delegator delegator) throws GeneralException, IOException {
ByteBuffer inputByteBuffer = getInputByteBuffer(context, delegator);