Fallback isolated ClassLoader to platform classes - #340
Conversation
14545be to
9e5aff1
Compare
|
Can you post repro steps for testing purposes? |
|
Sure thing @mgaffigan . I've edited it into the issue description (#338) for better visibility. |
…nt to Platform ClassLoader Signed-off-by: Paul Hristea <paul.hristea@novamap.health>
9e5aff1 to
dabc06b
Compare
|
Would this affect cases where a user has classes in a resource directory that includes libraries that do conflict with the parent classloader? I reviewed this issue by reading the docs for how the URLClassloader works for both old and new versions of Java:
Since the behaviour hasn't changed in 18 major versions I think we can safely assume that it won't break anything in the future :D I read the references in the PR description. This change is logical and correct. If a driver is loaded, that driver will have dependencies in the system classpath. Therefore including the system classpath is appropriate. HOWEVER see my question above. What happens if a user needs the classloader specifically to override something on the system classpath? Is this common enough to worry about? |
|
Hi @jonbartels, thanks for taking time to review! I believe that this is why the "Load Parent-First" option was introduced - it allows us to choose whether each Resource is meant to take priority during class loading. The cases you ask to consider should be solvable by making use of this checkbox - although they should be uncommon since the move from Java 8 began quite recently.
|
tonygermano
left a comment
There was a problem hiding this comment.
I believe this is the correct change to make so that it behaves similarly to how it ran under java 8. The change itself would have been difficult to make prior to bumping the minimum version to java 17 because the method did not exist in java 8; it would have needed to test if it existed and call it by reflection.
I tested using the driver from https://h2database.com/html/main.html
- added the driver as a resource (did not check load parent first)
- added a database reader channel
- added the driver resource to the channel
- specified the driver as
org.h2.Driver - specified the jdbc uri as
jdbc:h2:./appdata/h2.db - clicked the
Generate: Selectbutton above the SQL section - clicked the
Get Tablesbutton
Under the main branch, this threw a ClassNotFound Exception for java.sql.Driver.
With the fix from this branch
- no error is thrown
- no tables are returned (I never created any)
- a non-empty database file is created at the location specified in the appdata folder
@jonbartels The The The |

Solves #338