You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While it is easy to avoid the overwriting it just makes the code prone to errors when the order of the builder functions matters.
Proposed solution.
Change the JwtBuilder and the Claims interfaces and implementations such that they allow an addClaims functions like this one in the DefaultJwtBuilder implementation.
I've just been caught out by the setClaims method too, but for a different reason. The setClaims method takes a Map and then modifies the passed in map by adding the other claims to the map. This means that a immutable map (e.g. ImmutableMap or Collections.unmodifiableMap) can't be used in the builder. Modification of input parameters by an API is also not pleasant.
Would it be worth therefore deprecating the setClaims method altogether and moving to addClaims instead?
Can you introduce a method in the
JwtBuilder
that allows for bulk insertation of claims but does not overwrite previously set ones?While it is easy to avoid the overwriting it just makes the code prone to errors when the order of the builder functions matters.
Proposed solution.
Change the
JwtBuilder
and theClaims
interfaces and implementations such that they allow an addClaims functions like this one in theDefaultJwtBuilder
implementation.I'm happy to submit a PR.
Cheers
The text was updated successfully, but these errors were encountered: