Skip to content

Commit

Permalink
Backport fix #2374
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 2, 2019
1 parent e12eea6 commit 9e2a4a9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,10 @@ Cyril Martin ([email protected])
does not provide "Type(Type(null))"
(2.9.9)

Daniil Barvitsky (dbarvitsky@github(
Daniil Barvitsky (dbarvitsky@github)
* Reported #2324: `StringCollectionDeserializer` fails with custom collection
(2.9.9)

Edgar Asatryan (nstdio@github)
* Reported #2374: `ObjectMapper. getRegisteredModuleIds()` throws NPE if no modules registered
(2.9.9.1)
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Project: jackson-databind

#2326: Block one more gadget type (CVE-2019-12384)
#2341: Block one more gadget type (CVE-2019-12814)
#2374: `ObjectMapper. getRegisteredModuleIds()` throws NPE if no modules registered
(reported by Edgar A)

2.9.9 (16-May-2019)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,8 @@ public ObjectMapper registerModules(Iterable<? extends Module> modules)
*/
public Set<Object> getRegisteredModuleIds()
{
return Collections.unmodifiableSet(_registeredModuleTypes);
return (_registeredModuleTypes == null) ?
Collections.emptySet() : Collections.unmodifiableSet(_registeredModuleTypes);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,18 @@ public void testGetRegisteredModules()
AnotherSimpleModule mod2 = new AnotherSimpleModule("test2", Version.unknownVersion());

ObjectMapper mapper = new ObjectMapper();

mapper.registerModule(mod1);
mapper.registerModule(mod2);

Set<Object> registeredModuleIds = mapper.getRegisteredModuleIds();
assertEquals(2, registeredModuleIds.size());
assertTrue(registeredModuleIds.contains(mod1.getTypeId()));
assertTrue(registeredModuleIds.contains(mod2.getTypeId()));

// 01-Jul-2019, [databind#2374]: verify empty list is fine
mapper = new ObjectMapper();
assertEquals(0, mapper.getRegisteredModuleIds().size());
}

/*
Expand Down

0 comments on commit 9e2a4a9

Please sign in to comment.