From 6ba8804683a0dee27aa686c2cf42a80020012fdc Mon Sep 17 00:00:00 2001 From: mherman22 Date: Tue, 2 Jan 2024 22:11:55 +0300 Subject: [PATCH 1/2] Fix NPE on CohortReportFormController.onSubmit --- .../web/controller/report/CohortReportFormController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/omod/src/main/java/org/openmrs/web/controller/report/CohortReportFormController.java b/omod/src/main/java/org/openmrs/web/controller/report/CohortReportFormController.java index b2445fd..cfbb427 100644 --- a/omod/src/main/java/org/openmrs/web/controller/report/CohortReportFormController.java +++ b/omod/src/main/java/org/openmrs/web/controller/report/CohortReportFormController.java @@ -315,6 +315,11 @@ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse Document xml = db.parse(new InputSource(new StringReader( "" + data))); Node node = findChild(xml, "reportSchema"); + + if(node == null) { + return null; + } + node = findChild(node, "dataSets"); Element dsd = xml.createElement("dataSetDefinition"); dsd.setAttribute("name", "cohorts"); From 6abba191a2f30b1dc85c4e1b171e68b5cb57091d Mon Sep 17 00:00:00 2001 From: mherman22 Date: Wed, 3 Jan 2024 09:12:47 +0300 Subject: [PATCH 2/2] conform to conventions --- .../web/controller/report/CohortReportFormController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/omod/src/main/java/org/openmrs/web/controller/report/CohortReportFormController.java b/omod/src/main/java/org/openmrs/web/controller/report/CohortReportFormController.java index cfbb427..bb38e83 100644 --- a/omod/src/main/java/org/openmrs/web/controller/report/CohortReportFormController.java +++ b/omod/src/main/java/org/openmrs/web/controller/report/CohortReportFormController.java @@ -316,8 +316,8 @@ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse "" + data))); Node node = findChild(xml, "reportSchema"); - if(node == null) { - return null; + if (node == null) { + return null; } node = findChild(node, "dataSets");