-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
I think the changes made for #3110 have resulted in some unintended behavior.
Specifically, the new SimpleModule(Version)
constructor calls this(version.getArtifactId(), version);
which sets _hasExplicitName = true
even though no explicit name was passed in. And since getArtifactId()
returns ""
instead of null
, this results in getTypeId()
returning the same ""
for distinct modules.
I think either _hasExplicitName
name should not be set to true when it is not explicitly passed in, or _name
should be set to null if getArtifactId()
returns empty string. The former is probably easier since there validation in ObjectMapper to ensure getModuleName()
is not null, although it doesn't really seem correct to implicitly set name to an empty string - especially when it can also result in getTypeId()
being an empty string.
Here is a simple test case:
public class Module1 extends SimpleModule {
public Module1() {
super(Version.unknownVersion());
}
};
public class Module2 extends SimpleModule {
public Module2() {
super(Version.unknownVersion());
}
};
@Test
public void test() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Module1());
mapper.registerModule(new Module2());
Set<Object> modules = mapper.getRegisteredModuleIds();
Assert.assertEquals(2, modules.size());
}
Version Information
No response
Reproduction
<-- Any of the following
- Brief code sample/snippet: include here in preformatted/code section
- Longer example stored somewhere else (diff repo, snippet), add a link
- Textual explanation: include here
-->
// Your code here
Expected behavior
No response
Additional context
No response