use of org.neo4j.bolt.runtime.Neo4jError in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldSetPendingErrorOnMarkFailedIfNoHandler.
@Test
void shouldSetPendingErrorOnMarkFailedIfNoHandler() {
BoltStateMachineSPIImpl spi = mock(BoltStateMachineSPIImpl.class);
BoltChannel boltChannel = mock(BoltChannel.class);
var memoryTracker = mock(MemoryTracker.class);
BoltStateMachine machine = new BoltStateMachineV4(spi, boltChannel, Clock.systemUTC(), mock(DefaultDatabaseResolver.class), MapValue.EMPTY, memoryTracker);
Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
machine.markFailed(error);
assertEquals(error, pendingError(machine));
assertThat(machine).satisfies(inState(FailedState.class));
}
use of org.neo4j.bolt.runtime.Neo4jError in project neo4j by neo4j.
the class MessageProcessingHandlerTest method shouldLogShortWarningOnClientDisconnectMidwayThroughQuery.
@Test
void shouldLogShortWarningOnClientDisconnectMidwayThroughQuery() throws Exception {
// Connections dying is not exceptional per-se, so we don't need to fill the log with
// eye-catching stack traces; but it could be indicative of some issue, so log a brief
// warning in the debug log at least.
// Given
PackOutputClosedException outputClosed = new PackOutputClosedException("Output closed", "<client>");
Neo4jError txTerminated = Neo4jError.from(new TransactionTerminatedException(Status.Transaction.Terminated));
// When
AssertableLogProvider logProvider = emulateFailureWritingError(txTerminated, outputClosed);
// Then
assertThat(logProvider).forClass(getClass()).forLevel(WARN).containsMessageWithArguments("Client %s disconnected while query was running. Session has been cleaned up. " + "This can be caused by temporary network problems, but if you see this often, ensure your " + "applications are properly waiting for operations to complete before exiting.", "<client>");
}
use of org.neo4j.bolt.runtime.Neo4jError in project neo4j by neo4j.
the class BoltConnectionIT method shouldHandleFailureDuringResultPublishing.
@Test
void shouldHandleFailureDuringResultPublishing() throws Throwable {
// Given
var machine = newStateMachineAfterAuth();
var pullAllCallbackCalled = new CountDownLatch(1);
var error = new AtomicReference<Neo4jError>();
// When something fails while publishing the result stream
machine.process(run(), nullResponseHandler());
machine.process(pullAll(), new BoltResponseHandler() {
@Override
public boolean onPullRecords(BoltResult result, long size) throws Throwable {
throw new RuntimeException("Ooopsies!");
}
@Override
public boolean onDiscardRecords(BoltResult result, long size) throws Throwable {
throw new RuntimeException("Not this one!");
}
@Override
public void onMetadata(String key, AnyValue value) {
}
@Override
public void markFailed(Neo4jError err) {
error.set(err);
pullAllCallbackCalled.countDown();
}
@Override
public void markIgnored() {
}
@Override
public void onFinish() {
}
});
// Then
assertTrue(pullAllCallbackCalled.await(30, TimeUnit.SECONDS));
var err = error.get();
assertThat(err.status()).isEqualTo(Status.General.UnknownError);
assertThat(err.message()).contains("Ooopsies!");
}
Aggregations