This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new ef7eaef7 fix(instance): normalize endpoint types with root locale 
(#1486)
ef7eaef7 is described below

commit ef7eaef78a570e18c2a38145b8500b61f2c65c4c
Author: yyqdbngt <[email protected]>
AuthorDate: Tue Aug 11 17:46:27 2026 +0800

    fix(instance): normalize endpoint types with root locale (#1486)
    
    Co-authored-by: yyqdbngt <[email protected]>
---
 .../rocketmq/studio/instance/InstanceService.java  |  3 +-
 .../studio/instance/InstanceServiceTest.java       | 36 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/instance/InstanceService.java 
b/server/src/main/java/org/apache/rocketmq/studio/instance/InstanceService.java
index 17aa068c..f0050857 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/instance/InstanceService.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/instance/InstanceService.java
@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Locale;
 import java.util.UUID;
 
 @Slf4j
@@ -159,7 +160,7 @@ public class InstanceService {
         if (endpointType == null) {
             return 2;
         }
-        return switch (endpointType.toUpperCase()) {
+        return switch (endpointType.toUpperCase(Locale.ROOT)) {
             case "TCP_VPC" -> 0;
             case "TCP_INTERNET" -> 1;
             default -> 2;
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/instance/InstanceServiceTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/instance/InstanceServiceTest.java
index 370dc553..fe314a20 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/instance/InstanceServiceTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/instance/InstanceServiceTest.java
@@ -36,6 +36,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
 
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Locale;
 import java.util.Optional;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -791,6 +792,41 @@ class InstanceServiceTest {
         assertThat(created.getType()).isEqualTo(InstanceType.PROXY);
     }
 
+    @Test
+    void 
createInstanceShouldPrioritizeEndpointsIndependentlyOfDefaultLocaleTest() {
+        InstanceVO instance = InstanceVO.builder()
+                .vendor(InstanceVendor.ALIYUN)
+                .credentialId("cred-1")
+                .cloudInstanceId("rmq-cn-xxx")
+                .regionId("cn-hangzhou")
+                .build();
+        CloudCredentialVO credential = new CloudCredentialVO();
+        credential.setId("cred-1");
+        credential.setVendor(InstanceVendor.ALIYUN);
+        
when(cloudCredentialRepository.findById("cred-1")).thenReturn(Optional.of(credential));
+        CloudCatalogProvider catalog = 
org.mockito.Mockito.mock(CloudCatalogProvider.class);
+        CloudInstanceDetailVO detail = new CloudInstanceDetailVO();
+        detail.setInstanceId("rmq-cn-xxx");
+        detail.setInstanceName("prod-mq");
+        detail.setEndpoints(List.of(
+                new CloudInstanceDetailVO.CloudEndpoint("unknown", 
"fallback:8080"),
+                new CloudInstanceDetailVO.CloudEndpoint("tcp_internet", 
"public:8080")));
+        
when(providerRegistry.catalogFor(InstanceVendor.ALIYUN)).thenReturn(catalog);
+        when(catalog.getCloudInstance("cred-1", "cn-hangzhou", 
"rmq-cn-xxx")).thenReturn(detail);
+        
when(instanceRepository.save(any(InstanceVO.class))).thenAnswer(invocation -> 
invocation.getArgument(0));
+        Locale originalLocale = Locale.getDefault();
+
+        InstanceVO created;
+        try {
+            Locale.setDefault(Locale.forLanguageTag("tr-TR"));
+            created = instanceService.createInstance(instance);
+        } finally {
+            Locale.setDefault(originalLocale);
+        }
+
+        assertThat(created.getEndpoint()).isEqualTo("public:8080");
+    }
+
     @Test
     void createInstanceShouldResolveTencentEndpointFromCatalogTest() {
         InstanceVO instance = InstanceVO.builder()

Reply via email to