Skip to content

Commit b53c708

Browse files
authored
Add Bolt 4.4 support (#1026)
This initial update brings 4.4 support that is based on 4.3.
1 parent d950a3a commit b53c708

File tree

11 files changed

+1038
-6
lines changed

11 files changed

+1038
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.neo4j.driver.internal.messaging.v4.BoltProtocolV4;
2626
import org.neo4j.driver.internal.messaging.v41.BoltProtocolV41;
2727
import org.neo4j.driver.internal.messaging.v42.BoltProtocolV42;
28-
import org.neo4j.driver.internal.messaging.v43.BoltProtocolV43;
28+
import org.neo4j.driver.internal.messaging.v44.BoltProtocolV44;
2929

3030
import static io.netty.buffer.Unpooled.copyInt;
3131
import static io.netty.buffer.Unpooled.unreleasableBuffer;
@@ -42,7 +42,7 @@ public final class BoltProtocolUtil
4242

4343
private static final ByteBuf HANDSHAKE_BUF = unreleasableBuffer( copyInt(
4444
BOLT_MAGIC_PREAMBLE,
45-
BoltProtocolV43.VERSION.toIntRange( BoltProtocolV42.VERSION ),
45+
BoltProtocolV44.VERSION.toIntRange( BoltProtocolV42.VERSION ),
4646
BoltProtocolV41.VERSION.toInt(),
4747
BoltProtocolV4.VERSION.toInt(),
4848
BoltProtocolV3.VERSION.toInt() ) ).asReadOnly();

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.neo4j.driver.internal.messaging.v41.BoltProtocolV41;
4141
import org.neo4j.driver.internal.messaging.v42.BoltProtocolV42;
4242
import org.neo4j.driver.internal.messaging.v43.BoltProtocolV43;
43+
import org.neo4j.driver.internal.messaging.v44.BoltProtocolV44;
4344
import org.neo4j.driver.internal.spi.Connection;
4445

4546
import static org.neo4j.driver.internal.async.connection.ChannelAttributes.protocolVersion;
@@ -166,6 +167,10 @@ else if ( BoltProtocolV43.VERSION.equals( version ) )
166167
{
167168
return BoltProtocolV43.INSTANCE;
168169
}
170+
else if ( BoltProtocolV44.VERSION.equals( version ) )
171+
{
172+
return BoltProtocolV44.INSTANCE;
173+
}
169174
throw new ClientException( "Unknown protocol version: " + version );
170175
}
171176
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.internal.messaging.v44;
20+
21+
import org.neo4j.driver.internal.messaging.BoltProtocol;
22+
import org.neo4j.driver.internal.messaging.BoltProtocolVersion;
23+
import org.neo4j.driver.internal.messaging.MessageFormat;
24+
import org.neo4j.driver.internal.messaging.v43.BoltProtocolV43;
25+
26+
/**
27+
* Definition of the Bolt Protocol 4.4
28+
*/
29+
public class BoltProtocolV44 extends BoltProtocolV43
30+
{
31+
public static final BoltProtocolVersion VERSION = new BoltProtocolVersion( 4, 4 );
32+
public static final BoltProtocol INSTANCE = new BoltProtocolV44();
33+
34+
@Override
35+
public MessageFormat createMessageFormat()
36+
{
37+
return new MessageFormatV44();
38+
}
39+
40+
@Override
41+
public BoltProtocolVersion version()
42+
{
43+
return VERSION;
44+
}
45+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.internal.messaging.v44;
20+
21+
import org.neo4j.driver.internal.messaging.MessageFormat;
22+
import org.neo4j.driver.internal.messaging.common.CommonMessageReader;
23+
import org.neo4j.driver.internal.packstream.PackInput;
24+
import org.neo4j.driver.internal.packstream.PackOutput;
25+
26+
/**
27+
* Bolt message format v4.4
28+
*/
29+
public class MessageFormatV44 implements MessageFormat
30+
{
31+
@Override
32+
public MessageFormat.Writer newWriter( PackOutput output )
33+
{
34+
return new MessageWriterV44( output );
35+
}
36+
37+
@Override
38+
public MessageFormat.Reader newReader( PackInput input )
39+
{
40+
return new CommonMessageReader( input );
41+
}
42+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.internal.messaging.v44;
20+
21+
import java.util.Map;
22+
23+
import org.neo4j.driver.internal.messaging.AbstractMessageWriter;
24+
import org.neo4j.driver.internal.messaging.MessageEncoder;
25+
import org.neo4j.driver.internal.messaging.common.CommonValuePacker;
26+
import org.neo4j.driver.internal.messaging.encode.BeginMessageEncoder;
27+
import org.neo4j.driver.internal.messaging.encode.CommitMessageEncoder;
28+
import org.neo4j.driver.internal.messaging.encode.DiscardMessageEncoder;
29+
import org.neo4j.driver.internal.messaging.encode.GoodbyeMessageEncoder;
30+
import org.neo4j.driver.internal.messaging.encode.HelloMessageEncoder;
31+
import org.neo4j.driver.internal.messaging.encode.PullMessageEncoder;
32+
import org.neo4j.driver.internal.messaging.encode.ResetMessageEncoder;
33+
import org.neo4j.driver.internal.messaging.encode.RollbackMessageEncoder;
34+
import org.neo4j.driver.internal.messaging.encode.RouteMessageEncoder;
35+
import org.neo4j.driver.internal.messaging.encode.RunWithMetadataMessageEncoder;
36+
import org.neo4j.driver.internal.messaging.request.BeginMessage;
37+
import org.neo4j.driver.internal.messaging.request.CommitMessage;
38+
import org.neo4j.driver.internal.messaging.request.DiscardMessage;
39+
import org.neo4j.driver.internal.messaging.request.GoodbyeMessage;
40+
import org.neo4j.driver.internal.messaging.request.HelloMessage;
41+
import org.neo4j.driver.internal.messaging.request.PullMessage;
42+
import org.neo4j.driver.internal.messaging.request.ResetMessage;
43+
import org.neo4j.driver.internal.messaging.request.RollbackMessage;
44+
import org.neo4j.driver.internal.messaging.request.RouteMessage;
45+
import org.neo4j.driver.internal.messaging.request.RunWithMetadataMessage;
46+
import org.neo4j.driver.internal.packstream.PackOutput;
47+
import org.neo4j.driver.internal.util.Iterables;
48+
49+
/**
50+
* Bolt message writer v4.4
51+
*/
52+
public class MessageWriterV44 extends AbstractMessageWriter
53+
{
54+
public MessageWriterV44( PackOutput output )
55+
{
56+
super( new CommonValuePacker( output ), buildEncoders() );
57+
}
58+
59+
private static Map<Byte,MessageEncoder> buildEncoders()
60+
{
61+
Map<Byte,MessageEncoder> result = Iterables.newHashMapWithSize( 9 );
62+
result.put( HelloMessage.SIGNATURE, new HelloMessageEncoder() );
63+
result.put( GoodbyeMessage.SIGNATURE, new GoodbyeMessageEncoder() );
64+
result.put( RunWithMetadataMessage.SIGNATURE, new RunWithMetadataMessageEncoder() );
65+
result.put( RouteMessage.SIGNATURE, new RouteMessageEncoder() );
66+
67+
result.put( DiscardMessage.SIGNATURE, new DiscardMessageEncoder() );
68+
result.put( PullMessage.SIGNATURE, new PullMessageEncoder() );
69+
70+
result.put( BeginMessage.SIGNATURE, new BeginMessageEncoder() );
71+
result.put( CommitMessage.SIGNATURE, new CommitMessageEncoder() );
72+
result.put( RollbackMessage.SIGNATURE, new RollbackMessageEncoder() );
73+
74+
result.put( ResetMessage.SIGNATURE, new ResetMessageEncoder() );
75+
return result;
76+
}
77+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.neo4j.driver.internal.messaging.v3.BoltProtocolV3;
2626
import org.neo4j.driver.internal.messaging.v4.BoltProtocolV4;
2727
import org.neo4j.driver.internal.messaging.v41.BoltProtocolV41;
28-
import org.neo4j.driver.internal.messaging.v43.BoltProtocolV43;
28+
import org.neo4j.driver.internal.messaging.v44.BoltProtocolV44;
2929

3030
import static org.junit.jupiter.api.Assertions.assertEquals;
3131
import static org.neo4j.driver.internal.async.connection.BoltProtocolUtil.BOLT_MAGIC_PREAMBLE;
@@ -43,15 +43,15 @@ void shouldReturnHandshakeBuf()
4343
{
4444
assertByteBufContains(
4545
handshakeBuf(),
46-
BOLT_MAGIC_PREAMBLE, (1 << 16) | BoltProtocolV43.VERSION.toInt(), BoltProtocolV41.VERSION.toInt(),
46+
BOLT_MAGIC_PREAMBLE, (2 << 16) | BoltProtocolV44.VERSION.toInt(), BoltProtocolV41.VERSION.toInt(),
4747
BoltProtocolV4.VERSION.toInt(), BoltProtocolV3.VERSION.toInt()
4848
);
4949
}
5050

5151
@Test
5252
void shouldReturnHandshakeString()
5353
{
54-
assertEquals( "[0x6060b017, 66308, 260, 4, 3]", handshakeString() );
54+
assertEquals( "[0x6060b017, 132100, 260, 4, 3]", handshakeString() );
5555
}
5656

5757
@Test

0 commit comments

Comments
 (0)