Skip to content

Commit 483bed8

Browse files
authored
Fix up BWC after backport of #65732 as #65601 (#65741)
Relates #65732 Relates #65601
1 parent bcea87f commit 483bed8

File tree

2 files changed

+34
-49
lines changed

2 files changed

+34
-49
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ tasks.register("verifyVersions") {
175175
* after the backport of the backcompat code is complete.
176176
*/
177177

178-
boolean bwc_tests_enabled = false
179-
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/65601" /* place a PR link here when committing bwc changes */
178+
boolean bwc_tests_enabled = true
179+
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
180180
if (bwc_tests_enabled == false) {
181181
if (bwc_tests_disabled_issue.isEmpty()) {
182182
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

server/src/main/java/org/elasticsearch/transport/TransportService.java

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,6 @@ private HandshakeRequest() {
490490

491491
public static class HandshakeResponse extends TransportResponse {
492492

493-
private static final Version BUILD_HASH_HANDSHAKE_VERSION = Version.V_8_0_0;
494-
495493
private final Version version;
496494

497495
@Nullable // if version < BUILD_HASH_HANDSHAKE_VERSION
@@ -510,60 +508,47 @@ public HandshakeResponse(Version version, String buildHash, DiscoveryNode discov
510508

511509
public HandshakeResponse(StreamInput in) throws IOException {
512510
super(in);
513-
if (in.getVersion().onOrAfter(BUILD_HASH_HANDSHAKE_VERSION)) {
514-
// the first two fields need only VInts and raw (ASCII) characters, so we cross our fingers and hope that they appear
515-
// on the wire as we expect them to even if this turns out to be an incompatible build
516-
version = Version.readVersion(in);
517-
buildHash = in.readString();
518-
519-
try {
520-
// If the remote node is incompatible then make an effort to identify it anyway, so we can mention it in the exception
521-
// message, but recognise that this may fail
522-
discoveryNode = new DiscoveryNode(in);
523-
} catch (Exception e) {
524-
if (isIncompatibleBuild(version, buildHash)) {
525-
throw new IllegalArgumentException("unidentifiable remote node is build [" + buildHash +
526-
"] of version [" + version + "] but this node is build [" + Build.CURRENT.hash() +
527-
"] of version [" + Version.CURRENT + "] which has an incompatible wire format", e);
528-
} else {
529-
throw e;
530-
}
531-
}
511+
// the first two fields need only VInts and raw (ASCII) characters, so we cross our fingers and hope that they appear
512+
// on the wire as we expect them to even if this turns out to be an incompatible build
513+
version = Version.readVersion(in);
514+
buildHash = in.readString();
532515

516+
try {
517+
// If the remote node is incompatible then make an effort to identify it anyway, so we can mention it in the exception
518+
// message, but recognise that this may fail
519+
discoveryNode = new DiscoveryNode(in);
520+
} catch (Exception e) {
533521
if (isIncompatibleBuild(version, buildHash)) {
534-
if (PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS) {
535-
logger.warn("remote node [{}] is build [{}] of version [{}] but this node is build [{}] of version [{}] " +
536-
"which may not be compatible; remove system property [{}] to resolve this warning",
537-
discoveryNode, buildHash, version, Build.CURRENT.hash(), Version.CURRENT,
538-
PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY);
539-
} else {
540-
throw new IllegalArgumentException("remote node [" + discoveryNode + "] is build [" + buildHash +
541-
"] of version [" + version + "] but this node is build [" + Build.CURRENT.hash() +
542-
"] of version [" + Version.CURRENT + "] which has an incompatible wire format");
543-
}
522+
throw new IllegalArgumentException("unidentifiable remote node is build [" + buildHash +
523+
"] of version [" + version + "] but this node is build [" + Build.CURRENT.hash() +
524+
"] of version [" + Version.CURRENT + "] which has an incompatible wire format", e);
525+
} else {
526+
throw e;
544527
}
528+
}
545529

546-
clusterName = new ClusterName(in);
547-
} else {
548-
discoveryNode = in.readOptionalWriteable(DiscoveryNode::new);
549-
clusterName = new ClusterName(in);
550-
version = Version.readVersion(in);
551-
buildHash = null;
530+
if (isIncompatibleBuild(version, buildHash)) {
531+
if (PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS) {
532+
logger.warn("remote node [{}] is build [{}] of version [{}] but this node is build [{}] of version [{}] " +
533+
"which may not be compatible; remove system property [{}] to resolve this warning",
534+
discoveryNode, buildHash, version, Build.CURRENT.hash(), Version.CURRENT,
535+
PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY);
536+
} else {
537+
throw new IllegalArgumentException("remote node [" + discoveryNode + "] is build [" + buildHash +
538+
"] of version [" + version + "] but this node is build [" + Build.CURRENT.hash() +
539+
"] of version [" + Version.CURRENT + "] which has an incompatible wire format");
540+
}
552541
}
542+
543+
clusterName = new ClusterName(in);
553544
}
554545

555546
@Override
556547
public void writeTo(StreamOutput out) throws IOException {
557-
if (out.getVersion().onOrAfter(BUILD_HASH_HANDSHAKE_VERSION)) {
558-
Version.writeVersion(version, out);
559-
out.writeString(buildHash);
560-
discoveryNode.writeTo(out);
561-
clusterName.writeTo(out);
562-
} else {
563-
out.writeOptionalWriteable(discoveryNode);
564-
clusterName.writeTo(out);
565-
Version.writeVersion(version, out);
566-
}
548+
Version.writeVersion(version, out);
549+
out.writeString(buildHash);
550+
discoveryNode.writeTo(out);
551+
clusterName.writeTo(out);
567552
}
568553

569554
public Version getVersion() {

0 commit comments

Comments
 (0)