-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QL: Extend NodeSubclass to read classes from jars #50866
Conversation
As the test classes are spread across more than one project, the Gradle classpath contains not just folders but also jars. This commit allows the test class to explore the archive content and load matching classes from said source.
Pinging @elastic/es-search (:Search/SQL) |
String name = je.getName(); | ||
if (name.endsWith(".class")) { | ||
String className = name.substring(0, name.length() - ".class".length()).replace("/", "."); | ||
maybeLoadClass(clazz, className, root + "!/" + name, results); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is !/
intended as a visual marker in the path? The location
is later only used for the message in the Exception, so I guess so, but curious about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's a special marker inside the URL to indicate the path inside the archive:
jar:/my/file.jar!/org/my/package/clazz.class
/** | ||
* Load classes from predefined packages (hack to limit the scope) and if they match the hierarchy, add them to the cache | ||
*/ | ||
private static <T> void maybeLoadClass(Class<T> clazz, String className, String location, List<Class<? extends T>> results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe attemptClassLoad()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the name, the class might be loaded or not hence the 'maybe' versus attempt which suggests the loading will happen always (but it might fail).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but more experienced eyes should stamp it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/** | ||
* Load classes from predefined packages (hack to limit the scope) and if they match the hierarchy, add them to the cache | ||
*/ | ||
private static <T> void maybeLoadClass(Class<T> clazz, String className, String location, List<Class<? extends T>> results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the results
be a Set
instead of List
?
3be7fbd
to
9ef7c2b
Compare
As the test classes are spread across more than one project, the Gradle classpath contains not just folders but also jars. This commit allows the test class to explore the archive content and load matching classes from said source.
* Introduce reusable QL plugin for SQL and EQL (#50815) Extract reusable functionality from SQL into its own dedicated project QL. Implemented as a plugin, it provides common components across SQL and the upcoming EQL. While this commit is fairly large, for the most part it's just a big file move from sql package to the newly introduced ql. (cherry picked from commit ec1ac0d) * SQL: Fix incomplete registration of geo NamedWritables (cherry picked from commit e295763) * QL: Extend NodeSubclass to read classes from jars (#50866) As the test classes are spread across more than one project, the Gradle classpath contains not just folders but also jars. This commit allows the test class to explore the archive content and load matching classes from said source. (cherry picked from commit 25ad749) * QL: Remove implicit conversion inside Literal (#50962) Literal constructor makes an implicit conversion for each value given which turns out has some subtle side-effects. Improve MathProcessors to preserve numeric type where possible Fix bug on issue compatibility between date and intervals Preserve the source when folding inside the Optimizer (cherry picked from commit 9b73e22) * QL: Refactor DataType for pluggability (#51328) Change DataType from enum to class Break DataType enums into QL (default) and SQL types Make data type conversion pluggable so that new types can be introduced As part of the process: - static type conversion in QL package (such as Literal) has been removed - several utility classes have been broken into base (QL) and extended (SQL) parts based on type awareness - operators (+,-,/,*) are - due to extensibility, serialization of arithmetic operation has been slightly changed and pushed down to the operator executor itself (cherry picked from commit aebda81) * Compilation fixes for 7.x
As the test classes are spread across more than one project, the Gradle
classpath contains not just folders but also jars.
This commit allows the test class to explore the archive content and
load matching classes from said source.
With the fix in place, two test classes affected by this (around 600 tests) are now enabled.