@@ -293,10 +293,19 @@ public Object run() {
293293 // NOTE: we truncate the stack because IndyInterface has security issue (needs getClassLoader)
294294 // we don't do a security check just as a tradeoff, it cannot really escalate to anything.
295295 return AccessController .doPrivileged ((PrivilegedAction <Object >) script ::run );
296- } catch (Exception e ) {
297- if (logger .isTraceEnabled ()) {
298- logger .trace ("failed to run {}" , e , compiledScript );
296+ } catch (AssertionError ae ) {
297+ // Groovy asserts are not java asserts, and cannot be disabled, so we do a best-effort trying to determine if this is a
298+ // Groovy assert (in which case we wrap it and throw), or a real Java assert, in which case we rethrow it as-is, likely
299+ // resulting in the uncaughtExceptionHandler handling it.
300+ final StackTraceElement [] elements = ae .getStackTrace ();
301+ if (elements .length > 0 && "org.codehaus.groovy.runtime.InvokerHelper" .equals (elements [0 ].getClassName ())) {
302+ logger .trace ("failed to run {}" , ae , compiledScript );
303+ throw new ScriptException ("Error evaluating " + compiledScript .name (),
304+ ae , emptyList (), "" , compiledScript .lang ());
299305 }
306+ throw ae ;
307+ } catch (Exception | NoClassDefFoundError e ) {
308+ logger .trace ("failed to run {}" , e , compiledScript );
300309 throw new ScriptException ("Error evaluating " + compiledScript .name (), e , emptyList (), "" , compiledScript .lang ());
301310 }
302311 }
0 commit comments