Skip to content

Catch OutOfMemory and StackOverflow errors in Painless#19936

Merged
jdconrad merged 1 commit intoelastic:masterfrom
jdconrad:errors
Aug 11, 2016
Merged

Catch OutOfMemory and StackOverflow errors in Painless#19936
jdconrad merged 1 commit intoelastic:masterfrom
jdconrad:errors

Conversation

@jdconrad
Copy link
Copy Markdown
Contributor

Since Painless is both sandboxed and stateless, it is safe to catch OutOfMemory and StackOverflow errors. This prevents the users from destroying a node if they happen to write a script that is ridiculous like the following:

int[] x = new int[Integer.MAX_VALUE];

There is no reason to halt the entire application for the above script.

@rmuir
Copy link
Copy Markdown
Contributor

rmuir commented Aug 11, 2016

+1 we made a sandbox, lets take advantage of it :)

// Note that it is safe to catch any of the following errors since Painless is stateless.
} catch (PainlessError | BootstrapMethodError | OutOfMemoryError | StackOverflowError | Exception e) {
throw convertToScriptException(e);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for killing this IllegalAccessError: i added this on accident when debugging long ago!

@jdconrad
Copy link
Copy Markdown
Contributor Author

@rmuir Thanks for the review and pointing out the issue.

@jdconrad jdconrad merged commit a5008bb into elastic:master Aug 11, 2016
@jdconrad jdconrad deleted the errors branch September 6, 2016 16:44
@clintongormley clintongormley added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache and removed :Plugin Lang Painless labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement v5.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants