Skip to content

Commit e222e98

Browse files
luoyuxiawuchong
authored andcommitted
[hotfix] Fix old client can't connect to new server (#1086)
1 parent 13e96c3 commit e222e98

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

fluss-rpc/src/main/java/com/alibaba/fluss/rpc/netty/client/ServerApiVersions.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ final class ServerApiVersions {
3535
ServerApiVersions(Collection<PbApiVersion> serverApiVersions) {
3636
for (PbApiVersion serverVersion : serverApiVersions) {
3737
if (!ApiKeys.hasId(serverVersion.getApiKey())) {
38-
throw new IllegalArgumentException(
39-
"Server returned an API version which is not supported by this client: "
40-
+ serverVersion.getApiKey());
38+
continue;
4139
}
4240
ApiKeys apiKey = ApiKeys.forId(serverVersion.getApiKey());
4341
Optional<Short> version =
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2025 Alibaba Group Holding Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.alibaba.fluss.rpc.netty.client;
18+
19+
import com.alibaba.fluss.cluster.ServerType;
20+
import com.alibaba.fluss.rpc.messages.PbApiVersion;
21+
import com.alibaba.fluss.rpc.protocol.ApiKeys;
22+
import com.alibaba.fluss.rpc.protocol.ApiManager;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
import java.util.Set;
29+
30+
import static org.assertj.core.api.Assertions.assertThat;
31+
32+
/** The unit test for {@link ServerApiVersions}. */
33+
class ServerApiVersionsTest {
34+
35+
@Test
36+
void testClientUnSupportedApiVersions() {
37+
ApiManager apiManager = new ApiManager(ServerType.TABLET_SERVER);
38+
Set<ApiKeys> apiKeys = apiManager.enabledApis();
39+
List<PbApiVersion> apiVersions = new ArrayList<>();
40+
for (ApiKeys api : apiKeys) {
41+
apiVersions.add(
42+
new PbApiVersion()
43+
.setApiKey(api.id)
44+
.setMinVersion(api.lowestSupportedVersion)
45+
.setMaxVersion(api.highestSupportedVersion));
46+
}
47+
// add a api key that client don't support, we use -1 as apiKey to mock
48+
// the client unsupported api key
49+
apiVersions.add(new PbApiVersion().setApiKey(-1).setMinVersion(0).setMaxVersion(0));
50+
51+
ServerApiVersions serverApiVersions = new ServerApiVersions(apiVersions);
52+
// verify we get get highest available version for supported api key
53+
assertThat(serverApiVersions.highestAvailableVersion(ApiKeys.API_VERSIONS))
54+
.isEqualTo(ApiKeys.API_VERSIONS.highestSupportedVersion);
55+
}
56+
}

0 commit comments

Comments
 (0)