Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit be331f8

Browse files
committed
Fix #63 (for 2.7.9 / 2.8.4)
1 parent cdc9183 commit be331f8

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

release-notes/VERSION

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Project: jackson-module-jaxb-annotations
88

99
No changes since 2.7
1010

11+
2.7.9 (not yet released)
12+
13+
#63: Error in type resolution of reference type (`Optional`)
14+
(reported by adrianriley@github)
15+
1116
2.7.8 (26-Sep-2016)
1217
2.7.7 (27-Aug-2016)
1318
2.7.6 (23-Jul-2016)

src/main/java/com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> co
563563
/* First: let's ensure property is a container type: caller should have
564564
* verified but just to be sure
565565
*/
566-
if (!containerType.isContainerType()) {
567-
throw new IllegalArgumentException("Must call method with a container type (got "+containerType+")");
566+
if (containerType.getContentType() == null) {
567+
throw new IllegalArgumentException("Must call method with a container or reference type (got "+containerType+")");
568568
}
569569
return _typeResolverFromXmlElements(am);
570570
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.fasterxml.jackson.module.jaxb.types;
2+
3+
import java.util.concurrent.atomic.AtomicReference;
4+
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.module.jaxb.BaseJaxbTest;
7+
8+
// [jaxb-annotations#63]
9+
public class OptionalTypeRefinementTest extends BaseJaxbTest
10+
{
11+
static class Stuff63 {
12+
public AtomicReference<String> value = new AtomicReference<String>("abc");
13+
}
14+
15+
public void testWithReferenceType() throws Exception
16+
{
17+
final ObjectMapper mapper = getJaxbMapper();
18+
19+
String json = mapper.writeValueAsString(new Stuff63());
20+
assertEquals("{\"value\":\"abc\"}", json);
21+
22+
Stuff63 result = mapper.readValue("{\"value\":\"xyz\"}",
23+
Stuff63.class);
24+
assertNotNull(result);
25+
assertNotNull(result.value);
26+
assertEquals("xyz", result.value.get());
27+
}
28+
}

0 commit comments

Comments
 (0)