[ 
https://issues.apache.org/jira/browse/SCB-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16456074#comment-16456074
 ] 

ASF GitHub Bot commented on SCB-518:
------------------------------------

liubao68 closed pull request #676: [SCB-518] ServiceCenter ip address need to 
config default port
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/676
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
index b7bac4d74..8cf04d690 100644
--- 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
@@ -151,7 +151,7 @@ public static IpPort parseIpPortFromURI(String uriAddress) {
     }
   }
 
-  private static IpPort parseIpPort(String scheme, String authority) {
+  public static IpPort parseIpPort(String scheme, String authority) {
     if (authority == null)
       return null;
     int idx = authority.indexOf(':');
diff --git 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfig.java
 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfig.java
index 175dabad1..eb28ed72b 100644
--- 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfig.java
+++ 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ServiceRegistryConfig.java
@@ -42,8 +42,6 @@
 
   public static final ServiceRegistryConfig INSTANCE = new 
ServiceRegistryConfig();
 
-  private static final int PROTOCOL_HTTP_PORT = 80;
-
   private static final int DEFAULT_TIMEOUT_IN_MS = 30000;
 
   private static final int DEFAULT_TIMEOUT_IN_SECONDS = 30;
@@ -133,10 +131,8 @@ public boolean isSsl() {
     uriList.forEach(anUriList -> {
       try {
         URI uri = new URI(anUriList);
-        StringBuilder sb = new StringBuilder(uri.getHost());
-        sb.append(':').append(uri.getPort() < 0 ? PROTOCOL_HTTP_PORT : 
uri.getPort());
-        this.ssl = uri.getScheme().startsWith("https");
-        ipPortList.add(NetUtils.parseIpPort(sb.toString()));
+        this.ssl = "https".equals(uri.getScheme());
+        ipPortList.add(NetUtils.parseIpPort(uri.getScheme(), 
uri.getAuthority()));
       } catch (Exception e) {
         LOGGER.error("cse.service.registry.address invalid : {}", anUriList, 
e);
       }
diff --git 
a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
 
b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
index 4cfa5955b..9e1582281 100644
--- 
a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
+++ 
b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestServiceRegistryConfig.java
@@ -17,7 +17,10 @@
 
 package org.apache.servicecomb.serviceregistry.config;
 
+import java.util.List;
+
 import org.apache.commons.configuration.Configuration;
+import org.apache.servicecomb.foundation.common.net.IpPort;
 import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.junit.AfterClass;
 import org.junit.Assert;
@@ -30,6 +33,7 @@
   @BeforeClass
   public static void initClass() {
     ArchaiusUtils.resetConfig();
+    ArchaiusUtils.setProperty("cse.service.registry.address", 
"http://127.0.0.1, https://127.0.0.1";);
   }
 
   @AfterClass
@@ -45,7 +49,6 @@ public void testServiceRegistryConfig() {
     Assert.assertNotEquals(null, oConfig.getHeartbeatInterval());
     Assert.assertEquals("HTTP_1_1", oConfig.getHttpVersion().name());
     Assert.assertEquals("rest", oConfig.getTransport());
-    Assert.assertNotEquals(null, oConfig.getIpPort());
     Assert.assertEquals(1, oConfig.getWorkerPoolSize());
     Assert.assertEquals(true, oConfig.isSsl());
     Assert.assertEquals(30000, oConfig.getRequestTimeout());
@@ -57,6 +60,9 @@ public void testServiceRegistryConfig() {
     Assert.assertEquals(ServiceRegistryConfig.NO_TENANT, 
oConfig.getTenantName());
     Assert.assertEquals(null, oConfig.getSecretKey());
     
Assert.assertNull(ServiceRegistryConfig.INSTANCE.getMicroserviceVersionFactory());
+    List<IpPort> ipPorts = oConfig.getIpPort();
+    Assert.assertEquals("127.0.0.1:80", ipPorts.get(0).toString());
+    Assert.assertEquals("127.0.0.1:443", ipPorts.get(1).toString());
   }
 
   @Test


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> ServiceCenter ip address need to config default port
> ----------------------------------------------------
>
>                 Key: SCB-518
>                 URL: https://issues.apache.org/jira/browse/SCB-518
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Java-Chassis
>            Reporter: WeiChao
>            Assignee: WeiChao
>            Priority: Major
>
> for http/https, the default ports are 80 and 443. if port is not configured, 
> the default port needs to be used. this simplifies the configuration. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to