use of org.neo4j.bolt.runtime.BoltConnectionFatality in project neo4j by neo4j.
the class BoltConditions method verifyOneResponse.
public static void verifyOneResponse(ThrowingBiConsumer<BoltStateMachine, BoltResponseRecorder, BoltConnectionFatality> transition) throws Exception {
BoltStateMachine machine = newMachine();
BoltResponseRecorder recorder = new BoltResponseRecorder();
try {
transition.accept(machine, recorder);
} catch (BoltConnectionFatality connectionFatality) {
// acceptable for invalid transitions
}
assertEquals(1, recorder.responseCount());
}
use of org.neo4j.bolt.runtime.BoltConnectionFatality in project neo4j by neo4j.
the class AbstractBoltStateMachine method handleFailure.
@Override
public void handleFailure(Throwable cause, boolean fatal) throws BoltConnectionFatality {
if (ExceptionUtils.indexOfType(cause, BoltConnectionFatality.class) != -1) {
fatal = true;
}
Neo4jError error = fatal ? Neo4jError.fatalFrom(cause) : Neo4jError.from(cause);
fail(error);
if (error.isFatal()) {
if (ExceptionUtils.indexOfType(cause, AuthorizationExpiredException.class) != -1) {
throw new BoltConnectionAuthFatality("Failed to process a bolt message", cause);
}
if (cause instanceof AuthenticationException) {
throw new BoltConnectionAuthFatality((AuthenticationException) cause);
}
throw new BoltConnectionFatality("Failed to process a bolt message", cause);
}
}
use of org.neo4j.bolt.runtime.BoltConnectionFatality in project neo4j by neo4j.
the class BytesAccumulator method channelRead.
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
ByteBuf buf = (ByteBuf) msg;
count += buf.readableBytes();
if (count < 0) {
count = Long.MAX_VALUE;
}
if (count > limit) {
ctx.channel().close();
throw new BoltConnectionFatality(format("A connection '%s' is terminated because too many inbound bytes received " + "before the client is authenticated. Max bytes allowed: %s. Bytes received: %s.", ctx.channel(), limit, count), null);
}
super.channelRead(ctx, msg);
}
use of org.neo4j.bolt.runtime.BoltConnectionFatality in project neo4j by neo4j.
the class BoltStateMachineV4Test method actionsDisallowedBeforeInitialized.
@Test
void actionsDisallowedBeforeInitialized() {
// Given
BoltStateMachine machine = newMachine();
// When
try {
machine.process(BoltV4Messages.run(), nullResponseHandler());
fail("Failed to fail fatally");
}// Then
catch (BoltConnectionFatality e) {
// fatality correctly generated
}
}
Aggregations