Skip to content

Conversation

@jdconrad
Copy link
Contributor

@jdconrad jdconrad commented Jan 4, 2018

Updated the Painless Loader to first look for classes that are already loaded as part of the Definition initialization through the Whitelist. This allows for modules/plugins to whitelist custom classes without forcing Painless to have a direct relationship with the module's/plugin's ClassLoader.

This also removes the singleton of Definition, so now there will be one Definition per Compiler. However, the standard whitelist files singleton still exists out of convenience for now for testing. This should be cleaned up later in a different PR.

@rjernst This will be difficult to properly test until we integrate directly with SPI.

@jdconrad
Copy link
Contributor Author

jdconrad commented Jan 4, 2018

@elasticmachine Please test this.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

for (ScriptContext<?> context : contexts) {
if (context.instanceClazz.equals(SearchScript.class) || context.instanceClazz.equals(ExecutableScript.class)) {
contextsToCompilers.put(context, new Compiler(GenericElasticsearchScript.class, Definition.DEFINITION));
contextsToCompilers.put(context, new Compiler(GenericElasticsearchScript.class, new Definition(
Copy link
Member

Choose a reason for hiding this comment

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

For now, let's move the construction of Definition out of the loop, so we still only create one, until we can figure out if we need an internal cache to ensure too many copies aren't loaded of common classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Changed this to re-use the same Definition for all contexts for now.

@jdconrad
Copy link
Contributor Author

jdconrad commented Jan 5, 2018

@rjernst Thanks for the review. Will push as soon as the CI completes successfully.

@jdconrad jdconrad merged commit b5377d2 into elastic:master Jan 5, 2018
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 6, 2018
* master: (25 commits)
  Remove Gradle cheatsheet
  Fix reproduction info to point to Gradle wrapper
  Update platforms tests to use Gradle wrapper
  Update testing docs to reflect Gradle wrapper
  Painless: Modify Loader to Load Classes Directly from Definition (elastic#28088)
  Update contributing docs to use the Gradle wrapper
  Create nio-transport plugin for NioTransport (elastic#27949)
  test: replaced try-catch statements with expectThrows(...)
  Add getWarmer and getTranslog method to NodeIndicesStats (elastic#28092)
  fix doc mistake
  Added ASN support for Ingest GeoIP plugin.
  Fix global aggregation that requires breadth first and scores (elastic#27942)
  Introduce Gradle wrapper
  Ignore GIT_COMMIT when calculating commit hash
  Re-enable bwc tests after elastic#27881 was backported
  Set the elasticsearch-nio codebase for tests (elastic#28067)
  Bump compat version for local depdendent test to 6.2.0
  Pass `java.locale.providers=COMPAT` to Java 9 onwards (elastic#28080)
  Allow shrinking of indices from a previous major (elastic#28076)
  Remove deprecated exceptions (elastic#28059)
  ...
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 6, 2018
* master:
  Remove Gradle cheatsheet
  Fix reproduction info to point to Gradle wrapper
  Update platforms tests to use Gradle wrapper
  Update testing docs to reflect Gradle wrapper
  Painless: Modify Loader to Load Classes Directly from Definition (elastic#28088)
  Update contributing docs to use the Gradle wrapper
  Create nio-transport plugin for NioTransport (elastic#27949)
jasontedor added a commit that referenced this pull request Jan 6, 2018
* master:
  Remove out-of-date projectile file
  Remove Gradle cheatsheet
  Fix reproduction info to point to Gradle wrapper
  Update platforms tests to use Gradle wrapper
  Update testing docs to reflect Gradle wrapper
  Painless: Modify Loader to Load Classes Directly from Definition (#28088)
  Update contributing docs to use the Gradle wrapper
  Create nio-transport plugin for NioTransport (#27949)
  test: replaced try-catch statements with expectThrows(...)
  Add getWarmer and getTranslog method to NodeIndicesStats (#28092)
  fix doc mistake
  Added ASN support for Ingest GeoIP plugin.
  Fix global aggregation that requires breadth first and scores (#27942)
@clintongormley clintongormley added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache and removed :Plugin Lang Painless labels Feb 14, 2018
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
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 v6.2.0 v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants