@@ -115,12 +115,12 @@ private String formatTokenId(TokenIdent id) {
115115  /** 
116116   * Access to currentKey is protected by this object lock 
117117   */ 
118-   private  DelegationKey  currentKey ;
118+   private  volatile   DelegationKey  currentKey ;
119119
120-   private  long  keyUpdateInterval ;
121-   private  long  tokenMaxLifetime ;
122-   private  long  tokenRemoverScanInterval ;
123-   private  long  tokenRenewInterval ;
120+   private  final   long  keyUpdateInterval ;
121+   private  final   long  tokenMaxLifetime ;
122+   private  final   long  tokenRemoverScanInterval ;
123+   private  final   long  tokenRenewInterval ;
124124  /** 
125125   * Whether to store a token's tracking ID in its TokenInformation. 
126126   * Can be overridden by a subclass. 
@@ -486,17 +486,18 @@ private synchronized void removeExpiredKeys() {
486486  }
487487
488488  @ Override 
489-   protected  synchronized   byte [] createPassword (TokenIdent  identifier ) {
489+   protected  byte [] createPassword (TokenIdent  identifier ) {
490490    int  sequenceNum ;
491491    long  now  = Time .now ();
492492    sequenceNum  = incrementDelegationTokenSeqNum ();
493493    identifier .setIssueDate (now );
494494    identifier .setMaxDate (now  + tokenMaxLifetime );
495-     identifier .setMasterKeyId (currentKey .getKeyId ());
495+     DelegationKey  delegationCurrentKey  = currentKey ;
496+     identifier .setMasterKeyId (delegationCurrentKey .getKeyId ());
496497    identifier .setSequenceNumber (sequenceNum );
497498    LOG .info ("Creating password for identifier: "  + formatTokenId (identifier )
498-         + ", currentKey: "  + currentKey .getKeyId ());
499-     byte [] password  = createPassword (identifier .getBytes (), currentKey .getKey ());
499+         + ", currentKey: "  + delegationCurrentKey .getKeyId ());
500+     byte [] password  = createPassword (identifier .getBytes (), delegationCurrentKey .getKey ());
500501    DelegationTokenInformation  tokenInfo  = new  DelegationTokenInformation (now 
501502        + tokenRenewInterval , password , getTrackingIdIfEnabled (identifier ));
502503    try  {
@@ -521,7 +522,6 @@ protected synchronized byte[] createPassword(TokenIdent identifier) {
521522   */ 
522523  protected  DelegationTokenInformation  checkToken (TokenIdent  identifier )
523524      throws  InvalidToken  {
524-     assert  Thread .holdsLock (this );
525525    DelegationTokenInformation  info  = getTokenInfo (identifier );
526526    String  err ;
527527    if  (info  == null ) {
@@ -541,7 +541,7 @@ protected DelegationTokenInformation checkToken(TokenIdent identifier)
541541  }
542542
543543  @ Override 
544-   public  synchronized   byte [] retrievePassword (TokenIdent  identifier )
544+   public  byte [] retrievePassword (TokenIdent  identifier )
545545      throws  InvalidToken  {
546546    return  checkToken (identifier ).getPassword ();
547547  }
@@ -553,7 +553,7 @@ protected String getTrackingIdIfEnabled(TokenIdent ident) {
553553    return  null ;
554554  }
555555
556-   public  synchronized   String  getTokenTrackingId (TokenIdent  identifier ) {
556+   public  String  getTokenTrackingId (TokenIdent  identifier ) {
557557    DelegationTokenInformation  info  = getTokenInfo (identifier );
558558    if  (info  == null ) {
559559      return  null ;
@@ -567,7 +567,7 @@ public synchronized String getTokenTrackingId(TokenIdent identifier) {
567567   * @param password Password in the token. 
568568   * @throws InvalidToken InvalidToken. 
569569   */ 
570-   public  synchronized   void  verifyToken (TokenIdent  identifier , byte [] password )
570+   public  void  verifyToken (TokenIdent  identifier , byte [] password )
571571      throws  InvalidToken  {
572572    byte [] storedPassword  = retrievePassword (identifier );
573573    if  (!MessageDigest .isEqual (password , storedPassword )) {
@@ -584,7 +584,7 @@ public synchronized void verifyToken(TokenIdent identifier, byte[] password)
584584   * @throws InvalidToken if the token is invalid 
585585   * @throws AccessControlException if the user can't renew token 
586586   */ 
587-   public  synchronized   long  renewToken (Token <TokenIdent > token ,
587+   public  long  renewToken (Token <TokenIdent > token ,
588588                         String  renewer ) throws  InvalidToken , IOException  {
589589    ByteArrayInputStream  buf  = new  ByteArrayInputStream (token .getIdentifier ());
590590    DataInputStream  in  = new  DataInputStream (buf );
@@ -646,7 +646,7 @@ public synchronized long renewToken(Token<TokenIdent> token,
646646   * @throws InvalidToken for invalid token 
647647   * @throws AccessControlException if the user isn't allowed to cancel 
648648   */ 
649-   public  synchronized   TokenIdent  cancelToken (Token <TokenIdent > token ,
649+   public  TokenIdent  cancelToken (Token <TokenIdent > token ,
650650      String  canceller ) throws  IOException  {
651651    ByteArrayInputStream  buf  = new  ByteArrayInputStream (token .getIdentifier ());
652652    DataInputStream  in  = new  DataInputStream (buf );
0 commit comments