Source:
<code>private AsyncFunction<Message.Response, Void> onStartupResponse(final ProtocolVersion protocolVersion, final Executor initExecutor) { return new AsyncFunction<Message.Response, Void>() { @Override public ListenableFuture<Void> apply(Message.Response response) throws Exception { switch (response.type) { case READY: return checkClusterName(protocolVersion, initExecutor); case ERROR: Responses.Error error = (Responses.Error) response; if ((error.code == ExceptionCode.PROTOCOL_ERROR || error.code == ExceptionCode.SERVER_ERROR) && <START> error.message.contains("Invalid or unsupported protocol version") || <END> error.message.contains("Beta version of the protocol used")) throw unsupportedProtocolVersionException(protocolVersion, error.serverProtocolVersion); throw new TransportException(address, String.format("Error initializing connection: %s", error.message)); case AUTHENTICATE: Responses.Authenticate authenticate = (Responses.Authenticate) response; Authenticator authenticator = factory.authProvider.newAuthenticator(address, authenticate.authenticator); switch (protocolVersion) { case V1: if (authenticator instanceof ProtocolV1Authenticator) return authenticateV1(authenticator, protocolVersion, initExecutor); else return authenticateV2(authenticator, protocolVersion, initExecutor); case V2: case V3: case V4: case V5: return authenticateV2(authenticator, protocolVersion, initExecutor); default: throw defunct(protocolVersion.unsupported()); } default: throw new TransportException(address, String.format("Unexpected %s response message from server to a STARTUP message", response.type)); } } }; }</code><technical_language>I precedence of boolean operators require parentheses here: ( error.code == ExceptionCode.PROTOCOL_ERROR || error.code == ExceptionCode.SERVER_ERROR ) && ( error.message.contains("Invalid unsupported protocol version") || error.message.contains("Beta version of protocol used") ) is enough detect "Beta version of protocol used" message, of error code</technical_language>

Target:
private AsyncFunction<Message.Response, Void> onStartupResponse(final ProtocolVersion protocolVersion, final Executor initExecutor) { return new AsyncFunction<Message.Response, Void>() { @Override public ListenableFuture<Void> apply(Message.Response response) throws Exception { switch (response.type) { case READY: return checkClusterName(protocolVersion, initExecutor); case ERROR: Responses.Error error = (Responses.Error) response; if ((error.code == ExceptionCode.PROTOCOL_ERROR || error.code == ExceptionCode.SERVER_ERROR) && error.message.contains("Invalid or unsupported protocol version")) throw unsupportedProtocolVersionException(protocolVersion, error.serverProtocolVersion); throw new TransportException(address, String.format("Error initializing connection: %s", error.message)); case AUTHENTICATE: Responses.Authenticate authenticate = (Responses.Authenticate) response; Authenticator authenticator; try { authenticator = factory.authProvider.newAuthenticator(address, authenticate.authenticator); } catch (AuthenticationException e) { incrementAuthErrorMetric(); throw e; } switch (protocolVersion) { case V1: if (authenticator instanceof ProtocolV1Authenticator) return authenticateV1(authenticator, protocolVersion, initExecutor); else return authenticateV2(authenticator, protocolVersion, initExecutor); case V2: case V3: case V4: case V5: return authenticateV2(authenticator, protocolVersion, initExecutor); default: throw defunct(protocolVersion.unsupported()); } default: throw new TransportException(address, String.format("Unexpected %s response message from server to a STARTUP message", response.type)); } } }; }