Buggy code:
public class TokenCache extends LeaderSelectorListenerAdapter implements Closeable { private static Logger logger = LoggerFactory . getLogger ( TokenCache . class ) ; private static class CachedTokens { private static class Item { @ SerializedName ( "access_token" ) public String accessToken = "" ; @ SerializedName ( "js_ticket" ) public String jsTicket = "" ; } @ SerializedName ( "update_time" ) public long updateTime = 0 ; @ SerializedName ( "map" ) public HashMap < String , TokenCache . CachedTokens . Item > map = new HashMap < String , TokenCache . CachedTokens . Item > ( ) ; } private static final TokenCache instance = new TokenCache ( ) ; private static String getZkLeaderPath ( ) { } private static String getZkValuePath ( ) { } public static boolean isLeader ( ) throws Exception { } public static String getAccessToken ( String appID ) { } public static String getJsTicket ( String appID ) { } private void initialize ( ) throws Exception { } private CuratorFramework client = null ; private LeaderSelector leaderSelector = null ; private DistributedAtomicValue value = null ; private boolean initialized = false ; public void close ( ) { } public void takeLeadership ( CuratorFramework curatorFramework ) { TokenCache . logger . info ( "Leadership<seq2seq4repair_space>taken" ) ; try { boolean needRefresh = false ; try { TokenCache . CachedTokens cachedTokens = getCachedTokens ( ) ; long updateTime = ( null == cachedTokens ) ? 0 : cachedTokens . updateTime ; long duration = ( System . currentTimeMillis ( ) ) - updateTime ; <START_BUG> if ( ( duration < 0 ) || ( duration > ( TimeUnit . MINUTES . toMillis ( 30 ) ) ) ) { <END_BUG> needRefresh = true ; } } catch ( Throwable t ) { TokenCache . logger . error ( "Hit<seq2seq4repair_space>an<seq2seq4repair_space>error" , t ) ; needRefresh = true ; } if ( needRefresh ) { TokenCache . logger . info ( "Will<seq2seq4repair_space>refresh<seq2seq4repair_space>tokens" ) ; Collection < String > apps = WeixinConfig . getApps ( ) ; TokenCache . logger . debug ( "Apps:<seq2seq4repair_space>{}" , apps ) ; TokenCache . CachedTokens cachedTokens = getCachedTokens ( ) ; if ( null == cachedTokens ) { cachedTokens = new TokenCache . CachedTokens ( ) ; } for ( String app : apps ) { RestAdapter adapter = new RestAdapter . Builder ( ) . setEndpoint ( "https:////api.weixin.qq.com" ) . build ( ) ; WeixinAPI weixinAPI = adapter . create ( WeixinAPI . class ) ; WeixinConfig . Item item = WeixinConfig . get ( app ) ; TokenCache . CachedTokens . Item cacheTokenItem = new TokenCache . CachedTokens . Item ( ) ; for ( int i = 0 ; i < 10 ; ++ i ) { WeixinAPI . Token token = weixinAPI . getToken ( "client_credential" , item . appID , item . appSecret ) ; if ( StringUtils . isNoneBlank ( token . access_token ) ) { cacheTokenItem . accessToken = token . access_token ; break ; } } for ( int i = 0 ; i < 10 ; ++ i ) { WeixinAPI . Ticket ticket = weixinAPI . getTicket ( cacheTokenItem . accessToken , "jsapi" ) ; if ( StringUtils . isNoneBlank ( ticket . ticket ) ) { cacheTokenItem . jsTicket = ticket . ticket ; break ; } } cachedTokens . map . put ( app , cacheTokenItem ) ; } cachedTokens . updateTime = System . currentTimeMillis ( ) ; setCachedTokens ( cachedTokens ) ; TokenCache . logger . info ( "Tokens<seq2seq4repair_space>refreshed" ) ; } else { Thread . sleep ( TimeUnit . SECONDS . toMillis ( 60 ) ) ; } } catch ( InterruptedException e ) { TokenCache . logger . error ( "Interrupted" , e ) ; Thread . currentThread ( ) . interrupt ( ) ; } catch ( Throwable t ) { TokenCache . logger . error ( "Unknown<seq2seq4repair_space>error" , t ) ; } finally { TokenCache . logger . info ( "Relinquishing<seq2seq4repair_space>leadership." ) ; } } public TokenCache . CachedTokens getCachedTokens ( ) { } public void setCachedTokens ( TokenCache . CachedTokens cachedTokens ) { } }

Fix:
if ( ( Math . abs ( duration ) ) > ( TimeUnit . MINUTES . toMillis ( 30 ) ) ) {