Skip to content

Commit

Permalink
Fixed #696
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 6, 2015
1 parent 7108f58 commit 7e507d1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,7 @@ Zoltan Farkas (zolyfarkas@github)
Ludevik@github:
* Reported #682: Class<?>-valued Map keys not serialized properly
(2.5.1)

Charles Allen (drcrallen@github)
* Reported #696: Copy constructor does not preserve `_injectableValues`
(2.6.0)
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project: jackson-databind
2.6.0 (not yet released)

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

2.5.1 (not yet released)

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ protected ObjectMapper(ObjectMapper src)
_subtypeResolver = src._subtypeResolver;
_rootNames = new RootNameLookup();
_typeFactory = src._typeFactory;
_injectableValues = src._injectableValues;

HashMap<ClassKey,Class<?>> mixins = new HashMap<ClassKey,Class<?>>(src._mixInAnnotations);
_mixInAnnotations = mixins;
_serializationConfig = new SerializationConfig(src._serializationConfig, mixins);
Expand Down Expand Up @@ -1522,7 +1524,14 @@ public ObjectMapper setInjectableValues(InjectableValues injectableValues) {
_injectableValues = injectableValues;
return this;
}


/**
* @since 2.6
*/
public InjectableValues getInjectableValues() {
return _injectableValues;
}

/**
* Method for overriding default locale to use for formatting.
* Default value used is {@link Locale#getDefault()}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,14 @@ public TypeFactory getTypeFactory() {
public ContextAttributes getAttributes() {
return _config.getAttributes();
}


/**
* @since 2.6
*/
public InjectableValues getInjectableValues() {
return _injectableValues;
}

/*
/**********************************************************
/* Deserialization methods; basic ones to support ObjectCodec first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void testProps()
assertNotNull(m.getNodeFactory());
JsonNodeFactory nf = JsonNodeFactory.instance;
m.setNodeFactory(nf);
assertNull(m.getInjectableValues());
assertSame(nf, m.getNodeFactory());
}

Expand Down Expand Up @@ -138,13 +139,17 @@ public void testCopy() throws Exception
assertTrue(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
m.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
InjectableValues inj = new InjectableValues.Std();
m.setInjectableValues(inj);

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

ObjectMapper m2 = m.copy();
assertFalse(m2.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
m2.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
assertTrue(m2.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
assertSame(inj, m2.getInjectableValues());

// but should NOT change the original
assertFalse(m.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));

Expand Down

0 comments on commit 7e507d1

Please sign in to comment.