Allow null ObjectMapper in Jackson2ObjectMapperFactoryBean.getObjectType()

Issue: SPR-11785
This commit is contained in:
Sebastien Deleuze 2014-08-14 13:40:47 +02:00
parent 181299cc6c
commit ebc726a915
2 changed files with 6 additions and 2 deletions

View File

@ -486,8 +486,7 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper
@Override
public Class<?> getObjectType() {
Assert.notNull(this.objectMapper, "ObjectMapper must not be null");
return this.objectMapper.getClass();
return (this.objectMapper != null) ? this.objectMapper.getClass() : null;
}
@Override

View File

@ -182,6 +182,11 @@ public class Jackson2ObjectMapperFactoryBeanTests {
assertEquals(ObjectMapper.class, this.factory.getObjectType());
}
@Test
public void undefinedObjectType() {
assertEquals(null, this.factory.getObjectType());
}
private static SerializerFactoryConfig getSerializerFactoryConfig(ObjectMapper objectMapper) {
return ((BasicSerializerFactory) objectMapper.getSerializerFactory()).getFactoryConfig();
}