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 2022/08/30 11:50:26 UTC

[incubator-linkis] branch dev-1.3.0 updated: [linkis-gateway-httpclient-support] Modification of scala file floati… (#3130)

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

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


The following commit(s) were added to refs/heads/dev-1.3.0 by this push:
     new 6cbd3f42b [linkis-gateway-httpclient-support] Modification of scala file floati… (#3130)
6cbd3f42b is described below

commit 6cbd3f42be288de7bf04e1dd799d532475144853
Author: 成彬彬 <10...@users.noreply.github.com>
AuthorDate: Tue Aug 30 19:50:22 2022 +0800

    [linkis-gateway-httpclient-support] Modification of scala file floati… (#3130)
    
    * [linkis-gateway-httpclient-support] Modification of scala file floating red
---
 .../org/apache/linkis/httpclient/dws/DWSHttpClient.scala    | 13 +++++++------
 .../dws/authentication/StaticAuthenticationStrategy.scala   |  8 +++++---
 .../httpclient/dws/response/DWSAuthenticationResult.scala   |  3 ++-
 .../linkis/httpclient/dws/response/DWSHeartbeatResult.scala |  3 ++-
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/DWSHttpClient.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/DWSHttpClient.scala
index ab703a79d..93c1de817 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/DWSHttpClient.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/DWSHttpClient.scala
@@ -39,7 +39,7 @@ import org.apache.http.{HttpException, HttpResponse}
 
 import java.util
 
-import scala.collection.JavaConversions
+import scala.collection.{JavaConversions, JavaConverters}
 
 class DWSHttpClient(clientConfig: DWSClientConfig, clientName: String)
     extends AbstractHttpClient(clientConfig, clientName)
@@ -101,8 +101,9 @@ class DWSHttpClient(clientConfig: DWSClientConfig, clientName: String)
             transfer(value, map)
             value
           case list: util.List[util.Map[String, Object]] =>
-            val results = JavaConversions
-              .asScalaBuffer(list)
+            val results = JavaConverters
+              .asScalaBufferConverter(list)
+              .asScala
               .map { map =>
                 val value = clazz.getConstructor().newInstance().asInstanceOf[Result]
                 transfer(value, map)
@@ -116,14 +117,14 @@ class DWSHttpClient(clientConfig: DWSClientConfig, clientName: String)
   }
 
   protected def deserializeResponseBody(responseBody: String): Any = {
-    if (responseBody.startsWith("{") && responseBody.endsWith("}"))
+    if (responseBody.startsWith("{") && responseBody.endsWith("}")) {
       DWSHttpClient.jacksonJson.readValue(responseBody, classOf[util.Map[String, Object]])
-    else if (responseBody.startsWith("[") && responseBody.endsWith("]"))
+    } else if (responseBody.startsWith("[") && responseBody.endsWith("]")) {
       DWSHttpClient.jacksonJson.readValue(
         responseBody,
         classOf[util.List[util.Map[String, Object]]]
       )
-    else if (StringUtils.isEmpty(responseBody)) new util.HashMap[String, Object]
+    } else if (StringUtils.isEmpty(responseBody)) new util.HashMap[String, Object]
     else if (responseBody.length > 200) throw new HttpException(responseBody.substring(0, 200))
     else throw new HttpException(responseBody)
   }
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/StaticAuthenticationStrategy.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/StaticAuthenticationStrategy.scala
index ecec06007..80682268e 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/StaticAuthenticationStrategy.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/StaticAuthenticationStrategy.scala
@@ -61,12 +61,13 @@ class StaticAuthenticationStrategy(override protected val sessionMaxAliveTime: L
   ): AuthenticationAction = {
     val action = new DWSAuthenticationAction(serverUrl)
 
-    def pwd: String = if (StringUtils.isNotBlank(getClientConfig.getAuthTokenValue))
+    def pwd: String = if (StringUtils.isNotBlank(getClientConfig.getAuthTokenValue)) {
       getClientConfig.getAuthTokenValue
-    else
+    } else {
       throw new AuthenticationFailedException(
         "the value of authTokenValue in ClientConfig must be exists, since no password is found to login."
       )
+    }
 
     requestAction match {
       case userPwd: UserPwdAction =>
@@ -76,10 +77,11 @@ class StaticAuthenticationStrategy(override protected val sessionMaxAliveTime: L
         action.addRequestPayload("userName", userAction.getUser)
         action.addRequestPayload("password", pwd)
       case _ =>
-        if (StringUtils.isBlank(getClientConfig.getAuthTokenKey))
+        if (StringUtils.isBlank(getClientConfig.getAuthTokenKey)) {
           throw new AuthenticationFailedException(
             "the value of authTokenKey in ClientConfig must be exists, since no user is found to login."
           )
+        }
         action.addRequestPayload("userName", getClientConfig.getAuthTokenKey)
         action.addRequestPayload("password", pwd)
     }
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/response/DWSAuthenticationResult.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/response/DWSAuthenticationResult.scala
index 4711656a3..6ea3fc167 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/response/DWSAuthenticationResult.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/response/DWSAuthenticationResult.scala
@@ -62,9 +62,10 @@ class DWSAuthenticationResult(response: HttpResponse, serverUrl: String)
 
     override def updateLastAccessTime(): Unit = lastAccessTime = System.currentTimeMillis
   }
-  else
+  else {
     throw new HttpMessageParseException(
       s"login to gateway $serverUrl failed! Reason: " + getMessage
     )
+  }
 
 }
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/response/DWSHeartbeatResult.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/response/DWSHeartbeatResult.scala
index f68f020c0..8721625c4 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/response/DWSHeartbeatResult.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/response/DWSHeartbeatResult.scala
@@ -43,8 +43,9 @@ class DWSHeartbeatResult(response: HttpResponse, serverUrl: String)
     set(responseBody, statusCode, url, contentType)
   }
 
-  if (getStatus != 0)
+  if (getStatus != 0) {
     logger.warn(s"heartbeat to gateway $serverUrl failed! message: $getMessage.")
+  }
 
   override val isHealthy: Boolean = getData.get("isHealthy") match {
     case b: java.lang.Boolean => b


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