@@ -188,9 +188,11 @@ public void decodesXml() throws Exception {
188188
189189 @ Test
190190 public void doesntDecodeParameterizedTypes () throws Exception {
191- thrown .expect (UnsupportedOperationException .class );
191+ thrown .expect (feign . codec . DecodeException .class );
192192 thrown .expectMessage (
193- "JAXB only supports decoding raw types. Found java.util.Map<java.lang.String, ?>" );
193+ "java.util.Map is an interface, and JAXB can't handle interfaces.\n "
194+ + "\t this problem is related to the following location:\n "
195+ + "\t \t at java.util.Map" );
194196
195197 class ParameterizedHolder {
196198
@@ -210,6 +212,42 @@ class ParameterizedHolder {
210212 new JAXBDecoder (new JAXBContextFactory .Builder ().build ()).decode (response , parameterized );
211213 }
212214
215+ @ XmlRootElement
216+ static class Box <T > {
217+
218+ @ XmlElement private T t ;
219+
220+ public void set (T t ) {
221+ this .t = t ;
222+ }
223+ }
224+
225+ @ Test
226+ public void decodeAnnotatedParameterizedTypes () throws Exception {
227+ JAXBContextFactory jaxbContextFactory =
228+ new JAXBContextFactory .Builder ().withMarshallerFormattedOutput (true ).build ();
229+
230+ Encoder encoder = new JAXBEncoder (jaxbContextFactory );
231+
232+ Box <String > boxStr = new Box <>();
233+ boxStr .set ("hello" );
234+ Box <Box <String >> boxBoxStr = new Box <>();
235+ boxBoxStr .set (boxStr );
236+ RequestTemplate template = new RequestTemplate ();
237+ encoder .encode (boxBoxStr , Box .class , template );
238+
239+ Response response =
240+ Response .builder ()
241+ .status (200 )
242+ .reason ("OK" )
243+ .request (Request .create ("GET" , "/api" , Collections .emptyMap (), null , Util .UTF_8 ))
244+ .headers (Collections .<String , Collection <String >>emptyMap ())
245+ .body (template .body ())
246+ .build ();
247+
248+ new JAXBDecoder (new JAXBContextFactory .Builder ().build ()).decode (response , Box .class );
249+ }
250+
213251 /** Enabled via {@link feign.Feign.Builder#decode404()} */
214252 @ Test
215253 public void notFoundDecodesToEmpty () throws Exception {
0 commit comments