From b55caf5bc02207e06fc3ef5ce01d4902f0f0df45 Mon Sep 17 00:00:00 2001 From: Jabe03 Date: Fri, 7 Nov 2025 10:01:16 -0600 Subject: [PATCH 1/4] Parsing errors now are handled within initialize. Simplifed error handling when calling Kind 2 --- .../edu/uiowa/cs/clc/kind2/api/Kind2Api.java | 35 +++++++------------ .../uiowa/cs/clc/kind2/results/Result.java | 6 +++- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java index 5099e7f..bd39752 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java @@ -345,7 +345,6 @@ private void callKind2(String program, Result result, IProgressMonitor monitor) debug.println("Kind 2 command: " + ApiUtil.getQuotedCommand(builder.command())); Process process = null; String output = ""; - boolean exceptionThrown = false; try { process = builder.start(); @@ -359,30 +358,20 @@ private void callKind2(String program, Result result, IProgressMonitor monitor) output += new String(bytes); sleep(POLL_INTERVAL); } - } catch (Throwable t) { - exceptionThrown = true; - throw t; + if (!monitor.isCanceled()) { + int available = process.getInputStream().available(); + byte[] bytes = new byte[available]; + process.getInputStream().read(bytes); + output += new String(bytes); + result.initialize(output); + } + } catch (IOException | IllegalStateException e) { + throw e; } finally { - try { - if (!monitor.isCanceled()) { - int available = process.getInputStream().available(); - byte[] bytes = new byte[available]; - process.getInputStream().read(bytes); - output += new String(bytes); - try { - result.initialize(output); - } catch (Throwable t) { - if (!exceptionThrown) { - throw t; - } - } - } - } finally { - if (process != null) { - process.destroy(); - } - monitor.done(); + if (process != null) { + process.destroy(); } + monitor.done(); } } diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java b/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java index 1e3069a..04df186 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java @@ -297,7 +297,11 @@ public void initialize(String json) { // build the node tree this.buildTree(); // analyze the result - this.analyze(); + try { + this.analyze(); + } catch (RuntimeException e) { + // Do nothing, just leave info in result + } isInitialized = true; } From c7cf27a926eea7d74f6e2da76fdb1f612244fb6d Mon Sep 17 00:00:00 2001 From: Jabe03 Date: Fri, 7 Nov 2025 13:09:37 -0600 Subject: [PATCH 2/4] Removed exception throwing in analyze --- src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java | 2 -- src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java index bd39752..6f1676d 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java @@ -365,8 +365,6 @@ private void callKind2(String program, Result result, IProgressMonitor monitor) output += new String(bytes); result.initialize(output); } - } catch (IOException | IllegalStateException e) { - throw e; } finally { if (process != null) { process.destroy(); diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java b/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java index 04df186..902042c 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java @@ -126,7 +126,6 @@ private void analyze() { if (root == null) { // if the root object is null at this point, then we couldn't parse the json output properly. // It makes sense to throw kind2 errors found in the log objects. - throwKind2Errors(); return; } root.analyze(); @@ -297,11 +296,7 @@ public void initialize(String json) { // build the node tree this.buildTree(); // analyze the result - try { - this.analyze(); - } catch (RuntimeException e) { - // Do nothing, just leave info in result - } + this.analyze(); isInitialized = true; } From 669be389480bb40f2bf7962a750fcc247f6e2ac9 Mon Sep 17 00:00:00 2001 From: Jabe03 Date: Fri, 7 Nov 2025 13:10:59 -0600 Subject: [PATCH 3/4] Removed code that now goes unused --- .../uiowa/cs/clc/kind2/results/Result.java | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java b/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java index 902042c..ba96447 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/results/Result.java @@ -131,25 +131,6 @@ private void analyze() { root.analyze(); } - /** - * throw a {@link RuntimeException} if at least one of kind2 logs is error, fatal, or off. - */ - private void throwKind2Errors() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder - .append("An error has occurred during kind2 analysis. Please check the following logs:\n"); - boolean someError = false; - for (Log log : kind2Logs) { - if (log.getLevel() == LogLevel.error || log.getLevel() == LogLevel.fatal - || log.getLevel() == LogLevel.off) { - stringBuilder.append(log + "\n"); - someError = true; - } - } - if (someError) { - throw new RuntimeException(stringBuilder.toString()); - } - } @Override public String toString() { From fa8a454f84dcafce44b64fbc1173c20237170904 Mon Sep 17 00:00:00 2001 From: Jabe03 Date: Wed, 12 Nov 2025 11:45:32 -0600 Subject: [PATCH 4/4] Revert back to old logic in callKind2 --- .../edu/uiowa/cs/clc/kind2/api/Kind2Api.java | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java index 6f1676d..5099e7f 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java @@ -345,6 +345,7 @@ private void callKind2(String program, Result result, IProgressMonitor monitor) debug.println("Kind 2 command: " + ApiUtil.getQuotedCommand(builder.command())); Process process = null; String output = ""; + boolean exceptionThrown = false; try { process = builder.start(); @@ -358,18 +359,30 @@ private void callKind2(String program, Result result, IProgressMonitor monitor) output += new String(bytes); sleep(POLL_INTERVAL); } - if (!monitor.isCanceled()) { - int available = process.getInputStream().available(); - byte[] bytes = new byte[available]; - process.getInputStream().read(bytes); - output += new String(bytes); - result.initialize(output); - } + } catch (Throwable t) { + exceptionThrown = true; + throw t; } finally { - if (process != null) { - process.destroy(); + try { + if (!monitor.isCanceled()) { + int available = process.getInputStream().available(); + byte[] bytes = new byte[available]; + process.getInputStream().read(bytes); + output += new String(bytes); + try { + result.initialize(output); + } catch (Throwable t) { + if (!exceptionThrown) { + throw t; + } + } + } + } finally { + if (process != null) { + process.destroy(); + } + monitor.done(); } - monitor.done(); } }