Skip to content
Merged
Changes from all 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 @@ -66,6 +66,7 @@
import org.elasticsearch.transport.ConnectTransportException;
import org.elasticsearch.transport.ConnectionProfile;
import org.elasticsearch.transport.TcpTransport;
import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportServiceAdapter;
import org.elasticsearch.transport.TransportSettings;
Expand Down Expand Up @@ -393,8 +394,11 @@ protected NodeChannels connectToChannels(DiscoveryNode node, ConnectionProfile p

@Override
protected void sendMessage(Channel channel, BytesReference reference, ActionListener<Channel> listener) {
final ChannelFuture future = channel.writeAndFlush(Netty4Utils.toByteBuf(reference));
future.addListener(f -> {
if (channel.eventLoop().isShuttingDown()) {
listener.onFailure(new TransportException("Cannot send message, event loop is shutting down."));
} else {
final ChannelFuture future = channel.writeAndFlush(Netty4Utils.toByteBuf(reference));
future.addListener(f -> {
if (f.isSuccess()) {
listener.onResponse(channel);
} else {
Expand All @@ -405,7 +409,8 @@ protected void sendMessage(Channel channel, BytesReference reference, ActionList
assert cause instanceof Exception;
listener.onFailure((Exception) cause);
}
});
});
}
}

@Override
Expand Down