Skip to content

Commit fa59282

Browse files
committed
review feedback
1 parent 922e199 commit fa59282

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

driver/src/main/java/org/neo4j/driver/internal/async/connection/BoltProtocolUtil.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333

3434
public final class BoltProtocolUtil
3535
{
36-
// Represents the `TP` part of `HTTP` (0x48545450) which can be returned if connected to HTTP port
37-
public static final BoltProtocolVersion HTTP = new BoltProtocolVersion(80, 84 );
38-
3936
public static final int BOLT_MAGIC_PREAMBLE = 0x6060B017;
4037
public static final BoltProtocolVersion NO_PROTOCOL_VERSION = new BoltProtocolVersion( 0 , 0 );
4138

driver/src/main/java/org/neo4j/driver/internal/async/connection/HandshakeHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
import org.neo4j.driver.exceptions.SecurityException;
3939
import org.neo4j.driver.exceptions.ServiceUnavailableException;
4040

41-
import static org.neo4j.driver.internal.async.connection.BoltProtocolUtil.HTTP;
4241
import static org.neo4j.driver.internal.async.connection.BoltProtocolUtil.NO_PROTOCOL_VERSION;
42+
import static org.neo4j.driver.internal.messaging.BoltProtocolVersion.isHttp;
4343

4444
public class HandshakeHandler extends ReplayingDecoder<Void>
4545
{
@@ -144,7 +144,7 @@ private void handleUnknownSuggestedProtocolVersion( BoltProtocolVersion version,
144144
{
145145
fail( ctx, protocolNoSupportedByServerError() );
146146
}
147-
else if ( HTTP.equals( version ) )
147+
else if ( isHttp( version ) )
148148
{
149149
fail( ctx, httpEndpointError() );
150150
}

driver/src/main/java/org/neo4j/driver/internal/messaging/BoltProtocolVersion.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,11 @@ public int compareTo( BoltProtocolVersion other )
100100

101101
return result;
102102
}
103+
104+
public static boolean isHttp( BoltProtocolVersion protocolVersion )
105+
{
106+
// server would respond with `HTTP..` We read 4 bytes to figure out the version. The first two are not used
107+
// and therefore parse the `P` for major and `T` for minor.
108+
return protocolVersion.getMajorVersion() == 'P' && protocolVersion.getMinorVersion() == 'T';
109+
}
103110
}

driver/src/test/java/org/neo4j/driver/internal/async/connection/HandshakeHandlerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import static org.junit.jupiter.api.Assertions.assertNotNull;
5555
import static org.junit.jupiter.api.Assertions.assertNull;
5656
import static org.junit.jupiter.api.Assertions.assertThrows;
57-
import static org.neo4j.driver.internal.async.connection.BoltProtocolUtil.HTTP;
5857
import static org.neo4j.driver.internal.async.connection.BoltProtocolUtil.NO_PROTOCOL_VERSION;
5958
import static org.neo4j.driver.internal.async.connection.ChannelAttributes.setMessageDispatcher;
6059
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
@@ -209,7 +208,7 @@ void shouldFailGivenPromiseWhenServerSuggestsNoProtocol()
209208
@Test
210209
void shouldFailGivenPromiseWhenServerSuggestsHttp()
211210
{
212-
testFailure( HTTP, "Server responded HTTP" );
211+
testFailure( new BoltProtocolVersion( 'T', 'P' ), "Server responded HTTP" );
213212
}
214213

215214
@Test

0 commit comments

Comments
 (0)