Skip to content

Commit

Permalink
Fix #913: Properly copy MappingJsonFactory features
Browse files Browse the repository at this point in the history
  • Loading branch information
dsw2127 committed Sep 1, 2015
1 parent 06e37f3 commit 7d45f7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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 7d45f7f

Please sign in to comment.