From 81ffc29bc667eb3f0eb1c9c72604d222ec007468 Mon Sep 17 00:00:00 2001 From: Nathan Glenn Date: Wed, 21 Aug 2024 14:44:56 -0500 Subject: [PATCH] Skip (and warn for) blank lines in comments.dm The THOR-Soar project was failing to load because the comments.dm has blank lines, and those caused exceptions during loading (because `line.charAt(0)` was always out of bounds). After removing the blank lines, the comments appeared to be on the correct nodes, so we'll just ignore them. I do not know how the blank lines showed up in the file, but I find it very worrisome. --- .../visualsoar/datamap/SoarWorkingMemoryReader.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/umich/soar/visualsoar/datamap/SoarWorkingMemoryReader.java b/src/main/java/edu/umich/soar/visualsoar/datamap/SoarWorkingMemoryReader.java index 578c13d..c85854c 100644 --- a/src/main/java/edu/umich/soar/visualsoar/datamap/SoarWorkingMemoryReader.java +++ b/src/main/java/edu/umich/soar/visualsoar/datamap/SoarWorkingMemoryReader.java @@ -435,12 +435,20 @@ public static boolean readSafe(SoarWorkingMemoryModel swmm, Reader fr, Reader cr } } - //If the comment file exists, read in all its comments + // If the comment file exists, read in all its comments Vector commentVec = new Vector<>(); if (cr != null) { Scanner scanCR = new Scanner(cr); + int lineNum = 0; while (scanCR.hasNextLine()) { - commentVec.add(scanCR.nextLine()); + lineNum++; + String line = scanCR.nextLine(); + if (line.isEmpty()) { + errors.add( + new FeedbackListEntry("Warning: ignoring blank line at comment.dm line " + lineNum)); + continue; + } + commentVec.add(line); } }