Skip to content

Commit 64ba9b5

Browse files
committed
fix current version issue
1 parent 22e0cdb commit 64ba9b5

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

server/src/main/java/org/elasticsearch/TransportVersion.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Map;
2424
import java.util.ServiceLoader;
2525
import java.util.function.Function;
26+
import java.util.function.IntFunction;
2627
import java.util.stream.Collectors;
2728
import java.util.stream.Stream;
2829

@@ -177,7 +178,7 @@ public boolean isPatchFrom(TransportVersion version) {
177178
* if applicable for this deployment, otherwise the raw version number.
178179
*/
179180
public String toReleaseVersion() {
180-
return TransportVersions.VERSION_LOOKUP.apply(id);
181+
return VersionsHolder.VERSION_LOOKUP.apply(id);
181182
}
182183

183184
@Override
@@ -186,6 +187,7 @@ public String toString() {
186187
}
187188

188189
private static class VersionsHolder {
190+
private static final IntFunction<String> VERSION_LOOKUP;
189191
private static final List<TransportVersion> ALL_VERSIONS;
190192
private static final Map<Integer, TransportVersion> ALL_VERSIONS_MAP;
191193
private static final TransportVersion CURRENT;
@@ -204,6 +206,7 @@ private static class VersionsHolder {
204206

205207
ALL_VERSIONS_MAP = ALL_VERSIONS.stream().collect(Collectors.toUnmodifiableMap(TransportVersion::id, Function.identity()));
206208
CURRENT = ALL_VERSIONS.stream().max(TransportVersion::compareTo).get();
209+
VERSION_LOOKUP = ReleaseVersions.generateVersionsLookup(TransportVersions.class, CURRENT.id());
207210
}
208211
}
209212
}

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.Map;
2020
import java.util.Set;
2121
import java.util.TreeSet;
22-
import java.util.function.IntFunction;
2322

2423
/**
2524
* <p>Transport version is used to coordinate compatible wire protocol communication between nodes, at a fine-grained level. This replaces
@@ -383,16 +382,6 @@ static TransportVersion def(int id) {
383382
*/
384383
static final List<TransportVersion> DEFINED_VERSIONS = collectAllVersionIdsDefinedInClass(TransportVersions.class);
385384

386-
// the highest transport version constant defined
387-
static final TransportVersion LATEST_DEFINED;
388-
static {
389-
LATEST_DEFINED = DEFINED_VERSIONS.getLast();
390-
391-
// see comment on IDS field
392-
// now we're registered all the transport versions, we can clear the map
393-
IDS = null;
394-
}
395-
396385
public static List<TransportVersion> collectAllVersionIdsDefinedInClass(Class<?> cls) {
397386
Map<Integer, String> versionIdFields = new HashMap<>();
398387
List<TransportVersion> definedTransportVersions = new ArrayList<>();
@@ -434,8 +423,6 @@ public static List<TransportVersion> collectAllVersionIdsDefinedInClass(Class<?>
434423
return List.copyOf(definedTransportVersions);
435424
}
436425

437-
static final IntFunction<String> VERSION_LOOKUP = ReleaseVersions.generateVersionsLookup(TransportVersions.class, LATEST_DEFINED.id());
438-
439426
// no instance
440427
private TransportVersions() {}
441428
}

server/src/main/resources/org/elasticsearch/transport/esql-fixed-index-like.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "esql-fixed-index-like",
33
"ids": [
4-
9190000,
4+
9119000,
55
9112002,
66
8841064
77
]

0 commit comments

Comments
 (0)