Skip to content

Conversation

@aloubyansky
Copy link
Member

@aloubyansky aloubyansky commented Jun 4, 2020

Fixes #9017
Fixes #7424

These two issues were reported by the same user. They are different but both reproducers are affected by #9017

@boring-cyborg boring-cyborg bot added area/core area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle labels Jun 4, 2020
@gsmet gsmet requested a review from stuartwdouglas June 4, 2020 10:52
@gsmet gsmet added this to the 1.6.0 - master milestone Jun 4, 2020
@stuartwdouglas
Copy link
Collaborator

This does not seem right. FileSystemProvider is part of the JDK, there should never be multiple implementations of it (in fact you can't have multiple impls, because the JDK will stop you).

@aloubyansky
Copy link
Member Author

@aloubyansky
Copy link
Member Author

Have you checked the original issue?

@stuartwdouglas
Copy link
Collaborator

Caused by: java.lang.ClassCastException: Cannot cast org.apache.sshd.common.util.security.bouncycastle.BouncyCastleSecurityProviderRegistrar to org.apache.sshd.common.util.security.SecurityProviderRegistrar at java.base/java.lang.Class.cast(Class.java:3605)

This must be because the FS lookup is not using the TCCL, but some other provider is.

Is there any reason why we don't pass the TCCL to the ServiceLoader here?

@aloubyansky
Copy link
Member Author

It is using the TCCL but the JDK is using the system classloader to load the "installed" providers. The test deps are visible to the system classloader so this is where it picks it up.

@aloubyansky
Copy link
Member Author

Well, the JDK actually allows you to provide your own classloader which we don't in this specific case. But even if we did it wouldn't affect this use-case. Because it always loads the providers from the system classloader first and then from the user provided cl.

@aloubyansky
Copy link
Member Author

Looks at java.nio.file.spi.FileSystemProvider.loadInstalledProviders()

@stuartwdouglas
Copy link
Collaborator

Looks like there is not much else that can be done here.

The global provider list is being loaded from the system CL, but then if the TCCL is set the sshd provider attempts to use the TCCL to load some classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Gradle] ServiceLoader issues in test cases Unable to inject rest client defined in a different module in a multi module project

3 participants