Buggy code:
public abstract class ClusterListenerSupport implements ClientClusterService , ConnectionHeartbeatListener , ConnectionListener { private static final ILogger LOGGER = Logger . getLogger ( ClusterListenerSupport . class ) ; private static final long TERMINATE_TIMEOUT_SECONDS = 30 ; protected final HazelcastClientInstanceImpl client ; private final Collection < AddressProvider > addressProviders ; private final ClusterListenerSupport . ManagerAuthenticator managerAuthenticator = new ClusterListenerSupport . ManagerAuthenticator ( ) ; private final ExecutorService clusterExecutor ; private final boolean shuffleMemberList ; private Credentials credentials ; private ClientConnectionManager connectionManager ; private ClientMembershipListener clientMembershipListener ; private volatile Address ownerConnectionAddress ; private volatile ClientPrincipal principal ; public ClusterListenerSupport ( HazelcastClientInstanceImpl client , Collection < AddressProvider > addressProviders ) { } private ExecutorService createSingleThreadExecutorService ( HazelcastClientInstanceImpl client ) { } protected void init ( ) { } public Address getOwnerConnectionAddress ( ) { } public void shutdown ( ) { } private class ManagerAuthenticator implements Authenticator { @ Override public void authenticate ( ClientConnection connection ) throws AuthenticationException , IOException { final SerializationService ss = client . getSerializationService ( ) ; byte serializationVersion = ss . getVersion ( ) ; String uuid = null ; String ownerUuid = null ; if ( ( principal ) != null ) { uuid = principal . getUuid ( ) ; ownerUuid = principal . getOwnerUuid ( ) ; } ClientMessage clientMessage ; <START_BUG> if ( ( credentials ) instanceof UsernamePasswordCredentials ) { <END_BUG> UsernamePasswordCredentials cr = ( ( UsernamePasswordCredentials ) ( credentials ) ) ; clientMessage = ClientAuthenticationCodec . encodeRequest ( cr . getUsername ( ) , cr . getPassword ( ) , uuid , ownerUuid , true , JAVA , serializationVersion ) ; } else { Data data = ss . toData ( credentials ) ; clientMessage = ClientAuthenticationCustomCodec . encodeRequest ( data , uuid , ownerUuid , true , JAVA , serializationVersion ) ; } connection . init ( ) ; ClientMessage response ; final ClientInvocation clientInvocation = new ClientInvocation ( client , clientMessage , connection ) ; final Future < ClientMessage > future = clientInvocation . invoke ( ) ; try { response = future . get ( ) ; } catch ( Exception e ) { throw ExceptionUtil . rethrow ( e , IOException . class ) ; } ClientAuthenticationCodec . ResponseParameters result = ClientAuthenticationCodec . decodeResponse ( response ) ; AuthenticationStatus authenticationStatus = AuthenticationStatus . getById ( result . status ) ; switch ( authenticationStatus ) { case AUTHENTICATED : connection . setRemoteEndpoint ( result . address ) ; connection . setIsAuthenticatedAsOwner ( ) ; principal = new ClientPrincipal ( result . uuid , result . ownerUuid ) ; return ; case CREDENTIALS_FAILED : throw new AuthenticationException ( "Invalid<seq2seq4repair_space>credentials!" ) ; default : throw new AuthenticationException ( ( "Authentication<seq2seq4repair_space>status<seq2seq4repair_space>code<seq2seq4repair_space>not<seq2seq4repair_space>supported.<seq2seq4repair_space>status:" + authenticationStatus ) ) ; } } } protected void connectToCluster ( ) throws Exception { } private Collection < InetSocketAddress > getSocketAddresses ( ) { } public ClientPrincipal getPrincipal ( ) { } private void connectToOne ( ) throws Exception { } private boolean connect ( Set < InetSocketAddress > triedAddresses ) throws Exception { } private void fireConnectionEvent ( final LifecycleEvent . LifecycleState state ) { } @ Override public void connectionAdded ( Connection connection ) { } @ Override public void connectionRemoved ( Connection connection ) { } @ Override public void heartBeatStarted ( Connection connection ) { } @ Override public void heartBeatStopped ( Connection connection ) { } }

Fix:
if ( credentials . getClass ( ) . equals ( UsernamePasswordCredentials . class ) ) {