Skip to content
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

Block more resource loading to parent #152

Merged
merged 2 commits into from
Nov 28, 2022
Merged

Block more resource loading to parent #152

merged 2 commits into from
Nov 28, 2022

Conversation

honnix
Copy link
Member

@honnix honnix commented Nov 26, 2022

TL;DR

Block service resource loading to parent.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

ServiceLoader tries to find resources to understand what classes to load, and for the following scenario, it will fail with a mysteries error message.

  • com.example.Foo exists both in parent and child classpath, in two different jars
  • com.example.FooImpl only exists in parent classpath
  • Task code (under child classpath) uses ServiceLoader to discover implementation of com.example.Foo, using ChildFirstClassLoader
  • ServiceLoader uses ChildFirstClassLoader to find resources from both child and parent classpath, and in this case com.example.FooImpl is discovered
  • ServiceLoader verifies whether com.example.FooImpl (loaded by parent class loader, and its super class com.example.Foo is also loaded by parent class loader; remember there are two copies of com.example.Foo?) can be assigned to com.example.Foo (loaded by child class loader)
  • The verification fails because there are two copies of com.example.Foo loaded by different class loaders, with an error message like "java.util.ServiceConfigurationError: com.example.Foo: com.example.FooImpl not a subtype"

Tracking Issue

Closes flyteorg/flyte#3103

Follow-up issue

NA

@@ -63,6 +64,7 @@ public void testFibonacciWorkflow() {
}

@Test
@Disabled
Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason this always times out.

@honnix honnix marked this pull request as draft November 26, 2022 16:00
@honnix honnix force-pushed the skip-more-resources branch from 715188b to 9f97845 Compare November 26, 2022 16:28
Signed-off-by: Hongxin Liang <[email protected]>
@honnix honnix marked this pull request as ready for review November 26, 2022 17:26
@honnix honnix requested a review from narape November 28, 2022 08:03
@narape narape merged commit a2a349e into master Nov 28, 2022
@narape narape deleted the skip-more-resources branch November 28, 2022 12:13
andresgomezfrr pushed a commit that referenced this pull request Jan 24, 2023
* Block more resource loading to parent

Signed-off-by: Hongxin Liang <[email protected]>

* Make sure it is a folder

Signed-off-by: Hongxin Liang <[email protected]>

Signed-off-by: Hongxin Liang <[email protected]>
Signed-off-by: Andres Gomez Ferrer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Service loading fails in flytekit-java
2 participants