This is an automated email from the ASF dual-hosted git repository.
starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 9270ccc17b5 [fix](cluster)fix fe host may be contains Scope Identifier
(#52076)
9270ccc17b5 is described below
commit 9270ccc17b52a1832d404a78b18ef0a382bd1850
Author: zhangdong <[email protected]>
AuthorDate: Thu Jun 26 18:51:25 2025 +0800
[fix](cluster)fix fe host may be contains Scope Identifier (#52076)
fe host may be like: 2408:400a:5a:ea00:2fb5:112e:39dd:9bba%eth0
---
.../org/apache/doris/service/FrontendOptions.java | 15 ++++++-
.../apache/doris/service/FrontendOptionsTest.java | 51 ++++++++++++++++++++++
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendOptions.java
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendOptions.java
index 35b6d5e01e2..e578aea549e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendOptions.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendOptions.java
@@ -183,7 +183,20 @@ public class FrontendOptions {
// so we call localAddr.getCanonicalHostName() at here
return localAddr.getCanonicalHostName();
}
- return InetAddresses.toAddrString(localAddr);
+ return getIpByLocalAddr(localAddr);
+ }
+
+ /**
+ * get ip from addr
+ * @param addr InetAddress
+ * @return ip
+ */
+ public static String getIpByLocalAddr(InetAddress addr) {
+ String addrString = InetAddresses.toAddrString(addr);
+ if (addrString.contains("%")) {
+ addrString = addrString.split("%")[0];
+ }
+ return addrString;
}
private static void analyzePriorityCidrs() {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/service/FrontendOptionsTest.java
b/fe/fe-core/src/test/java/org/apache/doris/service/FrontendOptionsTest.java
new file mode 100755
index 00000000000..84a3e34702d
--- /dev/null
+++ b/fe/fe-core/src/test/java/org/apache/doris/service/FrontendOptionsTest.java
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.service;
+
+import org.apache.doris.common.AnalysisException;
+
+import com.google.common.net.InetAddresses;
+import mockit.Expectations;
+import mockit.Mocked;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.net.InetAddress;
+
+public class FrontendOptionsTest {
+ @Mocked
+ private InetAddresses inetAddresses;
+
+ @Before
+ public void setUp() throws NoSuchMethodException, SecurityException,
AnalysisException {
+ new Expectations() {
+ {
+ inetAddresses.toAddrString((InetAddress) any);
+ minTimes = 0;
+ result = "2408:400a:5a:ea00:2fb5:112e:39dd:9bba%eth0";
+ }
+ };
+ }
+
+ @Test
+ public void testGetIpByLocalAddr() {
+ String ip = FrontendOptions.getIpByLocalAddr(null);
+ Assert.assertEquals("2408:400a:5a:ea00:2fb5:112e:39dd:9bba", ip);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]