Skip to content

Commit 797bb0e

Browse files
Add code to prevent possible NullPointerException in 'findDataPids' method, and update error message in 'runSuite' method to include more details
1 parent fd52603 commit 797bb0e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/edu/ucsb/nceas/mdqengine/MDQEngine.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public Run runSuite(Suite suite, InputStream input, Map<String, Object> params,
115115
dataPids = findDataPids(nodeId, sysMeta.getIdentifier().getValue());
116116
} catch (MetadigException e) {
117117
log.error("Could not retrieve data objects for pid:" + sysMeta.getIdentifier().getValue() + ", node:"
118-
+ nodeId.getValue());
118+
+ nodeId.getValue() + ". Additional information: " + e.getMessage());
119119
}
120120
params.put("dataPids", dataPids);
121121

@@ -293,6 +293,9 @@ public ArrayList<String> findDataPids(NodeReference nodeId, String identifier) t
293293
doc.getDocumentElement().normalize();
294294

295295
NodeList nodeList = doc.getElementsByTagName("str");
296+
if (nodeList == null) {
297+
throw new MetadigException("Unable to retrieve data objects, nodeList is null.");
298+
}
296299
for (int i = 0; i < nodeList.getLength(); i++) {
297300
Element element = (Element) nodeList.item(i);
298301
if ("id".equals(element.getAttribute("name"))) {

0 commit comments

Comments
 (0)