vadbch / orika

Automatically exported from code.google.com/p/orika
0 stars 0 forks source link

Getting NullPointer exception when converting an integer to an enum with a registered custom converter #178

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.         MapperFactory mapperFactory = new 
DefaultMapperFactory.Builder().build();

        ConverterFactory converterFactory = mapperFactory.getConverterFactory();

        converterFactory.registerConverter(new ModuleConverter());
        converterFactory.registerConverter(new AccessConverter()); 

        BoundMapperFacade<DomainUser, User> userMapper = mapperFactory.getMapperFacade(DomainUser.class, User.class);
2. public class ModuleConverter extends BidirectionalConverter<Integer, Module> 
{

    @Override
    public Module convertTo(Integer source, Type<Module> destinationType) {
        return Module.findById(source);
    }

    @Override
    public Integer convertFrom(Module source, Type<Integer> destinationType) {
        return source.getId();
    }
}
3.

What is the expected output? What do you see instead?
logs:
Error occurred: java.lang.NullPointerException
    at ma.glasnost.orika.impl.generator.MapperGenerator.addMapMethod(MapperGenerator.java:175)
    at ma.glasnost.orika.impl.generator.MapperGenerator.build(MapperGenerator.java:71)
    ... 69 more
Caused by: java.lang.NullPointerException
    at ma.glasnost.orika.impl.generator.specification.ArrayOrCollectionToCollection.generateMappingCode(ArrayOrCollectionToCollection.java:30)
    at ma.glasnost.orika.impl.generator.SourceCodeContext.mapFields(SourceCodeContext.java:673)
    at ma.glasnost.orika.impl.generator.specification.MapToMap.generateMappingCode(MapToMap.java:63)
    at ma.glasnost.orika.impl.generator.SourceCodeContext.mapFields(SourceCodeContext.java:673)
    at ma.glasnost.orika.impl.generator.MapperGenerator.generateFieldMapCode(MapperGenerator.java:252)
    at ma.glasnost.orika.impl.generator.MapperGenerator.addMapMethod(MapperGenerator.java:172)

What version of the product are you using? On what operating system?

        <dependency>
            <groupId>ma.glasnost.orika</groupId>
            <artifactId>orika-core</artifactId>
            <version>1.4.2</version>
            <!-- or latest version -->
        </dependency>

Mac OS

Please provide any additional information below.

Original issue reported on code.google.com by Michael....@gmail.com on 29 Oct 2014 at 6:10