Buggy code:
public class SaslContext { private static final String AUTHENTICATE = "AUTHENTICATE<seq2seq4repair_space>" ; private static final String AUTHENTICATE_ABORT = ( SaslContext . AUTHENTICATE ) + "*" ; private final Relay relay ; private SaslContext . AbstractState state ; public SaslContext ( final Relay relay ) { } private void setState ( final SaslContext . AbstractState state ) { } public void init ( ) { } public void confirm ( final String parameters , final String authzid , final String user , final String pass ) { } public void loggedIn ( ) { } public void success ( ) { } public void fail ( ) { } public void abort ( ) { } private static abstract class AbstractState { abstract void init ( final SaslContext context ) { } abstract void confirm ( SaslContext context , String parameters , String authzid , String user , String pass ) { } abstract void loggedIn ( SaslContext context ) { } abstract void success ( SaslContext context ) { } abstract void fail ( SaslContext context ) { } abstract void abort ( SaslContext context ) { } } private static final class InitialState extends SaslContext . AbstractState { @ Override void init ( final SaslContext context ) { } @ Override void confirm ( final SaslContext context , final String parameters , final String authzid , final String user , final String pass ) { } @ Override void loggedIn ( final SaslContext context ) { } @ Override void success ( final SaslContext context ) { } @ Override void fail ( final SaslContext context ) { } @ Override void abort ( final SaslContext context ) { } } private static final class SaslInitiate extends SaslContext . AbstractState { @ Override void init ( final SaslContext context ) { } @ Override void confirm ( final SaslContext context , final String parameters , final String authzid , final String user , final String pass ) { } private String createAuthenticateMessage ( final String authzid , final String user , final String pass ) { } protected static String encode ( final String authzid , final String user , final String pass ) { final StringBuilder response = new StringBuilder ( ) ; if ( authzid != null ) { response . append ( authzid ) ; } response . append ( '' ) . append ( user ) . append ( '' ) . append ( pass ) ; try { <START_BUG> return Base64 . encodeBase64String ( response . toString ( ) . getBytes ( "UTF-8" ) ) ; <END_BUG> } catch ( UnsupportedEncodingException e ) { throw new IllegalArgumentException ( "Unsupported<seq2seq4repair_space>encoding<seq2seq4repair_space>specified." , e ) ; } } @ Override void loggedIn ( final SaslContext context ) { } @ Override void success ( final SaslContext context ) { } @ Override void fail ( final SaslContext context ) { } @ Override void abort ( final SaslContext context ) { } } private static final class SaslConfirmed extends SaslContext . AbstractState { private boolean loggedIn ; private boolean successful ; private SaslConfirmed ( ) { } @ Override void init ( final SaslContext context ) { } @ Override void confirm ( final SaslContext context , final String parameters , final String authzid , final String user , final String pass ) { } @ Override void loggedIn ( final SaslContext context ) { } @ Override void success ( final SaslContext context ) { } @ Override void fail ( final SaslContext context ) { } @ Override void abort ( final SaslContext context ) { } } }

Fix:
return new String ( Base64 . encodeBase64 ( response . toString ( ) . getBytes ( "UTF-8" ) ) ) ;