Bad use of interceptor ?
Opened this issue · 3 comments
Hi Slemesle,
I just tried to use a simple interceptor for post-treatment but I Didn' t make it compile with 1.0 or 1.1-snapshot versions, could you tell me if I made a mistake ?
Mapper:
@Mapper(ignoreMissingProperties = true,
withIgnoreNullValue = true,
withIoC = IoC.SPRING,
withCyclicMapping = true,
withCustom = {MoneyToMoneyCustomMapper.class, JsonToJsonCustomMapper.class, CustomCampaignInterceptor.class}
)
public interface CampaignLightMapper extends CampaignMapper {
@maps(withIgnoreFields = {
"distributionCampaignLinks",
"company",
"reason",
"distributedByUser",
"deposit"
})
CampaignDto asCampaignDto(Campaign in);
}
Interceptor:
@component
public class CustomCampaignInterceptor {
public void intercept(final Campaign source, final CampaignDto destination) {
// Some code entity to dto
}
public void intercept(final CampaignDto source, final Campaign destination) {
// Some code dto to entity
}
}
Thank you for your help.
I always get the same Exception:
Caused by: java.lang.NullPointerException
at fr.xebia.extras.selma.codegen.SourceNodeVars.isOutPrimitive(SourceNodeVars.java:162)
at fr.xebia.extras.selma.codegen.MappingBuilder.build(MappingBuilder.java:747)
at fr.xebia.extras.selma.codegen.MapperMethodGenerator.buildMappingMethod(MapperMethodGenerator.java:190)
at fr.xebia.extras.selma.codegen.MapperMethodGenerator.build(MapperMethodGenerator.java:69)
at fr.xebia.extras.selma.codegen.MapperClassGenerator.build(MapperClassGenerator.java:161)
at fr.xebia.extras.selma.codegen.MapperProcessor.generateMappingClassses(MapperProcessor.java:88)
at fr.xebia.extras.selma.codegen.MapperProcessor.process(MapperProcessor.java:71)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
... 101 more
Hi @surdsey ,
I've just had a look on this bug, but I am not able to reproduce this error.
This exception tells us that the InOutType is null in the SourceNodeVars but, I really don't see how it is possible.
Could you post some more code to reproduce the error in integration tests ?