77import com .fasterxml .jackson .core .JsonProcessingException ;
88import com .fasterxml .jackson .databind .MapperFeature ;
99import com .fasterxml .jackson .databind .ObjectMapper ;
10+ import com .fasterxml .jackson .databind .json .JsonMapper ;
1011import com .fasterxml .jackson .databind .module .SimpleModule ;
1112
1213import java .nio .charset .StandardCharsets ;
@@ -31,12 +32,14 @@ public final class JWTCreator {
3132 private static final SimpleModule module ;
3233
3334 static {
34- mapper = new ObjectMapper ();
3535 module = new SimpleModule ();
3636 module .addSerializer (PayloadClaimsHolder .class , new PayloadSerializer ());
3737 module .addSerializer (HeaderClaimsHolder .class , new HeaderSerializer ());
38- mapper .registerModule (module );
39- mapper .configure (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY , true );
38+
39+ mapper = JsonMapper .builder ()
40+ .configure (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY , true )
41+ .build ()
42+ .registerModule (module );
4043 }
4144
4245 private JWTCreator (Algorithm algorithm , Map <String , Object > headerClaims , Map <String , Object > payloadClaims )
@@ -489,7 +492,7 @@ private static boolean validateClaim(Map<?, ?> map) {
489492 return false ;
490493 }
491494
492- if (entry . getKey () == null || !(entry .getKey () instanceof String )) {
495+ if (!(entry .getKey () instanceof String )) {
493496 return false ;
494497 }
495498 }
0 commit comments