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

Broken QuarkusTestExtension #8446

Open
alesj opened this issue Apr 7, 2020 · 11 comments · May be fixed by #34681
Open

Broken QuarkusTestExtension #8446

alesj opened this issue Apr 7, 2020 · 11 comments · May be fixed by #34681
Labels
kind/bug Something isn't working

Comments

@alesj
Copy link
Contributor

alesj commented Apr 7, 2020

When using Quarkus 1.3.1.Final or current master against our Registry, I get this:

Zulip thread:

As mentioned / described, we use custom JUnit5 extension

To reproduce, simply change Quarkus version here:

@alesj alesj added the kind/bug Something isn't working label Apr 7, 2020
@alesj
Copy link
Contributor Author

alesj commented Apr 7, 2020

newMethod = {java.lang.reflect.Method@8575} "void io.apicurio.registry.ArtifactStateTest.testEnableDisableArtifact(io.apicurio.registry.client.RegistryService)"
clazz = {java.lang.Class@4485} "class io.apicurio.registry.ArtifactStateTest"
slot = 5
name = "testEnableDisableArtifact"
returnType = {java.lang.Class@8581} "void"
parameterTypes = {java.lang.Class[1]@8582}
0 = {java.lang.Class@8475} "interface io.apicurio.registry.client.RegistryService"
cachedConstructor = null
newInstanceCallerCache = null
name = "io.apicurio.registry.client.RegistryService"
classLoader = {io.quarkus.bootstrap.classloading.QuarkusClassLoader@8592} "QuarkusClassLoader:Quarkus Base Runtime ClassLoader"

Where actual argument then gets this classloader ...

argumentsFromTccl = {java.util.ArrayList@8577} size = 1
0 = {io.apicurio.registry.client.CachedRegistryService@8595} ""
getClass().getClassLoader() = {sun.misc.Launcher$AppClassLoader@6990}

@geoand
Copy link
Contributor

geoand commented Apr 8, 2020

I went through this and unfortunately there is no good solution...

Although the code in the custom extension can be hacked to load everything from the TCCL instead of the CL which the methods run, that won't cut it unfortunately because JUnit then validates the returned object against the parameter type (and of course this validation fails because of the different ClassLoaders).

This is somewhat related to #8252.

Perhaps your custom extension could return a proxy (constructed on the regular CL) that then delegates the calls to the real object which is constructed on the TCCL.

@alesj
Copy link
Contributor Author

alesj commented Apr 8, 2020

Perhaps your custom extension could return a proxy (constructed on the regular CL) that then delegates the calls to the real object which is constructed on the TCCL.

How would this help?
Wouldn't this still create a mismatch?

@geoand
Copy link
Contributor

geoand commented Apr 8, 2020

Ah sorry, yes you are right....

@gsmet
Copy link
Member

gsmet commented Apr 8, 2020

/cc @stuartwdouglas

@alesj
Copy link
Contributor Author

alesj commented Apr 8, 2020

@geoand
Copy link
Contributor

geoand commented Apr 8, 2020

You did need to make the changes I suggested in chat, right?

@alesj
Copy link
Contributor Author

alesj commented Apr 8, 2020 via email

@geoand
Copy link
Contributor

geoand commented Apr 8, 2020 via email

@stuartwdouglas
Copy link
Member

I dont think there is much we can do here without JUnit changes. They are considering adding better support for custom ClassLoader implementations in the next release, so hopefully that happens in a way that is useful to us.

@geoand
Copy link
Contributor

geoand commented Sep 13, 2024

This is one that would potentially be fixed by @holly-cummins's WIP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

4 participants