Skip to content

Commit 19bd463

Browse files
Set version in versions map on successful handshake
After extensive review, we want to set this version to ensure that we have agreement between the connection itself and other parts of the code that rely on the versions map to validate user queries.
1 parent 4a398b1 commit 19bd463

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/java/org/apache/cassandra/net/OutboundConnection.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,11 +1118,7 @@ void onCompletedHandshake(Result<MessagingSuccess> result)
11181118

11191119
MessagingSuccess success = result.success();
11201120
messagingVersion = success.messagingVersion;
1121-
// We store the peer's endpoint version, not the version we connect on, which might
1122-
// be lower due to our own preferred version. This is indicated in the `InboundConnectionInitator`.
1123-
// We assert here to ensure that this assumption holds.
1124-
int endpointVersion = settings.endpointToVersion.get(settings.to);
1125-
assert messagingVersion <= endpointVersion : "Found " + messagingVersion + " > " + endpointVersion;
1121+
settings.endpointToVersion.set(settings.to, messagingVersion);
11261122
debug.onConnect(success.messagingVersion, settings);
11271123
state.disconnected().maintenance.cancel(false);
11281124

test/unit/org/apache/cassandra/net/ConnectionTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ public void testSendSmall() throws Throwable
336336

337337
// Ensure version is the same
338338
inbound.assertHandlersMessagingVersion(outbound.messagingVersion());
339+
Assert.assertEquals(outbound.settings().endpointToVersion.get(endpoint), outbound.messagingVersion());
339340
});
340341
}
341342

@@ -393,6 +394,7 @@ public long serializedSize(Object noPayload, int version)
393394

394395
// Ensure version is the same
395396
inbound.assertHandlersMessagingVersion(outbound.messagingVersion());
397+
Assert.assertEquals(outbound.settings().endpointToVersion.get(endpoint), outbound.messagingVersion());
396398
});
397399
}
398400

0 commit comments

Comments
 (0)