Skip to content

Commit 47ecaea

Browse files
committed
Revert "Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (neo4j#708) (neo4j#718)"
This reverts commit 31d3495.
1 parent 6664215 commit 47ecaea

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

driver/src/main/java/org/neo4j/driver/internal/handlers/HelloResponseHandler.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,20 @@ public class HelloResponseHandler implements ResponseHandler
3737

3838
private final ChannelPromise connectionInitializedPromise;
3939
private final Channel channel;
40-
private final int protocolVersion;
4140

42-
public HelloResponseHandler( ChannelPromise connectionInitializedPromise, int protocolVersion )
41+
public HelloResponseHandler( ChannelPromise connectionInitializedPromise )
4342
{
4443
this.connectionInitializedPromise = connectionInitializedPromise;
4544
this.channel = connectionInitializedPromise.channel();
46-
this.protocolVersion = protocolVersion;
4745
}
4846

4947
@Override
5048
public void onSuccess( Map<String,Value> metadata )
5149
{
5250
try
5351
{
54-
// From Server V4 extracting server from metadata in the success message is unreliable
55-
// so we fix the Server version against the Bolt Protocol version for Server V4 and above.
56-
if ( protocolVersion == 4 )
57-
{
58-
setServerVersion( channel, ServerVersion.v4_0_0 );
59-
}
60-
else
61-
{
62-
setServerVersion( channel, extractNeo4jServerVersion( metadata ) );
63-
}
52+
ServerVersion serverVersion = extractNeo4jServerVersion( metadata );
53+
setServerVersion( channel, serverVersion );
6454

6555
String connectionId = extractConnectionId( metadata );
6656
setConnectionId( channel, connectionId );

driver/src/main/java/org/neo4j/driver/internal/messaging/v3/BoltProtocolV3.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void initializeChannel( String userAgent, Map<String,Value> authToken, Ch
8080
Channel channel = channelInitializedPromise.channel();
8181

8282
HelloMessage message = new HelloMessage( userAgent, authToken );
83-
HelloResponseHandler handler = new HelloResponseHandler( channelInitializedPromise, version() );
83+
HelloResponseHandler handler = new HelloResponseHandler( channelInitializedPromise );
8484

8585
messageDispatcher( channel ).enqueue( handler );
8686
channel.writeAndFlush( message, channel.voidPromise() );

driver/src/test/java/org/neo4j/driver/internal/handlers/HelloResponseHandlerTest.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
import org.neo4j.driver.internal.async.inbound.InboundMessageDispatcher;
3838
import org.neo4j.driver.internal.async.outbound.OutboundMessageHandler;
3939
import org.neo4j.driver.internal.messaging.v1.MessageFormatV1;
40+
<<<<<<< HEAD
4041
import org.neo4j.driver.internal.util.ServerVersion;
42+
=======
43+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
4144

4245
import static org.junit.jupiter.api.Assertions.assertEquals;
4346
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -74,7 +77,11 @@ void tearDown()
7477
void shouldSetServerVersionOnChannel()
7578
{
7679
ChannelPromise channelPromise = channel.newPromise();
80+
<<<<<<< HEAD
7781
HelloResponseHandler handler = new HelloResponseHandler( channelPromise, 3 );
82+
=======
83+
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );
84+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
7885

7986
Map<String,Value> metadata = metadata( anyServerVersion(), "bolt-1" );
8087
handler.onSuccess( metadata );
@@ -87,7 +94,11 @@ void shouldSetServerVersionOnChannel()
8794
void shouldThrowWhenServerVersionNotReturned()
8895
{
8996
ChannelPromise channelPromise = channel.newPromise();
97+
<<<<<<< HEAD
9098
HelloResponseHandler handler = new HelloResponseHandler( channelPromise, 3 );
99+
=======
100+
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );
101+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
91102

92103
Map<String,Value> metadata = metadata( null, "bolt-1" );
93104
assertThrows( UntrustedServerException.class, () -> handler.onSuccess( metadata ) );
@@ -100,7 +111,11 @@ void shouldThrowWhenServerVersionNotReturned()
100111
void shouldThrowWhenServerVersionIsNull()
101112
{
102113
ChannelPromise channelPromise = channel.newPromise();
114+
<<<<<<< HEAD
103115
HelloResponseHandler handler = new HelloResponseHandler( channelPromise, 3 );
116+
=======
117+
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );
118+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
104119

105120
Map<String,Value> metadata = metadata( Values.NULL, "bolt-x" );
106121
assertThrows( UntrustedServerException.class, () -> handler.onSuccess( metadata ) );
@@ -113,7 +128,11 @@ void shouldThrowWhenServerVersionIsNull()
113128
void shouldThrowWhenServerVersionCantBeParsed()
114129
{
115130
ChannelPromise channelPromise = channel.newPromise();
131+
<<<<<<< HEAD
116132
HelloResponseHandler handler = new HelloResponseHandler( channelPromise, 3 );
133+
=======
134+
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );
135+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
117136

118137
Map<String,Value> metadata = metadata( "WrongServerVersion", "bolt-x" );
119138
assertThrows( IllegalArgumentException.class, () -> handler.onSuccess( metadata ) );
@@ -123,6 +142,7 @@ void shouldThrowWhenServerVersionCantBeParsed()
123142
}
124143

125144
@Test
145+
<<<<<<< HEAD
126146
void shouldUseProtocolVersionForServerVersionWhenConnectedWithBoltV4()
127147
{
128148
ChannelPromise channelPromise = channel.newPromise();
@@ -141,6 +161,12 @@ void shouldSetConnectionIdOnChannel()
141161
{
142162
ChannelPromise channelPromise = channel.newPromise();
143163
HelloResponseHandler handler = new HelloResponseHandler( channelPromise, 3 );
164+
=======
165+
void shouldSetConnectionIdOnChannel()
166+
{
167+
ChannelPromise channelPromise = channel.newPromise();
168+
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );
169+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
144170

145171
Map<String,Value> metadata = metadata( anyServerVersion(), "bolt-42" );
146172
handler.onSuccess( metadata );
@@ -153,7 +179,11 @@ void shouldSetConnectionIdOnChannel()
153179
void shouldThrowWhenConnectionIdNotReturned()
154180
{
155181
ChannelPromise channelPromise = channel.newPromise();
182+
<<<<<<< HEAD
156183
HelloResponseHandler handler = new HelloResponseHandler( channelPromise, 3 );
184+
=======
185+
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );
186+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
157187

158188
Map<String,Value> metadata = metadata( anyServerVersion(), null );
159189
assertThrows( IllegalStateException.class, () -> handler.onSuccess( metadata ) );
@@ -166,7 +196,11 @@ void shouldThrowWhenConnectionIdNotReturned()
166196
void shouldThrowWhenConnectionIdIsNull()
167197
{
168198
ChannelPromise channelPromise = channel.newPromise();
199+
<<<<<<< HEAD
169200
HelloResponseHandler handler = new HelloResponseHandler( channelPromise, 3 );
201+
=======
202+
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );
203+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
170204

171205
Map<String,Value> metadata = metadata( anyServerVersion(), Values.NULL );
172206
assertThrows( IllegalStateException.class, () -> handler.onSuccess( metadata ) );
@@ -179,7 +213,11 @@ void shouldThrowWhenConnectionIdIsNull()
179213
void shouldCloseChannelOnFailure() throws Exception
180214
{
181215
ChannelPromise channelPromise = channel.newPromise();
216+
<<<<<<< HEAD
182217
HelloResponseHandler handler = new HelloResponseHandler( channelPromise, 3 );
218+
=======
219+
HelloResponseHandler handler = new HelloResponseHandler( channelPromise );
220+
>>>>>>> parent of 31d3495a... Since Server v4.0 the server agent received in response to the Hello message is unreliable. Instead, since the server and Bolt protocol versions are aligned, we use the protocol version instead for all connections to Server 4.0 and higher (#708) (#718)
183221

184222
RuntimeException error = new RuntimeException( "Hi!" );
185223
handler.onFailure( error );

0 commit comments

Comments
 (0)