Skip to content

ClassCastException in dev.morphia.mapping.codec.pojo.TypeData #3787

@renat-nosto

Description

@renat-nosto

Describe the bug
in dev.morphia.mapping.codec.pojo.TypeData#get(java.lang.reflect.Type)

        } else if (type instanceof Class) {
            var typeData = new TypeData((Class) type);
            for (Type argType : TypeParameters.of(type)) {
                typeData.typeParameters.add(argType.equals(type) ? type : get(argType));
            }
            return typeData;
        } 

Type type is added to List<TypeData<?>> typeParameters instead of TypeData typeData
which leads to

class java.lang.Class cannot be cast to class dev.morphia.mapping.codec.pojo.TypeData (java.lang.Class is in module java.base of loader 'bootstrap'; dev.morphia.mapping.codec.pojo.TypeData is in unnamed module of loader 'app')
java.lang.ClassCastException: class java.lang.Class cannot be cast to class dev.morphia.mapping.codec.pojo.TypeData (java.lang.Class is in module java.base of loader 'bootstrap'; dev.morphia.mapping.codec.pojo.TypeData is in unnamed module of loader 'app')
	at dev.morphia.mapping.conventions.ConfigureProperties.isNotConcrete(ConfigureProperties.java:100)
	at dev.morphia.mapping.conventions.ConfigureProperties.buildProperty(ConfigureProperties.java:57)
	at dev.morphia.mapping.conventions.ConfigureProperties.processProperties(ConfigureProperties.java:92)
	at dev.morphia.mapping.conventions.ConfigureProperties.apply(ConfigureProperties.java:41)
	at dev.morphia.mapping.codec.pojo.EntityModelBuilder.build(EntityModelBuilder.java:135)
	at dev.morphia.mapping.Mapper.getEntityModel(Mapper.java:266)

** Please complete the following information: **

  • Morphia Version: 2.5.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions