Buggy code:
public class DataEndpointGroup implements DataEndpointFailureCallback { private static final Log log = LogFactory . getLog ( DataEndpointGroup . class ) ; private List < DataEndpoint > dataEndpoints ; private DataEndpointGroup . HAType haType ; private DataEndpointGroup . EventQueue eventQueue ; private int reconnectionInterval ; private AtomicInteger currentDataPublisherIndex = new AtomicInteger ( ) ; private AtomicInteger maximumDataPublisherIndex = new AtomicInteger ( ) ; private ScheduledExecutorService reconnectionService ; private final Integer START_INDEX = 0 ; public enum HAType { FAILOVER , LOADBALANCE ; } public DataEndpointGroup ( DataEndpointGroup . HAType haType , DataEndpointAgent agent ) { } public void addDataEndpoint ( DataEndpoint dataEndpoint ) { } public void tryPublish ( Event event ) throws EventQueueFullException { } public void tryPublish ( Event event , long timeoutMS ) throws EventQueueFullException { } public void publish ( Event event ) { } class EventQueue { private RingBuffer < WrappedEventFactory . WrappedEvent > ringBuffer ; private Disruptor < WrappedEventFactory . WrappedEvent > eventQueueDisruptor ; private ExecutorService eventQueuePool ; EventQueue ( int queueSize ) { } private void tryPut ( Event event ) throws EventQueueFullException { } private void tryPut ( Event event , long timeoutMS ) throws EventQueueFullException { } private void put ( Event event ) { } private void shutdown ( ) { } } class EventQueueWorker implements EventHandler < WrappedEventFactory . WrappedEvent > { @ Override public void onEvent ( WrappedEventFactory . WrappedEvent wrappedEvent , long sequence , boolean endOfBatch ) throws Exception { } } private void flushAllDataEndpoints ( ) { } private DataEndpoint getDataEndpoint ( boolean isBusyWait ) { int startIndex ; <START_BUG> if ( haType . equals ( DataEndpointGroup . HAType . FAILOVER ) ) { <END_BUG> startIndex = getDataPublisherIndex ( ) ; } else { startIndex = START_INDEX ; } int index = startIndex ; while ( true ) { DataEndpoint dataEndpoint = dataEndpoints . get ( index ) ; if ( dataEndpoint . getState ( ) . equals ( ACTIVE ) ) { return dataEndpoint ; } else if ( ( haType . equals ( DataEndpointGroup . HAType . FAILOVER ) ) && ( ( dataEndpoint . getState ( ) . equals ( BUSY ) ) || ( dataEndpoint . getState ( ) . equals ( INITIALIZING ) ) ) ) { busyWait ( 1 ) ; } else { index ++ ; if ( index > ( ( maximumDataPublisherIndex . get ( ) ) - 1 ) ) { index = START_INDEX ; } if ( index == startIndex ) { if ( isBusyWait ) { if ( ! ( reconnectionService . isShutdown ( ) ) ) { busyWait ( 1 ) ; } else { if ( ! ( isActiveDataEndpointExists ( ) ) ) { return null ; } else { busyWait ( 1 ) ; } } } else { return null ; } } } } } private void busyWait ( long timeInMilliSec ) { } private boolean isActiveDataEndpointExists ( ) { } private synchronized int getDataPublisherIndex ( ) { } public void tryResendEvents ( List < Event > events ) { } private List < Event > trySendActiveEndpoints ( List < Event > events ) { } private class ReconnectionTask implements Runnable { public void run ( ) { } private boolean isServerExists ( String ip , int port ) { } } public String toString ( ) { } public void shutdown ( ) { } }

Fix:
if ( haType . equals ( DataEndpointGroup . HAType . LOADBALANCE ) ) {