@Test public void onFailure_alreadyCompleted() { final Connection connection = createConnection(); final RequestEntry entry = connection.newRequest( "DoStuff", false ); final Request request = new Request( connection, entry ); final SafeProcedure onFailure = () -> { }; request.onFailure( onFailure ); final IllegalStateException exception = expectThrows( IllegalStateException.class, () -> request.onFailure( onFailure ) ); assertEquals( exception.getMessage(), "Replicant-0074: Request.onFailure invoked on completed request Request(DoStuff)[Id=1]." ); }
public void onFailure( @Nonnull final SafeProcedure onError ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0074: Request.onFailure invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( false ); _entry.setExpectingResults( false ); _connection.completeRequest( _entry, Objects.requireNonNull( onError ) ); }
Request { public void onFailure( @Nonnull final SafeProcedure onError ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0074: Request.onFailure invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( false ); _entry.setExpectingResults( false ); _connection.completeRequest( _entry, Objects.requireNonNull( onError ) ); } }
Request { public void onFailure( @Nonnull final SafeProcedure onError ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0074: Request.onFailure invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( false ); _entry.setExpectingResults( false ); _connection.completeRequest( _entry, Objects.requireNonNull( onError ) ); } Request( @Nonnull final Connection connection, @Nonnull final RequestEntry entry ); }
Request { public void onFailure( @Nonnull final SafeProcedure onError ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0074: Request.onFailure invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( false ); _entry.setExpectingResults( false ); _connection.completeRequest( _entry, Objects.requireNonNull( onError ) ); } Request( @Nonnull final Connection connection, @Nonnull final RequestEntry entry ); @Nonnull String getConnectionId(); int getRequestId(); final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ); void onFailure( @Nonnull final SafeProcedure onError ); }
Request { public void onFailure( @Nonnull final SafeProcedure onError ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0074: Request.onFailure invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( false ); _entry.setExpectingResults( false ); _connection.completeRequest( _entry, Objects.requireNonNull( onError ) ); } Request( @Nonnull final Connection connection, @Nonnull final RequestEntry entry ); @Nonnull String getConnectionId(); int getRequestId(); final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ); void onFailure( @Nonnull final SafeProcedure onError );  }