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

Replace Deprecated Calls #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

SethSmucker
Copy link
Collaborator

Replace several straightforward deprecated calls with their suggested replacements.

part of NationalSecurityAgency/datawave#2443

@SethSmucker
Copy link
Collaborator Author

DefaultJwtBuilder.toJson() is deprecated, but it's overriden in the JWTTokenHandler's CustomJWTBuilder nested class. From what I can see, it doesn't look like there's a way to remove it without also updating DefaultJwtBuilder, which is an Accumulo class.

Here's the snippit from JWTTokenHandler's CustomJWTBuilder:

 private class CustomJWTBuilder extends DefaultJwtBuilder {
        private final ObjectMapper objectMapper;
        
        private CustomJWTBuilder(ObjectMapper objectMapper) {
            this.objectMapper = objectMapper;
        }
        
        @Override
        protected byte[] toJson(Object object) throws SerializationException {
            try {
                return objectMapper.writeValueAsBytes(object);
            } catch (JsonProcessingException e) {
                throw new SerializationException(e.getMessage(), e);
            }
        }
    }

Any suggestions?

@ivakegg
Copy link
Collaborator

ivakegg commented Oct 2, 2024

DefaultJwtBuilder.toJson() is deprecated, but it's overriden in the JWTTokenHandler's CustomJWTBuilder nested class. From
...
Any suggestions?

@SethSmucker I honestly do not see a way around it as the compact() method ends up calling the toJson method and we need to supply our own object mapper. This one we may need to leave as is. BTW, this is NOT an accumulo class.

@ivakegg
Copy link
Collaborator

ivakegg commented Oct 2, 2024

DefaultJwtBuilder.toJson() is deprecated, but it's overriden in the JWTTokenHandler's CustomJWTBuilder nested class. From
...
Any suggestions?

@SethSmucker I honestly do not see a way around it as the compact() method ends up calling the toJson method and we need to supply our own object mapper. This one we may need to leave as is. BTW, this is NOT an accumulo class.

OH WAIT! I see how to do this. You can create a "Serializer<Map<String,?>> serializer" that wraps the object mapper to do the json serialization. Then add it when building using the serializeToJsonWIth(serializer). That way you can get rid of the custom implementation and just use the default one directly.

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.

2 participants