Skip to content
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

Ensure TcpConnector#connect does not emit error after success #967

Merged
merged 4 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
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 @@ -244,15 +244,16 @@ public void onSubscribe(final Cancellable cancellable) {
}

@Override
public void onSuccess(final C connection) {
requireNonNull(connection);
public void onSuccess(@Nullable final C connection) {
if (terminatedUpdater.compareAndSet(ConnectHandler.this, 0, 1)) {
target.onSuccess(connection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we assume that downstream target Subscriber will handle null instead of a connection? I think it's easy to assume from the caller side that it's expected to receive non-null connection. Was suggesting to invoke target.onError instead of throwing from onSuccess.

Copy link
Collaborator Author

@NiteshKant NiteshKant Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we assume that downstream target Subscriber will handle null instead of a connection?

Yes, in general in operators we pass-through what we get unless we use it.

Was suggesting to invoke target.onError instead of throwing from onSuccess.

I understood the suggestion but I am following the general pattern I mention above.

} else {
LOGGER.info("Connection {} created for a channel: {} but connect failed previously. " +
"Closing connection",
normanmaurer marked this conversation as resolved.
Show resolved Hide resolved
connection, channel);
normanmaurer marked this conversation as resolved.
Show resolved Hide resolved
connection.closeAsync().subscribe();
if (connection != null) {
connection.closeAsync().subscribe();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public NettyConnection<Buffer, Buffer> connectBlocking(ExecutionContext executio
}

/**
* Connect and await for the connection.
* Connect to the passed {@code address}.
*
* @param executionContext {@link ExecutionContext} to use for the connections.
* @param address to connect.
Expand Down