Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support customization of the MapperFactory #228

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

kqarryzada
Copy link
Collaborator

Previously, the fields of the MapperFactory were static. This
effectively allowed only a single instance of the object, and also made
it impossible to override the createObjectMapper() method with personal
customizations like adding serializers/deserializers. The SCIM SDK
already treated MapperFactory instances as if they were not static, so
we will now permit flexible customization. The documentation makes it
clear that the superclass's object mapper must be fetched first for
optimal behavior.

Reviewer: vyhhuang
Reviewer: dougbulkley

JiraIssue: DS-49067
Resolves #147

Fixed a deprecation warning from an old method provided by Jackson.
Previously, the fields of the MapperFactory were static. This
effectively allowed only a single instance of the object, and also made
it impossible to override the createObjectMapper() method with personal
customizations like adding serializers/deserializers. The SCIM SDK
already treated MapperFactory instances as if they were not static, so
we will now permit flexible customization. The documentation makes it
clear that the superclass's object mapper must be fetched first for
optimal behavior.

Reviewer: vyhhuang
Reviewer: dougbulkley

JiraIssue: DS-49067
@kqarryzada kqarryzada self-assigned this Jul 19, 2024
var objectMapperBuilder = JsonMapper.builder(new ScimJsonFactory());

// Do not care about case when de-serializing POJOs.
objectMapperBuilder.enable(ACCEPT_CASE_INSENSITIVE_PROPERTIES);
Copy link
Collaborator Author

@kqarryzada kqarryzada Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original mapper.configure() call for this property (which I've now deleted) was marked as deprecated by Jackson, so I've updated the logic to instead set the property on the builder class instead. I'm not sure why other setting types (e.g., deserialization features) are okay with setting this directly on an object mapper, but it seems to be what the library encourages.

@@ -68,7 +69,8 @@ protected ScimJsonFactory(@NotNull final ScimJsonFactory sourceFactory,
JsonParser createScimFilterParser(@NotNull final Reader r)
throws IOException
{
IOContext ctxt = _createContext(r, false);
ContentReference reference = ContentReference.construct(true, r);
IOContext ctxt = _createContext(reference, false);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated change that resolves another deprecation warning. I've kept this in a separate commit.

Copy link

@vyhhuang vyhhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look fine to me.

@kqarryzada kqarryzada merged commit c5a828d into master Jul 22, 2024
10 checks passed
@kqarryzada kqarryzada deleted the DS-49067-customize-sdk-objectmapper branch July 22, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Json customization via MapperFactory doesn't work
3 participants