You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2023/02/07 09:29:33 UTC

[linkis] branch dev-1.3.2 updated: bugfix 4153 (#4154)

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

peacewong pushed a commit to branch dev-1.3.2
in repository https://gitbox.apache.org/repos/asf/linkis.git


The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
     new 4d1b4cf4f bugfix 4153 (#4154)
4d1b4cf4f is described below

commit 4d1b4cf4fad5f8927277f465b3e390e2cc4d5b2d
Author: 人生有如两个橘子 <15...@163.com>
AuthorDate: Tue Feb 7 17:29:27 2023 +0800

    bugfix 4153 (#4154)
---
 .../SpringCloudGatewayConfiguration.scala          | 24 ++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/SpringCloudGatewayConfiguration.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/SpringCloudGatewayConfiguration.scala
index 39fe9a064..dd1cf6c03 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/SpringCloudGatewayConfiguration.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/SpringCloudGatewayConfiguration.scala
@@ -158,14 +158,22 @@ class SpringCloudGatewayConfiguration {
           val serviceInstance = getServiceInstance(serviceId)
           logger.info("redirect to " + serviceInstance)
           val lb = this.getLoadBalancer(serviceInstance.getApplicationName)
-          val server =
-            lb.getAllServers.asScala.find(_.getHostPort == serviceInstance.getInstance).get
-          new RibbonLoadBalancerClient.RibbonServer(
-            serviceId,
-            server,
-            isSecure(server, serviceId),
-            serverIntrospectorFun(serviceId).getMetadata(server)
-          )
+          val serverOption =
+            lb.getAllServers.asScala.find(_.getHostPort == serviceInstance.getInstance)
+          if (serverOption.isDefined) {
+            val server = serverOption.get
+            new RibbonLoadBalancerClient.RibbonServer(
+              serviceId,
+              server,
+              isSecure(server, serviceId),
+              serverIntrospectorFun(serviceId).getMetadata(server)
+            )
+          } else {
+            logger.warn(
+              "RibbonLoadBalancer not have Server, execute default super choose method" + serviceInstance
+            )
+            super.choose(serviceInstance.getApplicationName, hint)
+          }
         } else super.choose(serviceId, hint)
 
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org