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

Quarkus testing with @ParameterizedTest broken with Java 17 + 18 (xstream) #24492

Closed
snazy opened this issue Mar 23, 2022 · 14 comments · Fixed by #24872
Closed

Quarkus testing with @ParameterizedTest broken with Java 17 + 18 (xstream) #24492

snazy opened this issue Mar 23, 2022 · 14 comments · Fixed by #24872
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@snazy
Copy link
Contributor

snazy commented Mar 23, 2022

Describe the bug

The following exception happens during tests using @QuarkusTest with Java 17 + 18.

The failing test case is a @ParameterizedTest with a @MethodSource that returns a Stream of objects that contain List instances created by Arrays.asList() - hence the java.util.Collections$UnmodifiableCollection.

Looks like it's not a direct fault of Quarkus, but xsteam not able to deal with those objects.

Adding --add-opens=java.base/java.util=ALL-UNNAMED does not help.

com.thoughtworks.xstream.converters.ConversionException: 
No converter available
---- Debugging information ----
message             : No converter available
type                : java.util.Collections$UnmodifiableRandomAccessList
converter           : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
message[1]          : Unable to make field private static final long java.util.Collections$UnmodifiableCollection.serialVersionUID accessible: module java.base does not "opens java.util" to unnamed module @7f1dd5e7
-------------------------------
	at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:88)
	at com.thoughtworks.xstream.XStream$1.lookupConverterForType(XStream.java:478)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:49)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:270)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:174)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:262)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:270)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:174)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:262)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:270)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:174)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:262)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:44)
	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:83)
	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1266)
	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1255)
	at com.thoughtworks.xstream.XStream.toXML(XStream.java:1228)
	at com.thoughtworks.xstream.XStream.toXML(XStream.java:1215)
	at io.quarkus.test.junit.internal.XStreamDeepClone.doClone(XStreamDeepClone.java:49)
	at io.quarkus.test.junit.internal.XStreamDeepClone.clone(XStreamDeepClone.java:35)
	at io.quarkus.test.junit.internal.SerializationWithXStreamFallbackDeepClone.clone(SerializationWithXStreamFallbackDeepClone.java:33)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:981)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:896)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestTemplateMethod(QuarkusTestExtension.java:856)

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

17.0.2
18

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.5.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@snazy snazy added the kind/bug Something isn't working label Mar 23, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 23, 2022

/cc @geoand

@gsmet
Copy link
Member

gsmet commented Mar 23, 2022

Could you prepare a small reproducer? We run our tests with JDK 17 and 18 so there might be something specific to your project.

@gsmet gsmet added the triage/needs-reproducer We are waiting for a reproducer. label Mar 23, 2022
@geoand
Copy link
Contributor

geoand commented Mar 23, 2022

Something tells me there is some extra testing extension coming into play...

Like @gsmet says, we'll need a reproducer

@snazy
Copy link
Contributor Author

snazy commented Mar 24, 2022

Will put a reproducer together (or facepalm and close this issue, if one of our extensions is causing this w/ Java 17/18)

@snazy
Copy link
Contributor Author

snazy commented Mar 25, 2022

The extension's org.junit.jupiter.params.ParameterizedTestExtension from org.junit.jupiter:junit-jupiter-params

snazy added a commit to snazy/quarkus that referenced this issue Mar 25, 2022
@snazy snazy changed the title Quarkus testing broken with Java 17 + 18 (xstream) Quarkus testing with @ParameterizedTest broken with Java 17 + 18 (xstream) Mar 25, 2022
@snazy
Copy link
Contributor Author

snazy commented Mar 25, 2022

Reproducer pushed as a PR.
Parameterized tests getting a List created by Arrays.asList() fails, "plain" ArrayList works.

@snazy
Copy link
Contributor Author

snazy commented Mar 25, 2022

Haven't checked Guava's collections though.

@famod
Copy link
Member

famod commented Mar 25, 2022

This reminds me a lot of x-stream/xstream#253 where I also documented a (not so pretty) alternate workaround.

So this is an upstream issue we cannot really do anything about, so I'm closing this.
Once (if ever) x-stream 1.5 sees the light of day, we'll look into integrating it.

Adding --add-opens=java.base/java.util=ALL-UNNAMED does not help.

I think you've got a typo there as the following makes the test pass (via surefire argLine):

--add-opens java.base/java.util=ALL-UNNAMED

(more specifically mvn test -f integration-tests/test-extension -Dtest=ParamsTest -Dsurefire.argLine.additional='--add-opens java.base/java.util=ALL-UNNAMED', but surefire.argLine.additional only exists in Quarkus CI/local buidl)

@famod famod closed this as completed Mar 25, 2022
@famod
Copy link
Member

famod commented Mar 25, 2022

PS: Anyway, thanks for reporting!

@famod famod removed the triage/needs-reproducer We are waiting for a reproducer. label Mar 25, 2022
@gsmet
Copy link
Member

gsmet commented Mar 25, 2022

Does it work with List.of()? Because if so, it’s probably what people will use with Java 17+.

@famod
Copy link
Member

famod commented Mar 25, 2022

No, unfortunately: x-stream/xstream#253 (comment)

@snazy
Copy link
Contributor Author

snazy commented Mar 26, 2022

This reminds me a lot of x-stream/xstream#253

That's a kinda depressing issue to read :(

I think you've got a typo there (add-opens)

Well, not a typo (as I've added it to .mvn/jvm.config + .mvn/mvnd.properites). It's been a mistake to add it to the Maven JVM - should have added it to the JVM running the tests via surefire (my bad).

I'll probably just add the two --add-opens to Quarkus surefire/failsafe configs.

snazy added a commit to snazy/quarkus that referenced this issue Apr 11, 2022
geoand added a commit to geoand/quarkus that referenced this issue Apr 11, 2022
geoand added a commit to geoand/quarkus that referenced this issue Apr 11, 2022
geoand added a commit to geoand/quarkus that referenced this issue Apr 11, 2022
geoand added a commit that referenced this issue Apr 11, 2022
Avoid XStream causing illegal access issues for internal JDK collections
@quarkus-bot quarkus-bot bot added this to the 2.9 - main milestone Apr 11, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 11, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 11, 2022
@gsmet gsmet modified the milestones: 2.9 - main, 2.8.1.Final Apr 11, 2022
@xtaixe
Copy link

xtaixe commented Apr 20, 2022

Hi.

I'm still seeing this on 2.8.1.Final when the @MethodSourcereturns a Stream<Map.Entry<String, String>>. The error is:

com.thoughtworks.xstream.converters.ConversionException: 
No converter available
---- Debugging information ----
message             : No converter available
type                : java.util.KeyValueHolder
converter           : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
message[1]          : Unable to make field final java.lang.Object java.util.KeyValueHolder.key accessible: module java.base does not "opens java.util" to unnamed module @7219ec67
-------------------------------

Let me know if you want me to create a new issue. cc @geoand

@geoand
Copy link
Contributor

geoand commented Apr 20, 2022

Please do

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

Successfully merging a pull request may close this issue.

5 participants