Skip to content

Commit 7e507d1

Browse files
committed
Fixed #696
1 parent 7108f58 commit 7e507d1

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

release-notes/CREDITS

+4
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,7 @@ Zoltan Farkas (zolyfarkas@github)
203203
Ludevik@github:
204204
* Reported #682: Class<?>-valued Map keys not serialized properly
205205
(2.5.1)
206+
207+
Charles Allen (drcrallen@github)
208+
* Reported #696: Copy constructor does not preserve `_injectableValues`
209+
(2.6.0)

release-notes/VERSION

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project: jackson-databind
77
2.6.0 (not yet released)
88

99
#649: Make `BeanDeserializer` use new `parser.nextFieldName()` and `.hasTokenId()` methods
10+
#696: Copy constructor does not preserve `_injectableValues`
11+
(reported by Charles A)
1012

1113
2.5.1 (not yet released)
1214

src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ protected ObjectMapper(ObjectMapper src)
412412
_subtypeResolver = src._subtypeResolver;
413413
_rootNames = new RootNameLookup();
414414
_typeFactory = src._typeFactory;
415+
_injectableValues = src._injectableValues;
416+
415417
HashMap<ClassKey,Class<?>> mixins = new HashMap<ClassKey,Class<?>>(src._mixInAnnotations);
416418
_mixInAnnotations = mixins;
417419
_serializationConfig = new SerializationConfig(src._serializationConfig, mixins);
@@ -1522,7 +1524,14 @@ public ObjectMapper setInjectableValues(InjectableValues injectableValues) {
15221524
_injectableValues = injectableValues;
15231525
return this;
15241526
}
1525-
1527+
1528+
/**
1529+
* @since 2.6
1530+
*/
1531+
public InjectableValues getInjectableValues() {
1532+
return _injectableValues;
1533+
}
1534+
15261535
/**
15271536
* Method for overriding default locale to use for formatting.
15281537
* Default value used is {@link Locale#getDefault()}.

src/main/java/com/fasterxml/jackson/databind/ObjectReader.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,14 @@ public TypeFactory getTypeFactory() {
834834
public ContextAttributes getAttributes() {
835835
return _config.getAttributes();
836836
}
837-
837+
838+
/**
839+
* @since 2.6
840+
*/
841+
public InjectableValues getInjectableValues() {
842+
return _injectableValues;
843+
}
844+
838845
/*
839846
/**********************************************************
840847
/* Deserialization methods; basic ones to support ObjectCodec first

src/test/java/com/fasterxml/jackson/databind/TestObjectMapper.java

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void testProps()
4747
assertNotNull(m.getNodeFactory());
4848
JsonNodeFactory nf = JsonNodeFactory.instance;
4949
m.setNodeFactory(nf);
50+
assertNull(m.getInjectableValues());
5051
assertSame(nf, m.getNodeFactory());
5152
}
5253

@@ -138,13 +139,17 @@ public void testCopy() throws Exception
138139
assertTrue(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
139140
m.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
140141
assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
142+
InjectableValues inj = new InjectableValues.Std();
143+
m.setInjectableValues(inj);
141144

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

144147
ObjectMapper m2 = m.copy();
145148
assertFalse(m2.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
146149
m2.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
147150
assertTrue(m2.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
151+
assertSame(inj, m2.getInjectableValues());
152+
148153
// but should NOT change the original
149154
assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
150155

0 commit comments

Comments
 (0)