Skip to content

Commit

Permalink
Fix #922
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 10, 2015
1 parent 5183922 commit af2241c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Project: jackson-databind
#899: Problem serializing `ObjectReader` (and possibly `ObjectMapper`)
#913: ObjectMapper.copy does not preserve MappingJsonFactory features
(reported, fixed by Daniel W)
#922: ObjectMapper.copy() does not preserve _registeredModuleTypes

2.6.1 (09-Aug-2015)

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,14 @@ protected ObjectMapper(ObjectMapper src)

// Default serializer factory is stateless, can just assign
_serializerFactory = src._serializerFactory;

// as per [databind#922], make sure to copy registered modules as appropriate
Set<Object> reg = _registeredModuleTypes;
if (reg == null) {
_registeredModuleTypes = null;
} else {
_registeredModuleTypes = new LinkedHashSet<Object>(reg);
}
}

/**
Expand Down Expand Up @@ -681,7 +689,9 @@ public ObjectMapper registerModule(Module module)
Object typeId = module.getTypeId();
if (typeId != null) {
if (_registeredModuleTypes == null) {
_registeredModuleTypes = new HashSet<Object>();
// plus let's keep them in order too, easier to debug or expose
// in registration order if that matter
_registeredModuleTypes = new LinkedHashSet<Object>();
}
// try adding; if already had it, should skip
if (!_registeredModuleTypes.add(typeId)) {
Expand Down

0 comments on commit af2241c

Please sign in to comment.