Buggy code:
public class ApnsServerSimulator { private static final Logger logger = LoggerFactory . getLogger ( ApnsServerSimulator . class ) ; private static final char [ ] base = new char [ ] { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' } ; private static AtomicInteger threadNameCount = new AtomicInteger ( 0 ) ; private final Semaphore startUp = new Semaphore ( 0 ) ; private final ServerSocketFactory sslFactory ; private final InetAddress gatewayHost ; private final int gatewayPort ; private final InetAddress feedbackHost ; private final int feedbackPort ; private int effectiveGatewayPort ; private int effectiveFeedbackPort ; private final List < byte [ ] > badTokens = new ArrayList < byte [ ] > ( ) ; public ApnsServerSimulator ( ServerSocketFactory sslFactory , InetAddress gatewayHost , int gatewayPort , InetAddress feedbackHost , int feedbackPort ) { } Thread gatewayThread ; Thread feedbackThread ; ServerSocket gatewaySocket ; ServerSocket feedbackSocket ; public void start ( ) { } public void stop ( ) { } public int getEffectiveGatewayPort ( ) { } public int getEffectiveFeedbackPort ( ) { } protected void fail ( final byte status , final int identifier , final InputOutputSocket inputOutputSocket ) throws IOException { } protected void onNotification ( final ApnsServerSimulator . Notification notification , final InputOutputSocket inputOutputSocket ) throws IOException { } protected List < byte [ ] > getBadTokens ( ) { } public static ApnsServerSimulator prepareAndStart ( ServerSocketFactory socketFactory , InetAddress gatewayHost , int gatewayPort , InetAddress feedbackHost , int feedbackPort ) { } public static String encodeHex ( final byte [ ] bytes ) { } @ SuppressWarnings ( "UnusedDeclaration" ) public class Notification { private final int type ; private final int identifier ; private final int expiry ; private final byte [ ] deviceToken ; private final byte [ ] payload ; private final byte priority ; public Notification ( final int type , final byte [ ] deviceToken , final byte [ ] payload ) { } public Notification ( final int type , final int identifier , final int expiry , final byte [ ] deviceToken , final byte [ ] payload ) { } public Notification ( final int type , final int identifier , final int expiry , final byte [ ] deviceToken , final byte [ ] payload , final byte priority ) { } public byte [ ] getPayload ( ) { } public byte [ ] getDeviceToken ( ) { } public int getType ( ) { } public int getExpiry ( ) { } public int getIdentifier ( ) { } public byte getPriority ( ) { } @ Override public String toString ( ) { } } private class GatewayListener extends Thread { private GatewayListener ( ) { } public void run ( ) { } private void handleGatewayConnection ( final InputOutputSocket inputOutputSocket ) throws IOException { } private void parseNotifications ( final InputOutputSocket inputOutputSocket ) { } private void readFramedNotifications ( final InputOutputSocket inputOutputSocket ) throws IOException { } private Item get ( final Map < Byte , ApnsInputStream . Item > map , final byte idDeviceToken ) { } private void readEnhancedNotification ( final InputOutputSocket inputOutputSocket ) throws IOException { } private void readLegacyNotification ( final InputOutputSocket inputOutputSocket ) throws IOException { } private void resolveBadToken ( byte [ ] deviceToken ) { synchronized ( badTokens ) { String encoded = ApnsServerSimulator . encodeHex ( deviceToken ) ; <START_BUG> if ( encoded . toUpperCase ( ) . startsWith ( TOKEN_INVALIDATION_PREFIX . toUpperCase ( ) ) ) { <END_BUG> badTokens . add ( deviceToken ) ; } } } @ Override public void interrupt ( ) { } } private class FeedbackRunner extends Thread { private FeedbackRunner ( ) { } public void run ( ) { } private void handleFeedbackConnection ( final InputOutputSocket inputOutputSocket ) { } private void sendFeedback ( final InputOutputSocket inputOutputSocket ) throws IOException { } private void writeFeedback ( final InputOutputSocket inputOutputSocket , final byte [ ] token ) throws IOException { } } No newline ; at end ; of file ; }

Fix:
if ( encoded . toLowerCase ( ) . startsWith ( TOKEN_INVALIDATION_PREFIX ) ) {