Skip to content

Commit

Permalink
Backport #913 fix in 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 10, 2015
1 parent a7b26eb commit 5183922
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ Andy Wilkinson (wilkinsona@github)
(2.6.1)

lufe66@github:

* Reported 894: When using withFactory on ObjectMapper, the created Factory has a TypeParser
which still has the original Factory
(2.6.2)

Daniel Walker (dsw2127@github)
* Reported, contributed fix for #913: `ObjectMapper.copy()` does not preserve
`MappingJsonFactory` features
(2.6.2)
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Project: jackson-databind
which still has the original Factory
(reported by lufe66@github)
#899: Problem serializing `ObjectReader` (and possibly `ObjectMapper`)
#913: ObjectMapper.copy does not preserve MappingJsonFactory features
(reported, fixed by Daniel W)

2.6.1 (09-Aug-2015)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public MappingJsonFactory(ObjectMapper mapper)
}
}

public MappingJsonFactory(JsonFactory src, ObjectMapper mapper)
{
super(src, mapper);
if (mapper == null) {
setCodec(new ObjectMapper(this));
}
}

/**
* We'll override the method to return more specific type; co-variance
* helps here
Expand All @@ -46,7 +54,7 @@ public JsonFactory copy()
{
_checkInvalidCopy(MappingJsonFactory.class);
// note: as with base class, must NOT copy mapper reference
return new MappingJsonFactory(null);
return new MappingJsonFactory(this, null);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public void testCopy() throws Exception
assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
InjectableValues inj = new InjectableValues.Std();
m.setInjectableValues(inj);
assertFalse(m.isEnabled(JsonParser.Feature.ALLOW_COMMENTS));
m.enable(JsonParser.Feature.ALLOW_COMMENTS);
assertTrue(m.isEnabled(JsonParser.Feature.ALLOW_COMMENTS));

// // First: verify that handling of features is decoupled:

Expand Down Expand Up @@ -193,6 +196,10 @@ public void testCopy() throws Exception
assertEquals(0, m2.getSerializationConfig().mixInCount());
assertEquals(1, m.getDeserializationConfig().mixInCount());
assertEquals(0, m2.getDeserializationConfig().mixInCount());

// [Issue#913]: Ensure JsonFactory Features copied
assertTrue(m2.isEnabled(JsonParser.Feature.ALLOW_COMMENTS));

}

public void testAnnotationIntrospectorCopyin()
Expand Down

0 comments on commit 5183922

Please sign in to comment.