Skip to content

Commit

Permalink
Add Bolt 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
injectives committed Jul 23, 2024
1 parent 6c63a14 commit 68e0a77
Show file tree
Hide file tree
Showing 10 changed files with 914 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.neo4j.driver.internal.messaging.v42.BoltProtocolV42;
import org.neo4j.driver.internal.messaging.v44.BoltProtocolV44;
import org.neo4j.driver.internal.messaging.v5.BoltProtocolV5;
import org.neo4j.driver.internal.messaging.v55.BoltProtocolV55;
import org.neo4j.driver.internal.messaging.v56.BoltProtocolV56;

public final class BoltProtocolUtil {
public static final int BOLT_MAGIC_PREAMBLE = 0x6060B017;
Expand All @@ -39,7 +39,7 @@ public final class BoltProtocolUtil {

private static final ByteBuf HANDSHAKE_BUF = unreleasableBuffer(copyInt(
BOLT_MAGIC_PREAMBLE,
BoltProtocolV55.VERSION.toIntRange(BoltProtocolV5.VERSION),
BoltProtocolV56.VERSION.toIntRange(BoltProtocolV5.VERSION),
BoltProtocolV44.VERSION.toIntRange(BoltProtocolV42.VERSION),
BoltProtocolV41.VERSION.toInt(),
BoltProtocolV3.VERSION.toInt()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.neo4j.driver.internal.messaging.v53.BoltProtocolV53;
import org.neo4j.driver.internal.messaging.v54.BoltProtocolV54;
import org.neo4j.driver.internal.messaging.v55.BoltProtocolV55;
import org.neo4j.driver.internal.messaging.v56.BoltProtocolV56;
import org.neo4j.driver.internal.spi.Connection;

public interface BoltProtocol {
Expand Down Expand Up @@ -214,6 +215,8 @@ static BoltProtocol forVersion(BoltProtocolVersion version) {
return BoltProtocolV54.INSTANCE;
} else if (BoltProtocolV55.VERSION.equals(version)) {
return BoltProtocolV55.INSTANCE;
} else if (BoltProtocolV56.VERSION.equals(version)) {
return BoltProtocolV56.INSTANCE;
}
throw new ClientException("Unknown protocol version: " + version);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [https://neo4j.com]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.neo4j.driver.internal.messaging.v56;

import org.neo4j.driver.internal.messaging.BoltProtocol;
import org.neo4j.driver.internal.messaging.BoltProtocolVersion;
import org.neo4j.driver.internal.messaging.v55.BoltProtocolV55;

public class BoltProtocolV56 extends BoltProtocolV55 {
public static final BoltProtocolVersion VERSION = new BoltProtocolVersion(5, 6);
public static final BoltProtocol INSTANCE = new BoltProtocolV56();

@Override
public BoltProtocolVersion version() {
return VERSION;
}

@Override
protected boolean useLegacyNotifications() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ private static GqlStatusObject extractGqlStatusObject(Value value) {
return new InternalGqlStatusObject(status, description, diagnosticRecord);
} else {
var title = value.get("title").asString();
var notificationDescription =
value.containsKey("description") ? value.get("description").asString() : description;

var positionValue = diagnosticRecord.get("_position");
InputPosition position = null;
Expand Down Expand Up @@ -427,7 +429,7 @@ private static GqlStatusObject extractGqlStatusObject(Value value) {
diagnosticRecord,
neo4jCode,
title,
description,
notificationDescription,
severity,
rawSeverity,
classification,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@
import org.neo4j.driver.internal.messaging.v3.BoltProtocolV3;
import org.neo4j.driver.internal.messaging.v41.BoltProtocolV41;
import org.neo4j.driver.internal.messaging.v44.BoltProtocolV44;
import org.neo4j.driver.internal.messaging.v55.BoltProtocolV55;
import org.neo4j.driver.internal.messaging.v56.BoltProtocolV56;

class BoltProtocolUtilTest {
@Test
void shouldReturnHandshakeBuf() {
assertByteBufContains(
handshakeBuf(),
BOLT_MAGIC_PREAMBLE,
(5 << 16) | BoltProtocolV55.VERSION.toInt(),
(6 << 16) | BoltProtocolV56.VERSION.toInt(),
(2 << 16) | BoltProtocolV44.VERSION.toInt(),
BoltProtocolV41.VERSION.toInt(),
BoltProtocolV3.VERSION.toInt());
}

@Test
void shouldReturnHandshakeString() {
assertEquals("[0x6060b017, 328965, 132100, 260, 3]", handshakeString());
assertEquals("[0x6060b017, 394757, 132100, 260, 3]", handshakeString());
}

@Test
Expand Down
Loading

0 comments on commit 68e0a77

Please sign in to comment.