Buggy code:
public ( ) ) ) { useritem . setNotificationCount ( 0L ) ; useritem . setId ( screenname ) ; useritem . setSince ( now ) ; useritem . setSinceHumanReadable ( sdf . format ( now ) ) ; useritem . setRegistered ( true ) ; useritem . setURLCheckingMode ( "stealth" ) ; useritem . setHideEmbeddedCounts ( true ) ; } if ( ( topcolor != null ) && ( isValidTopcolor ( topcolor ) ) ) useritem . setHNTopcolor ( topcolor ) ; else useritem . setHNTopcolor ( "ff6600" ) ; useritem . setSeen ( now ) ; useritem . setSeenHumanReadable ( sdf . format ( now ) ) ; useritem . setThisAccessToken ( uuid_str ) ; useritem . setThisAccessTokenExpires ( future ) ; useritem . setHNAuthToken ( null ) ; if ( hn_user_jo . has ( "karma" ) ) { hn_karma_str = hn_user_jo . getString ( "karma" ) ; if ( Global . isWholeNumeric ( hn_karma_str ) ) useritem . setHNKarma ( Long . parseLong ( hn_karma_str ) ) ; else useritem . setHNKarma ( 0L ) ; } else useritem . setHNKarma ( 0L ) ; if ( hn_user_jo . has ( "created" ) ) { hn_since_str = hn_user_jo . getString ( "created" ) ; if ( Global . isWholeNumeric ( hn_since_str ) ) useritem . setHNSince ( Long . parseLong ( hn_since_str ) ) ; else useritem . setHNSince ( 0L ) ; } else useritem . setHNSince ( 0L ) ; session . save ( useritem ) ; jsonresponse . put ( "response_status" , "success" ) ; jsonresponse . put ( "verified" , true ) ; jsonresponse . put ( "this_access_token" , uuid_str ) ; jsonresponse . put ( "screenname" , useritem . getId ( ) ) ; break ; } else { System . out . println ( ( ( "Loop<seq2seq4repair_space>" + x ) + ",<seq2seq4repair_space>Found<seq2seq4repair_space>BEGIN|<seq2seq4repair_space>and<seq2seq4repair_space>|END,<seq2seq4repair_space>but<seq2seq4repair_space>the<seq2seq4repair_space>string<seq2seq4repair_space>didn't<seq2seq4repair_space>match<seq2seq4repair_space>the<seq2seq4repair_space>DB.<seq2seq4repair_space>Trying<seq2seq4repair_space>again<seq2seq4repair_space>in<seq2seq4repair_space>5<seq2seq4repair_space>seconds." ) ) ; try { Thread . sleep ( 5000 ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } x ++ ; } } } else { System . out . println ( ( ( "Loop<seq2seq4repair_space>" + x ) + ",<seq2seq4repair_space>Did<seq2seq4repair_space>not<seq2seq4repair_space>find<seq2seq4repair_space>BEGIN|<seq2seq4repair_space>or<seq2seq4repair_space>|END.<seq2seq4repair_space>Trying<seq2seq4repair_space>again<seq2seq4repair_space>in<seq2seq4repair_space>5<seq2seq4repair_space>seconds." ) ) ; try { Thread . sleep ( 5000 ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } x ++ ; } } } catch ( IOException ioe ) { System . err . println ( "IOException<seq2seq4repair_space>attempting<seq2seq4repair_space>to<seq2seq4repair_space>verifyHNUser.<seq2seq4repair_space>Ignore<seq2seq4repair_space>and<seq2seq4repair_space>continue." ) ; } } if ( x == limit ) { System . out . println ( ( ( "Checked<seq2seq4repair_space>" + limit ) + "<seq2seq4repair_space>times<seq2seq4repair_space>and<seq2seq4repair_space>failed.<seq2seq4repair_space>Returning<seq2seq4repair_space>response_status<seq2seq4repair_space>=<seq2seq4repair_space>error." ) ) ; jsonresponse . put ( "response_status" , "error" ) ; jsonresponse . put ( "message" , ( ( "Checked<seq2seq4repair_space>" + limit ) + "<seq2seq4repair_space>times<seq2seq4repair_space>and<seq2seq4repair_space>didn\'t<seq2seq4repair_space>find<seq2seq4repair_space>\"BEGIN|\"" ) ) ; } } tx . commit ( ) ; } catch ( Exception e ) { if ( tx != null ) tx . rollback ( ) ; e . printStackTrace ( ) ; } finally { Global . printThreadHeader ( indentval , session . hashCode ( ) , "Endpoint.verifyHNUser" , "closing" ) ; session . close ( ) ; } } } else if ( method . equals ( "getMostFollowedUsers" ) ) { Session session = HibernateUtil . getSessionFactory ( ) . openSession ( ) ; int indentval = new Random ( ) . nextInt ( 10 ) ; Global . printThreadHeader ( indentval , session . hashCode ( ) , "Endpoint.getMostFollowedUsers" , "opening" ) ; Transaction tx = null ; try { tx = session . beginTransaction ( ) ; Globalvar gvi = ( ( Globalvar ) ( session . get ( Globalvar . class , "most_followed_users" ) ) ) ; if ( gvi != null ) { jsonresponse . put ( "response_status" , "success" ) ; jsonresponse . put ( "most_followed_users" , new JSONArray ( gvi . getStringValue ( ) ) ) ; } else { jsonresponse . put ( "response_status" , "error" ) ; jsonresponse . put ( "message" , "Couldn't<seq2seq4repair_space>get<seq2seq4repair_space>most_followed_users<seq2seq4repair_space>value<seq2seq4repair_space>from<seq2seq4repair_space>DB." ) ; } tx . commit ( ) ; } catch ( Exception e ) { if ( tx != null ) tx . rollback ( ) ; e . printStackTrace ( ) ; } finally { Global . printThreadHeader ( indentval , session . hashCode ( ) , "Endpoint.getMostFollowedUsers" , "closing" ) ; session . close ( ) ; } } else if ( method . equals ( "getItem" ) ) { String id = request . getParameter ( "id" ) ; if ( ( ( id == null ) || ( id . isEmpty ( ) ) ) || ( ! ( Global . isWholeNumeric ( id ) ) ) ) { jsonresponse . put ( "message" , "id<seq2seq4repair_space>value<seq2seq4repair_space>was<seq2seq4repair_space>null,<seq2seq4repair_space>empty<seq2seq4repair_space>or<seq2seq4repair_space>invalid" ) ; jsonresponse . put ( "response_status" , "error" ) ; } else { Session session = HibernateUtil . getSessionFactory ( ) . openSession ( ) ; int indentval = new Random ( ) . nextInt ( 10 ) ; Global . printThreadHeader ( indentval , session . hashCode ( ) , "Endpoint.getItem" , "opening" ) ; Transaction tx = null ; try { tx = session . beginTransaction ( ) ; Item item = ( ( Item ) ( session . get ( Item . class , Long . parseLong ( id ) ) ) ) ; if ( item != null ) { jsonresponse . put ( "response_status" , "success" ) ; jsonresponse . put ( "item_jo" , item . getJSON ( ) ) ; } else { jsonresponse . put ( "response_status" , "error" ) ; jsonresponse . put ( "message" , "Item<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>exist<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>DB." ) ; } tx . commit ( ) ; } catch ( Exception e ) { if ( tx != null ) tx . rollback ( ) ; e . printStackTrace ( ) ; } finally { Global . printThreadHeader ( indentval , session . hashCode ( ) , "Endpoint.getItem" , "closing" ) ; session . close ( ) ; } } } } catch ( JSONException jsone ) { out . println ( ( ( "{<seq2seq4repair_space>\"response_status\":<seq2seq4repair_space>\"error\",<seq2seq4repair_space>\"message\":<seq2seq4repair_space>\"JSONException<seq2seq4repair_space>caught<seq2seq4repair_space>in<seq2seq4repair_space>Endpoint<seq2seq4repair_space>GET<seq2seq4repair_space>non-auth<seq2seq4repair_space>methods.<seq2seq4repair_space>method=" + method ) + "\"}" ) ) ; System . err . println ( ( "endpoint:<seq2seq4repair_space>JSONException<seq2seq4repair_space>thrown<seq2seq4repair_space>in<seq2seq4repair_space>Endpoint<seq2seq4repair_space>GET<seq2seq4repair_space>non-auth<seq2seq4repair_space>methods.<seq2seq4repair_space>" + ( jsone . getMessage ( ) ) ) ) ; jsone . printStackTrace ( ) ; return ; } } else if ( ( ( ( ( ( ( ( ( ( ( method . equals ( "getUserSelf" ) ) || ( method . equals ( "setUserPreference" ) ) ) || ( method . equals ( "followUser" ) ) ) || ( method . equals ( "unfollowUser" ) ) ) || ( method . equals ( "resetNotificationCount" ) ) ) || ( method . equals ( "deleteNotification" ) ) ) || ( method . equals ( "removeItemFromNotificationIds" ) ) ) || ( method . equals ( "getNotificationItem" ) ) ) || ( method . equals ( "resetNewsfeedCount" ) ) ) || ( method . equals ( "getChat" ) ) ) || ( method . equals ( "submitChatMessage" ) ) ) { try { String screenname = request . getParameter ( "screenname" ) ; String this_access_token = request . getParameter ( "this_access_token" ) ; if ( ( ! ( ( screenname == null ) || ( screenname . isEmpty ( ) ) ) ) && ( ! ( ( this_access_token == null ) || ( this_access_token . isEmpty ( ) ) ) ) ) { if ( ! ( ( screenname == null ) || ( screenname . isEmpty ( ) ) ) ) { Session session = HibernateUtil . getSessionFactory ( ) . openSession ( ) ; int indentval = new Random ( ) . nextInt ( 10 ) ; Global . printThreadHeader ( indentval , session . hashCode ( ) , ( "Endpoint." + method ) , "opening" ) ; Transaction tx = null ; try { tx = session . beginTransaction ( ) ; User useritem = ( ( User ) ( session . get ( User . class , screenname ) ) ) ; if ( useritem != null ) { if ( useritem . isValid ( this_access_token ) ) { if ( method . equals ( "getUserSelf" ) ) { boolean something_needs_updating = false ; String ext_version = request . getParameter ( "ext_version" ) ; if ( ( ext_version != null ) && ( ! ( ext_version . isEmpty ( ) ) ) ) { if ( ( ( ( ( ext_version . length ( ) ) == 5 ) && ( Global . isWholeNumeric ( ext_version . substring ( 0 , 1 ) ) ) ) && ( ext_version . substring ( 1 , 2 ) . equals ( "." ) ) ) && ( Global . isWholeNumeric ( ext_version . substring ( 2 , 5 ) ) ) ) { if ( ( ( useritem . getExtVersion ( ) ) == null ) || ( ! ( useritem . getExtVersion ( ) . equals ( ext_version ) ) ) ) { useritem . setExtVersion ( ext_version ) ; something_needs_updating = true ; } } } JSONObject user_jo = null ; long now = System . currentTimeMillis ( ) ; if ( ( now - ( useritem . getSeen ( ) ) ) > 600000 ) { something_needs_updating = true ; useritem . setSeen ( now ) ; SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd<seq2seq4repair_space>HH:mm:ss<seq2seq4repair_space>z" ) ; sdf . setTimeZone ( TimeZone . getTimeZone ( "America//New_York" ) ) ; useritem . setSeenHumanReadable ( sdf . format ( timestamp_at_entry ) ) ; try { String result = Jsoup . connect ( ( ( "https:////hacker-news.firebaseio.com//v0//user//" + screenname ) + ".json" ) ) . userAgent ( "Mozilla//5.0<seq2seq4repair_space>(X11;<seq2seq4repair_space>Linux<seq2seq4repair_space>x86_64)<seq2seq4repair_space>AppleWebKit//537.36<seq2seq4repair_space>(KHTML,<seq2seq4repair_space>like<seq2seq4repair_space>Gecko)<seq2seq4repair_space>Chrome//38.0.2125.104<seq2seq4repair_space>Safari//537.36" ) . ignoreContentType ( true ) . execute ( ) . body ( ) ; JSONObject hn_user_jo = new JSONObject ( result ) ; if ( hn_user_jo . has ( "karma" ) ) useritem . setHNKarma ( hn_user_jo . getLong ( "karma" ) ) ; } catch ( IOException ioe ) { } catch ( JSONException jsone ) { } } <START_BUG> if ( ( ( useritem . getKarmaPool ( ) ) != 0L ) || ( ( useritem . getLastKarmaPoolDrain ( ) ) < ( ( System . currentTimeMillis ( ) ) - ( ( useritem . getKarmaPoolTTLMins ( ) ) * 60000 ) ) ) ) { <END_BUG>

Fix:
if ( ( ( useritem . getKarmaPool ( ) ) != 0L ) && ( ( useritem . getLastKarmaPoolDrain ( ) ) < ( ( System . currentTimeMillis ( ) ) - ( ( useritem . getKarmaPoolTTLMins ( ) ) * 60000 ) ) ) ) {