From 0f7e9533842c19dcb8f967f45edef31799549097 Mon Sep 17 00:00:00 2001 From: Jordan Padams Date: Thu, 1 Dec 2022 09:19:45 -0800 Subject: [PATCH] Update open/close of object reader Previous functionality opened and closed the reader within a recursive method. Moved thie open/close up a level in execution. Resolves #564 --- .../content/array/ArrayContentValidator.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/gov/nasa/pds/tools/validate/content/array/ArrayContentValidator.java b/src/main/java/gov/nasa/pds/tools/validate/content/array/ArrayContentValidator.java index 8fdc57055..aad437edf 100644 --- a/src/main/java/gov/nasa/pds/tools/validate/content/array/ArrayContentValidator.java +++ b/src/main/java/gov/nasa/pds/tools/validate/content/array/ArrayContentValidator.java @@ -119,6 +119,7 @@ public void validate(ArrayObject arrayObject) { LOG.debug("validate:tableNameReportStr {}", tableNameReportStr); try { + arrayObject.open(); process(array, arrayObject, dimensions, new int[dimensions.length], 0, dimensions.length - 1); } catch (Exception e) { @@ -141,7 +142,6 @@ private void process(Array array, ArrayObject arrayObject, int[] dimensions, int System.out.print("."); } - arrayObject.open(); for (int i = 0; i < dimensions[depth];) { if (depth < maxDepth) { // max depth not reached, do another recursion position[depth] = i; @@ -162,7 +162,6 @@ private void process(Array array, ArrayObject arrayObject, int[] dimensions, int } } } - arrayObject.close(); } private void validatePosition(Array array, ArrayObject arrayObject, ArrayLocation location, @@ -260,10 +259,11 @@ private void validatePosition(Array array, ArrayObject arrayObject, ArrayLocatio loc = loc.replaceAll("\\]", ""); } - // #544: @jpl-jengelke reports that validate used to produce a detailed error message but now just - // says `null`. @jordanpadams says the calculation is no longer completed by the software and didn't - // make sense, but that said, `null` is not intuitive. - String message = "Error occurred while trying to " + "read data at location " + loc + ". Verify possible mismatch in file size and expected array size."; + // #544: @jpl-jengelke reports that validate used to produce a detailed error message but now + // just says `null`. @jordanpadams says the calculation is no longer completed by the software + // and didn't make sense, but that said, `null` is not intuitive. + String message = "Error occurred while trying to " + "read data at location " + loc + + ". Verify possible mismatch in data type and/or file size versus array size."; if (ee.getMessage() != null) message += ": " + ee.getMessage(); throw new IOException(message);