This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new d685132942a branch-3.1: [fix](cluster)fix fe host may be contains
Scope Identifier #52076 (#52397)
d685132942a is described below
commit d685132942a6fd1256ee9493fd49b8f6c48adb57
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jun 27 13:36:14 2025 +0800
branch-3.1: [fix](cluster)fix fe host may be contains Scope Identifier
#52076 (#52397)
Cherry-picked from #52076
Co-authored-by: zhangdong <[email protected]>
---
.../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]