OpenSearch/modules/lang-groovy
Lee Hinman aab8c1f032 Catch AssertionError and NoClassDefFoundError in groovy scripts
Previously, we only caught subclasses of Exception, however, there are
some cases when Errors are thrown instead of Exceptions. These two cases
are `assert` and when a class cannot be found.

Without this change, the exception would bubble up to the
`uncaughtExceptionHandler`, which would in turn, exit the JVM
(related: #19923).

A note of difference between regular Java asserts and Groovy asserts,
from http://docs.groovy-lang.org/docs/latest/html/documentation/core-testing-guide.html

"Another important difference from Java is that in Groovy assertions are
enabled by default. It has been a language design decision to remove the
possibility to deactivate assertions."

In the event that a user uses an assert such as:

```groovy
def bar=false; assert bar, "message";
```

The GroovyScriptEngineService throws a NoClassDefFoundError being unable
to find the `java.lang.StringBuffer` class. It is *highly* recommended
that any Groovy scripting user switch to using regular exceptions rather
than unconfiguration Groovy assertions.

Resolves #19806
2016-08-12 13:06:49 -06:00
..
licenses Upgrade groovy dependency in lang-groovy module to version 2.4.6 2016-02-27 17:41:15 +01:00
src Catch AssertionError and NoClassDefFoundError in groovy scripts 2016-08-12 13:06:49 -06:00
build.gradle Circuit break the number of inline scripts compiled per minute 2016-08-09 10:26:27 -06:00