From 24d995d6217aa341f1a308b197a6edeeddec871c Mon Sep 17 00:00:00 2001 From: tswstarplanet Date: Sun, 9 Dec 2018 23:23:33 +0800 Subject: [PATCH 1/2] optimize findConfigedPorts method of ServiceConfig to log only one time when userandom port --- .../src/main/java/org/apache/dubbo/config/ServiceConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java index 66e8d7fc426..0164442715d 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java @@ -653,8 +653,8 @@ private Integer findConfigedPorts(ProtocolConfig protocolConfig, String name, Ma if (portToBind == null || portToBind < 0) { portToBind = getAvailablePort(defaultPort); putRandomPort(name, portToBind); + logger.warn("Use random available port(" + portToBind + ") for protocol " + name); } - logger.warn("Use random available port(" + portToBind + ") for protocol " + name); } } From 7e88717fb59d63d58c5478db14192e74d1f6b323 Mon Sep 17 00:00:00 2001 From: tswstarplanet Date: Mon, 10 Dec 2018 12:47:56 +0800 Subject: [PATCH 2/2] move the log to method putRandomPort --- .../src/main/java/org/apache/dubbo/config/ServiceConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java index 0164442715d..579acd0d437 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java @@ -170,6 +170,7 @@ private static void putRandomPort(String protocol, Integer port) { protocol = protocol.toLowerCase(); if (!RANDOM_PORT_MAP.containsKey(protocol)) { RANDOM_PORT_MAP.put(protocol, port); + logger.warn("Use random available port(" + port + ") for protocol " + protocol); } } @@ -653,7 +654,6 @@ private Integer findConfigedPorts(ProtocolConfig protocolConfig, String name, Ma if (portToBind == null || portToBind < 0) { portToBind = getAvailablePort(defaultPort); putRandomPort(name, portToBind); - logger.warn("Use random available port(" + portToBind + ") for protocol " + name); } } }