Skip to content

Make reactive subscription request with Long.MAX_VALUE unbounded #1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public void installRecordConsumer( BiConsumer<Record,Throwable> recordConsumer )
@Override
public void request( long n )
{
if ( n == Long.MAX_VALUE )
{
n = -1;
}
pullHandler.request( n );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ void shouldPull()
verify( pullHandler ).request( 100 );
}

@Test
void shouldPullUnboundedOnLongMax()
{
// Given
RunResponseHandler runHandler = newRunResponseHandler();
PullResponseHandler pullHandler = mock( PullResponseHandler.class );
RxResultCursor cursor = new RxResultCursorImpl( runHandler, pullHandler );

// When
cursor.request( Long.MAX_VALUE );

// Then
verify( pullHandler ).request( -1 );
}

@Test
void shouldCancel()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ private CompletionStage<Record> consumeNextRecordOrCompletionSignal( RxBlockingS

private long getFetchSize( RxResultHolder resultHolder )
{
return resultHolder.getSessionHolder().getConfig()
.fetchSize()
.orElse( resultHolder.getSessionHolder().getDriverHolder().getConfig().fetchSize() );
long fetchSize = resultHolder.getSessionHolder().getConfig()
.fetchSize()
.orElse( resultHolder.getSessionHolder().getDriverHolder().getConfig().fetchSize() );
return fetchSize == -1 ? Long.MAX_VALUE : fetchSize;
}

private neo4j.org.testkit.backend.messages.responses.Record createResponse( Record record )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ public class StartTest implements TestkitRequest
skipMessage );
REACTIVE_SKIP_PATTERN_TO_REASON.put( "^.*\\.Routing[^.]+\\.test_should_retry_write_until_success_with_leader_change_using_tx_function$",
skipMessage );
skipMessage = "Fetch size -1 not supported";
REACTIVE_SKIP_PATTERN_TO_REASON.put( "^.*\\.NoRouting[^.]+\\.test_should_pull_all_when_fetch_is_minus_one_using_driver_configuration$", skipMessage );
REACTIVE_SKIP_PATTERN_TO_REASON.put( "^.*\\.TestIterationSessionRun\\.test_all$", skipMessage );
REACTIVE_SKIP_PATTERN_TO_REASON.put( "^.*\\.TestIterationSessionRun\\.test_all_slow_connection$", skipMessage );
REACTIVE_SKIP_PATTERN_TO_REASON.put( "^.*\\.TestIterationTxRun\\.test_all$", skipMessage );
REACTIVE_SKIP_PATTERN_TO_REASON.put( "^.*\\.TestIterationTxRun\\.test_all_slow_connection$", skipMessage );
REACTIVE_SKIP_PATTERN_TO_REASON.put( "^.*\\.TestSessionRun\\.test_discard_on_session_close_unfinished_result$",
"Does not support partially consumed state" );
REACTIVE_SKIP_PATTERN_TO_REASON.put( "^.*\\.NoRouting[^.]+\\.test_should_error_on_database_shutdown_using_tx_run$", "Session close throws error" );
Expand Down