[ https://issues.apache.org/jira/browse/FELIX-5666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16110361#comment-16110361 ]
David Leangen commented on FELIX-5666: -------------------------------------- I found a "temporary" solution: creating a rule. {code} static class MapTargetRule implements TargetRule { @Override public ConverterFunction getFunction() { return new MapConverterFunction(); } @Override public Type getTargetType() { return Map.class; } } static class MapConverterFunction implements ConverterFunction { @Override public Object apply( Object obj, Type targetType ) throws Exception { return Converters .standardConverter() .convert(obj) .sourceAsDTO() .to(targetType); } } {code} The reason I write "temporary" is because this rule seems too generic and the usage, I am guessing, so common, that it is a bit heavy-handed to be required to declare this type of rule each time. But in any case, the serialization of a DTO-type object now works when called like this: {code} String s = serializer .serialize( obj ) .with(Converters.newConverterBuilder().rule(new MapTargetRule()).build()) .toString(); {code} What do you think we should do? I just committed another test case so you can see. It is in JsonBackingObjectSerializationTest. > Serializer goes into infinite loop > ---------------------------------- > > Key: FELIX-5666 > URL: https://issues.apache.org/jira/browse/FELIX-5666 > Project: Felix > Issue Type: Bug > Components: Converter > Reporter: David Leangen > > I'm only guessing as to what the problem is, following some stepping through > the code. I could not find any similar existing test cases, but if the > following does not immediately click for [~bosschaert], I will try to add one. > It appears that, when serializing an object to a "DTO-Type" object to a Map, > some kind of backing object is created. > If the backing object contains a field that instantiates the same DTO, then > the loop gets created. > Example: > {code} > public class MyDtoType { > public String id; > public MyDtoType( String anID ) { > id = anID; > } > public static MyDtoType error() { > return new MyDtoType( "ERROR" ); > } > } > {code} > It looks like the serializer keeps calling the error() method infinitely, but > I am not able to easily pinpoint where this happens. -- This message was sent by Atlassian JIRA (v6.4.14#64029)