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

ClassCastException related to Maps on Parameterized test on 2.8.1.Final on Java 11 #25073

Closed
xtaixe opened this issue Apr 21, 2022 · 2 comments · Fixed by #25084
Closed

ClassCastException related to Maps on Parameterized test on 2.8.1.Final on Java 11 #25073

xtaixe opened this issue Apr 21, 2022 · 2 comments · Fixed by #25084
Labels
kind/bug Something isn't working
Milestone

Comments

@xtaixe
Copy link

xtaixe commented Apr 21, 2022

Describe the bug

Parameterized tests dealing with objects that have maps as fields break when upgrading from 2.8.0.Final to 2.8.1.Final (at least on Java 11).

@QuarkusTest
class ReproducerTest {

    static Stream<Arguments> arguments() {
        return Stream.of(
                Arguments.of(new TestObject1()),
                Arguments.of(new TestObject2()));
    }

    @ParameterizedTest
    @MethodSource("arguments")
    void map(Object o) {

    }

    static class TestObject1 {

        private final Map<String, String> map = Collections.emptyMap();

        Map<String, String> getMap() {
            return map;
        }

    }

    static class TestObject2 {

        private final Map<String, String> map = Map.of();

        Map<String, String> getMap() {
            return map;
        }

    }

}

gives the following errors:

java.lang.ClassCastException: class java.util.Collections$EmptyMap cannot be cast to class java.util.Collection (java.util.Collections$EmptyMap and java.util.Collection are in module java.base of loader 'bootstrap')

	at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:72)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:50)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
java.lang.ClassCastException: class java.util.ImmutableCollections$Map1 cannot be cast to class java.util.Collection (java.util.ImmutableCollections$Map1 and java.util.Collection are in module java.base of loader 'bootstrap')

	at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:72)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

Darwin xtaixe 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "11.0.14" 2022-01-18 OpenJDK Runtime Environment GraalVM CE 22.0.0.2 (build 11.0.14+9-jvmci-22.0-b05) OpenJDK 64-Bit Server VM GraalVM CE 22.0.0.2 (build 11.0.14+9-jvmci-22.0-b05, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.8.1.Final

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

Apache Maven 3.8.5

Additional information

No response

@xtaixe xtaixe added the kind/bug Something isn't working label Apr 21, 2022
@gsmet
Copy link
Member

gsmet commented Apr 21, 2022

@geoand this is probably related to the Xstream changes.

geoand added a commit to geoand/quarkus that referenced this issue Apr 22, 2022
@geoand
Copy link
Contributor

geoand commented Apr 22, 2022

#25084 fixes the issue

@quarkus-bot quarkus-bot bot added this to the 2.9 - main milestone Apr 22, 2022
geoand added a commit that referenced this issue Apr 22, 2022
Fix CCE with Map parameterized types
@gsmet gsmet modified the milestones: 2.9 - main, 2.8.2.Final Apr 24, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 24, 2022
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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants