File tree 4 files changed +23
-2
lines changed
main/java/com/fasterxml/jackson/databind
test/java/com/fasterxml/jackson/databind
4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -309,7 +309,11 @@ Andy Wilkinson (wilkinsona@github)
309
309
(2.6.1)
310
310
311
311
lufe66@github:
312
-
313
312
* Reported 894: When using withFactory on ObjectMapper, the created Factory has a TypeParser
314
313
which still has the original Factory
315
314
(2.6.2)
315
+
316
+ Daniel Walker (dsw2127@github)
317
+ * Reported, contributed fix for #913: `ObjectMapper.copy()` does not preserve
318
+ `MappingJsonFactory` features
319
+ (2.6.2)
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ Project: jackson-databind
10
10
which still has the original Factory
11
11
(reported by lufe66@github)
12
12
#899: Problem serializing `ObjectReader` (and possibly `ObjectMapper`)
13
+ #913: ObjectMapper.copy does not preserve MappingJsonFactory features
14
+ (reported, fixed by Daniel W)
13
15
14
16
2.6.1 (09-Aug-2015)
15
17
Original file line number Diff line number Diff line change @@ -33,6 +33,14 @@ public MappingJsonFactory(ObjectMapper mapper)
33
33
}
34
34
}
35
35
36
+ public MappingJsonFactory (JsonFactory src , ObjectMapper mapper )
37
+ {
38
+ super (src , mapper );
39
+ if (mapper == null ) {
40
+ setCodec (new ObjectMapper (this ));
41
+ }
42
+ }
43
+
36
44
/**
37
45
* We'll override the method to return more specific type; co-variance
38
46
* helps here
@@ -46,7 +54,7 @@ public JsonFactory copy()
46
54
{
47
55
_checkInvalidCopy (MappingJsonFactory .class );
48
56
// note: as with base class, must NOT copy mapper reference
49
- return new MappingJsonFactory (null );
57
+ return new MappingJsonFactory (this , null );
50
58
}
51
59
52
60
/*
Original file line number Diff line number Diff line change @@ -159,6 +159,9 @@ public void testCopy() throws Exception
159
159
assertFalse (m .isEnabled (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES ));
160
160
InjectableValues inj = new InjectableValues .Std ();
161
161
m .setInjectableValues (inj );
162
+ assertFalse (m .isEnabled (JsonParser .Feature .ALLOW_COMMENTS ));
163
+ m .enable (JsonParser .Feature .ALLOW_COMMENTS );
164
+ assertTrue (m .isEnabled (JsonParser .Feature .ALLOW_COMMENTS ));
162
165
163
166
// // First: verify that handling of features is decoupled:
164
167
@@ -193,6 +196,10 @@ public void testCopy() throws Exception
193
196
assertEquals (0 , m2 .getSerializationConfig ().mixInCount ());
194
197
assertEquals (1 , m .getDeserializationConfig ().mixInCount ());
195
198
assertEquals (0 , m2 .getDeserializationConfig ().mixInCount ());
199
+
200
+ // [Issue#913]: Ensure JsonFactory Features copied
201
+ assertTrue (m2 .isEnabled (JsonParser .Feature .ALLOW_COMMENTS ));
202
+
196
203
}
197
204
198
205
public void testAnnotationIntrospectorCopyin ()
You can’t perform that action at this time.
0 commit comments