[ https://issues.apache.org/jira/browse/JOHNZON-202?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Struberg resolved JOHNZON-202. ----------------------------------- Resolution: Fixed Fix Version/s: 1.1.13 Thanks for the report. Docs fixed. Please review! > org.apache.johnzon.mapper.Adapter JavaDoc wrong and > IllegalArgumentException-message from org.apache.johnzon.mapper.Mappings > misleading > --------------------------------------------------------------------------------------------------------------------------------------- > > Key: JOHNZON-202 > URL: https://issues.apache.org/jira/browse/JOHNZON-202 > Project: Johnzon > Issue Type: Improvement > Components: Mapper > Affects Versions: 1.1.11 > Reporter: Alexander Falb > Assignee: Mark Struberg > Priority: Major > Fix For: 1.1.13 > > Attachments: image-2019-02-19-14-59-17-119.png > > > {{org.apache.johnzon.mapper.Adapter<A, B>}} states, that {{A}} is taken from > JSON and converted to {{B}} to store in the POJO. Following this, I > implemented 3 adapter for java.time.* classes. When calling > {{Mapper#writeObjectAsString(Object)}} the following exception is thrown: > {code:java} > java.lang.IllegalArgumentException: Ambiguous adapter for > org.apache.johnzon.mapper.access.FieldAccessMode$FieldReader@5e265ba4 > at org.apache.johnzon.mapper.Mappings.findConverter(Mappings.java:593) > at org.apache.johnzon.mapper.Mappings.addGetterIfNeeded(Mappings.java:494) > at org.apache.johnzon.mapper.Mappings.createClassMapping(Mappings.java:412) > at > org.apache.johnzon.mapper.Mappings.findOrCreateClassMapping(Mappings.java:361) > at org.apache.johnzon.mapper.Mapper.isDeduplicateObjects(Mapper.java:141) > at org.apache.johnzon.mapper.Mapper.writeObject(Mapper.java:134) > at org.apache.johnzon.mapper.Mapper.writeObjectAsString(Mapper.java:178) > at JohnzonTestMain.main(JohnzonTestMain.java:27){code} > While debugging this problem I found the following: > (my custom adapers are highlighted - it looks like I implemented them the > wrong way) > !image-2019-02-19-14-59-17-119.png! > I think the JavaDoc of Adapter is wrong. The {{A to(B b);}} method is ment to > convert from a JSON-value to a Java-value and {{B from(A a);}} from a > Java-value to a JSON-value (A is the Javatype and B the JSONtype)? > Also the exception is kind of misleading. Getting the actually ambiguous key > would have been helpful. > > If you are interested I can provide a PR on GitHub, fixing the JavaDoc and > changing the exception message? -- This message was sent by Atlassian JIRA (v7.6.14#76016)