use of org.neo4j.bolt.transport.pipeline.MessageDecoder in project neo4j by neo4j.
the class AbstractBoltProtocol method install.
/**
* Install chunker, packstream, message reader, message handler, message encoder for protocol v1
*/
@Override
public void install() {
BoltStateMachine stateMachine = stateMachineFactory.newStateMachine(version(), channel, connectionHints, memoryTracker);
var neo4jPack = createPack(memoryTracker);
var messageWriter = createMessageWriter(neo4jPack, logging, memoryTracker);
var connection = connectionFactory.newConnection(channel, stateMachine, messageWriter);
var messageReader = createMessageReader(connection, messageWriter, bookmarksParser, logging, channelProtector, memoryTracker);
memoryTracker.allocateHeap(ChunkDecoder.SHALLOW_SIZE + MessageAccumulator.SHALLOW_SIZE + MessageDecoder.SHALLOW_SIZE + HouseKeeper.SHALLOW_SIZE);
channel.installBoltProtocol(new ChunkDecoder(), new MessageAccumulator(config), new MessageDecoder(neo4jPack, messageReader, logging), new HouseKeeper(connection, logging.getInternalLog(HouseKeeper.class)));
}
use of org.neo4j.bolt.transport.pipeline.MessageDecoder in project neo4j by neo4j.
the class MessageDecoderTest method shouldLogContentOfTheMessageOnError.
@ParameterizedTest
@MethodSource("argumentsProvider")
public void shouldLogContentOfTheMessageOnError(Neo4jPack packerUnderTest) throws Exception {
this.packerUnderTest = packerUnderTest;
BoltRequestMessageReader requestMessageReader = mock(BoltRequestMessageReader.class);
RuntimeException error = new RuntimeException("Hello!");
doThrow(error).when(requestMessageReader).read(any());
LogService logService = mock(LogService.class);
Log log = mock(Log.class);
when(logService.getInternalLog(MessageDecoder.class)).thenReturn(log);
channel = new EmbeddedChannel(new MessageDecoder(packerUnderTest::newUnpacker, requestMessageReader, logService));
byte[] messageBytes = packMessageWithSignature(RunMessage.SIGNATURE);
var e = assertThrows(RuntimeException.class, () -> channel.writeInbound(Unpooled.wrappedBuffer(messageBytes)));
assertEquals(error, e);
assertMessageHexDumpLogged(log, messageBytes);
}
use of org.neo4j.bolt.transport.pipeline.MessageDecoder in project neo4j by neo4j.
the class MessageDecoderTest method shouldLogContentOfTheMessageOnIOError.
@ParameterizedTest
@MethodSource("argumentsProvider")
public void shouldLogContentOfTheMessageOnIOError(Neo4jPack packerUnderTest) throws Exception {
this.packerUnderTest = packerUnderTest;
BoltConnection connection = mock(BoltConnection.class);
BoltResponseMessageWriter responseMessageHandler = mock(BoltResponseMessageWriter.class);
BoltRequestMessageReader requestMessageReader = new BoltRequestMessageReaderV3(connection, responseMessageHandler, mock(ChannelProtector.class), NullLogService.getInstance());
LogService logService = mock(LogService.class);
Log log = mock(Log.class);
when(logService.getInternalLog(MessageDecoder.class)).thenReturn(log);
channel = new EmbeddedChannel(new MessageDecoder(packerUnderTest::newUnpacker, requestMessageReader, logService));
byte invalidMessageSignature = Byte.MAX_VALUE;
byte[] messageBytes = packMessageWithSignature(invalidMessageSignature);
assertThrows(BoltIOException.class, () -> channel.writeInbound(Unpooled.wrappedBuffer(messageBytes)));
assertMessageHexDumpLogged(log, messageBytes);
}
Aggregations