Buggy code:
void debug ( String msg ) { } void edebug ( String msg ) { } void error ( String msg ) { } class DiabloMinerFatalException extends Exception { public DiabloMinerFatalException ( String reason ) { } private static final long serialVersionUID = - 9022549833049053386L ; } class NetworkState { URL queryUrl ; URL longPollUrl ; String userPass ; int index ; final DiabloMiner . NetworkState . GetWorkAsync getWorkAsync = this . new GetWorkAsync ( ) ; final DiabloMiner . NetworkState . SendWorkAsync sendWorkAsync = this . new SendWorkAsync ( ) ; DiabloMiner . NetworkState . LongPollAsync longPollAsync = null ; int refresh ; boolean rollNTime ; NetworkState ( URL url , String user , String pass , int index ) { } JsonNode doJSONRPC ( boolean longPoll , boolean sendWork , ObjectNode requestMessage ) throws IOException { } void forceUpdate ( ) { } class GetWorkItem { JsonNode json ; boolean rollNtime ; long pulled = getNow ( ) ; GetWorkItem ( JsonNode json , boolean rollNTime ) { } } class SendWorkItem { ObjectNode message ; String deviceName ; DiabloMiner . DeviceState . ExecutionState . GetWorkParser getWork ; SendWorkItem ( ObjectNode message , String deviceName , DiabloMiner . DeviceState . ExecutionState . GetWorkParser getWork ) { } } class GetWorkAsync implements Runnable { LinkedBlockingDeque < DiabloMiner . DeviceState . ExecutionState . GetWorkParser > getWorkQueue = new LinkedBlockingDeque < DiabloMiner . DeviceState . ExecutionState . GetWorkParser > ( ) ; AtomicReference < DiabloMiner . NetworkState . GetWorkItem > queueIncoming = new AtomicReference < DiabloMiner . NetworkState . GetWorkItem > ( null ) ; public void run ( ) { while ( running . get ( ) ) { DiabloMiner . DeviceState . ExecutionState . GetWorkParser getWorkParser = null ; if ( ( queueIncoming . get ( ) ) == null ) { try { DiabloMiner . NetworkState . GetWorkItem getWorkItem = new DiabloMiner . NetworkState . GetWorkItem ( doJSONRPC ( false , false , getWorkMessage ) , rollNTime ) ; queueIncoming . compareAndSet ( null , getWorkItem ) ; } catch ( IOException e ) { error ( ( ( ( "Cannot<seq2seq4repair_space>connect<seq2seq4repair_space>to<seq2seq4repair_space>" + ( queryUrl . getHost ( ) ) ) + ":<seq2seq4repair_space>" ) + ( e . getLocalizedMessage ( ) ) ) ) ; } } try { getWorkParser = getWorkQueue . take ( ) ; } catch ( InterruptedException e ) { continue ; } if ( getWorkParser != null ) { if ( ( getWorkParser . resetTime ) < ( ( getNow ( ) ) - ( ( 100 * 60 ) * 1000 ) ) ) { getWorkParser . networkState = networkStates [ 0 ] ; getWorkParser . networkState . getWorkAsync . add ( getWorkParser ) ; getWorkParser . resetTime = getNow ( ) ; } else if ( ( ( donate ) && ( ( getWorkParser . networkState . index ) == 0 ) ) && ( ( getWorkParser . resetTime ) < ( ( getNow ( ) ) - ( 60 * 1000 ) ) ) ) { getWorkParser . networkState = networkStates [ 1 ] ; getWorkParser . networkState . getWorkAsync . add ( getWorkParser ) ; getWorkParser . resetTime = getNow ( ) ; } if ( ( queueIncoming . get ( ) ) != null ) { DiabloMiner . NetworkState . GetWorkItem getWorkItem = queueIncoming . getAndSet ( null ) ; if ( ( ( ( getWorkItem . pulled ) + ( refresh ) ) + 1000 ) > ( getNow ( ) ) ) { getWorkParser . getWorkIncoming . push ( getWorkItem ) ; } else { getWorkQueue . push ( getWorkParser ) ; } } else { if ( ( getWorkParser . networkState . index ) < ( ( networkStatesCount ) - 1 ) ) <START_BUG> getWorkParser . networkState = networkStates [ ( ( getWorkParser . networkState . index ) ++ ) ] ; <END_BUG> else getWorkParser . networkState = networkStates [ 0 ] ; getWorkParser . networkState . getWorkAsync . add ( getWorkParser ) ; try { Thread . sleep ( 250 ) ; } catch ( InterruptedException e1 ) { } } } } } void add ( DiabloMiner . DeviceState . ExecutionState . GetWorkParser getWorkParser ) { } } class SendWorkAsync implements Runnable { LinkedBlockingDeque < DiabloMiner . NetworkState . SendWorkItem > sendWorkQueue = new LinkedBlockingDeque < DiabloMiner . NetworkState . SendWorkItem > ( ) ; public void run ( ) { while ( running . get ( ) ) { DiabloMiner . NetworkState . SendWorkItem sendWorkItem = null ; boolean error = false ; try { sendWorkItem = sendWorkQueue . take ( ) ; } catch ( InterruptedException e ) { continue ; } while ( sendWorkItem != null ) { try { boolean accepted = doJSONRPC ( false , true , sendWorkItem . message ) . getBooleanValue ( ) ; if ( accepted ) { info ( ( ( ( ( ( queryUrl . getHost ( ) ) + "<seq2seq4repair_space>accepted<seq2seq4repair_space>block<seq2seq4repair_space>" ) + ( currentBlocks . incrementAndGet ( ) ) ) + "<seq2seq4repair_space>from<seq2seq4repair_space>" ) + ( sendWorkItem . deviceName ) ) ) ; } else { info ( ( ( ( ( ( queryUrl . getHost ( ) ) + "<seq2seq4repair_space>rejected<seq2seq4repair_space>block<seq2seq4repair_space>" ) + ( currentRejects . incrementAndGet ( ) ) ) + "<seq2seq4repair_space>from<seq2seq4repair_space>" ) + ( sendWorkItem . deviceName ) ) ) ; edebug ( ( ( ( ( ( ( "Rejected<seq2seq4repair_space>block<seq2seq4repair_space>" + ( ( float ) ( ( ( getNow ( ) ) - ( sendWorkItem . getWork . lastPulled ) ) // 1000.0 ) ) ) + "<seq2seq4repair_space>seconds<seq2seq4repair_space>old,<seq2seq4repair_space>roll<seq2seq4repair_space>ntime<seq2seq4repair_space>set<seq2seq4repair_space>to<seq2seq4repair_space>" ) + ( sendWorkItem . getWork . rollNTime ) ) + ",<seq2seq4repair_space>rolled<seq2seq4repair_space>" ) + ( sendWorkItem . getWork . rolledNTime ) ) + "<seq2seq4repair_space>times" ) ) ; sendWorkItem . getWork . networkState . getWorkAsync . add ( sendWorkItem . getWork ) ; } sendWorkItem = null ; }

Fix:
getWorkParser . networkState = networkStates [ ( ( getWorkParser . networkState . index ) + 1 ) ] ;