Elffuss BraidHub

kikocis/java-driver public

Force the underlying connection in ControlConnection.closeAsync().

Otherwise the connection's future might not complete properly, if there
was an in-flight request at the time when closeAsync() was called.

Also force() in other places where we close the connection, to ensure
the channel gets closed.
Changeset7857e4b97bd65ab03f2d4a79c2d3ae101fe8a9c00ef3350c4a760ba6e90b22f2
Authorolim7t <omichallat+github@gmail.com> · 2016-03-31 15:44 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2016-03-31 15:44 +02:00
Parents8e2317fde2d3

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +5 −5
@@ -88,7 +88,7 @@
8888 r.cancel(false);
8989
9090 Connection connection = connectionRef.get();
91- return connection == null ? CloseFuture.immediateFuture() : connection.closeAsync();
91+ return connection == null ? CloseFuture.immediateFuture() : connection.closeAsync().force();
9292 }
9393
9494 Host connectedHost() {
@@ -136,7 +136,7 @@
136136 @Override
137137 protected void onReconnection(Connection connection) {
138138 if (isShutdown) {
139- connection.closeAsync();
139+ connection.closeAsync().force();
140140 return;
141141 }
142142
@@ -170,7 +170,7 @@
170170 private void signalError() {
171171 Connection connection = connectionRef.get();
172172 if (connection != null)
173- connection.closeAsync();
173+ connection.closeAsync().force();
174174
175175 // If the error caused the host to go down, onDown might have already triggered a reconnect.
176176 // But backgroundReconnect knows how to deal with that.
@@ -182,7 +182,7 @@
182182 newConnection.setOwner(this);
183183 Connection old = connectionRef.getAndSet(newConnection);
184184 if (old != null && !old.isClosed())
185- old.closeAsync();
185+ old.closeAsync().force();
186186 }
187187
188188 private Connection reconnectInternal(Iterator<Host> iter, boolean isInitialConnection) throws UnsupportedProtocolVersionException {
@@ -717,7 +717,7 @@
717717 logger.debug("[Control connection] {} is down/removed and it was the control host, triggering reconnect",
718718 current.address);
719719 if (!current.isClosed())
720- current.closeAsync();
720+ current.closeAsync().force();
721721 backgroundReconnect(0);
722722 }
723723 }