From 1940ba2b248b58466a7fd0e993126b5f838dd35a Mon Sep 17 00:00:00 2001 From: Max Rohde <1448524+mxro@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:41:02 +1100 Subject: [PATCH] Fixing formatting and indentation --- .../nashornsandbox/internal/JsEvaluator.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/delight/nashornsandbox/internal/JsEvaluator.java b/src/main/java/delight/nashornsandbox/internal/JsEvaluator.java index f65e7e1..f7576cb 100644 --- a/src/main/java/delight/nashornsandbox/internal/JsEvaluator.java +++ b/src/main/java/delight/nashornsandbox/internal/JsEvaluator.java @@ -6,10 +6,12 @@ /** * The JavaScript evaluator. It is designed to run Nashorn engine in separate - * thread (using provided {@link ExecutorService}), to allow limit cpu time - * consumed. + * thread (using provided {@link ExecutorService}), to allow limit cpu time + * consumed. * - *
Created on 2017.11.22
+ *+ * Created on 2017.11.22 + *
* * @author Marcin Golebski * @version $Id$ @@ -17,12 +19,13 @@ class JsEvaluator implements Runnable { private final ThreadMonitor threadMonitor; private final ScriptEngine scriptEngine; - + private Object result = null; private Exception exception = null; private final ScriptEngineOperation operation; - JsEvaluator(final ScriptEngine scriptEngine, final long maxCPUTime, final long maxMemory, ScriptEngineOperation operation) { + JsEvaluator(final ScriptEngine scriptEngine, final long maxCPUTime, final long maxMemory, + ScriptEngineOperation operation) { this.scriptEngine = scriptEngine; this.threadMonitor = new ThreadMonitor(maxCPUTime, maxMemory); this.operation = operation; @@ -35,18 +38,18 @@ boolean isScriptKilled() { boolean isCPULimitExceeded() { return threadMonitor.isCPULimitExceeded(); } - + boolean isMemoryLimitExceeded() { return threadMonitor.isMemoryLimitExceeded(); } /** - * Enter the monitor method. It should be called from main thread. + * Enter the monitor method. It should be called from main thread. */ void runMonitor() { threadMonitor.run(); } - + @Override public void run() { try { @@ -54,18 +57,15 @@ public void run() { if (registered) { result = operation.executeScriptEngineOperation(scriptEngine); } - } - catch (final RuntimeException e) { + } catch (final RuntimeException e) { // InterruptedException means script was successfully interrupted, // so no exception should be propagated - if(!(e.getCause() instanceof InterruptedException)) { + if (!(e.getCause() instanceof InterruptedException)) { exception = e; } - } - catch (final Exception e) { + } catch (final Exception e) { exception = e; - } - finally { + } finally { threadMonitor.scriptFinished(); threadMonitor.stopMonitor(); } @@ -74,7 +74,7 @@ public void run() { Exception getException() { return exception; } - + Object getResult() { return result; }