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

NPE when trying to add null Map or List claims #416

Closed
DanilaVaratyntsev opened this issue Apr 22, 2020 · 2 comments
Closed

NPE when trying to add null Map or List claims #416

DanilaVaratyntsev opened this issue Apr 22, 2020 · 2 comments
Labels
bug This points to a verified bug in the code

Comments

@DanilaVaratyntsev
Copy link

DanilaVaratyntsev commented Apr 22, 2020

Description

I'm getting a NullPointerException in JWTCreator#validateClaim(List<?>) and JWTCreator#validateClaim(Map<?, ?>) methods when trying to add a null map or list claim.

At the same time, JWTCreator#addClaim(String, Object), that would be called after validation, accepts null values and deletes a claim in this case.

I guess, validation can be performed only on not-null maps and lists.

Please, excuse me for wasting your time if it's an expected behavior.

Reproduction

Code sample for List:

JWT.create()
    .withClaim("listClaim", (List<String>) null)
    .sign(Algorithm.HMAC256("MySecret"));

Code sample for Map:

JWT.create()
    .withClaim("mapClaim", (Map<String, ?>) null)
    .sign(Algorithm.HMAC256("MySecret"));
@lbalmaceda
Copy link
Contributor

👋 Thanks for reaching out. I think those 2 methods should keep the behavior of the other withClaim methods. This is, whenever a key is non-null but the value is null, remove that key from the final claims set.
I'll move it to the backlog.

@lbalmaceda lbalmaceda added the bug This points to a verified bug in the code label Apr 22, 2020
@lbalmaceda
Copy link
Contributor

We should be able to release this next week. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

2 participants