JaxbConverterFactory doesn't recognize @XmlJavaTypeAdapter
What kind of issue is this?
Question. This issue tracker is not the place for questions. If you want to ask how to do something, or to understand why something isn't working the way you expect it to, use Stack Overflow. https://stackoverflow.com/questions/tagged/retrofit
Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests get fixed. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9
Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.
The way JAXB deals with classes that doesn't have a no-arg constructor or classes with final fields is by using an XmlAdapter, and to configure an XmlAdapter for some class, we need to annotate this class with XmlJavaTypeAdapter.
The problem happens if the root is an immutable class, in this case, the root java class will be annotated with XmlJavaTypeAdapter, which the JaxbConverterFactory doesn't recognize (it only checks isAnnotationPresent for XmlRootElement), and will return a null value, so retrofit will assume that the request/response cannot be converted using JAXB.
It would be an easy change to also check for XmlJavaTypeAdapter annotation.
Complete tutorial: http://blog.bdoughan.com/2010/12/jaxb-and-immutable-objects.html
Source: lysine-dev/retrofit