Skip to content

Commit 3179c16

Browse files
committed
heartbeat: ignore "Connection has been closed" error
It can happen that connection is being closed between `isClosed()` from userEventTriggered `isClosed()` from `write()`. Which will result in netty event loop printing warning. Not a big deal, but it confuses QA in regards of the analyzing if this is a real error or not. So, let's just ignore it.
1 parent 30852a0 commit 3179c16

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

driver-core/src/main/java/com/datastax/driver/core/Connection.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,13 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
15921592
"{} was inactive for {} seconds, sending heartbeat",
15931593
Connection.this,
15941594
factory.configuration.getPoolingOptions().getHeartbeatIntervalSeconds());
1595-
write(HEARTBEAT_CALLBACK);
1595+
try {
1596+
write(HEARTBEAT_CALLBACK);
1597+
} catch (ConnectionException e) {
1598+
if (!e.getMessage().contains("Connection has been closed")) {
1599+
throw e;
1600+
}
1601+
}
15961602
}
15971603
}
15981604

0 commit comments

Comments
 (0)