@ Override public void run ( ) throws Exception { this . storageManager . modifyRun ( MODEL_KEY , UserWriteModel . class , users -> { final Date timeout = new Date ( System . currentTimeMillis ( ) - getTimeout ( ) ) ; final Collection < UserEntity > updates = new LinkedList <> ( ) ; final Collection < String > removals = new LinkedList <> ( ) ; for ( final UserEntity user : users . asCollection ( ) ) { if ( user . getEmailTokenDate ( ) == null || user . getEmailTokenDate ( ) . after ( timeout ) ) { continue ; } // process timeout if ( user . isEmailVerified ( ) ) { user . setEmailToken ( null ) ; user . setEmailTokenDate ( null ) ; user . setEmailTokenSalt ( null ) ; updates . add ( user ) ; } else { // delete removals . add ( user . getId ( ) ) ; } } updates . forEach ( users :: putUser ) ; removals . forEach ( users :: removeUser ) ; } ) ; }
Clean up timed out user registrations