zhoulii commented on code in PR #2733:
URL: 
https://github.com/apache/incubator-streampark/pull/2733#discussion_r1186957209


##########
streampark-common/src/main/scala/org/apache/streampark/common/util/HttpClientUtils.scala:
##########
@@ -16,23 +16,23 @@
  */
 package org.apache.streampark.common.util
 
-import org.apache.http.NameValuePair
-import org.apache.http.auth.{AuthSchemeProvider, AuthScope, Credentials}
-import org.apache.http.client.config.{AuthSchemes, RequestConfig}
-import org.apache.http.client.entity.UrlEncodedFormEntity
-import org.apache.http.client.methods._
-import org.apache.http.client.utils.URIBuilder
-import org.apache.http.config.RegistryBuilder
-import org.apache.http.entity.StringEntity
-import org.apache.http.impl.auth.SPNegoSchemeFactory
-import org.apache.http.impl.client.{BasicCredentialsProvider, 
CloseableHttpClient, HttpClientBuilder, HttpClients}
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager
-import org.apache.http.message.BasicNameValuePair
-import org.apache.http.util.EntityUtils
+import org.apache.hadoop.shaded.org.apache.http.client.config.AuthSchemes

Review Comment:
   We'd better not use reference from `hadoop.shaded` package.



##########
streampark-common/src/main/scala/org/apache/streampark/common/util/HttpClientUtils.scala:
##########
@@ -97,83 +98,47 @@ object HttpClientUtils {
     getHttpResult(httpPost)
   }
 
-  def httpPatchRequest(url: String): String = {
-    val httpPatch = new HttpPatch(url)
-    getHttpResult(httpPatch)
-  }
-
-  def httpPostRequest(url: String, params: util.Map[String, AnyRef]): String = 
{
+  def httpPostRequest(url: String, params: JavaMap[String, AnyRef]): String = {
     val httpPost = new HttpPost(url)
     httpPost.setEntity(new 
UrlEncodedFormEntity(paramsToNameValuePairs(params), defaultChart))
     getHttpResult(httpPost)
   }
 
-  def httpPatchRequest(url: String, params: util.Map[String, AnyRef]): String 
= {
-    val httpPatch = new HttpPatch(url)
-    httpPatch.setEntity(new 
UrlEncodedFormEntity(paramsToNameValuePairs(params), defaultChart))
-    getHttpResult(httpPatch)
-  }
-
-  def httpPostRequest(url: String, params: String): String = httpRequest(new 
HttpPost(url), params)
-
-  def httpPatchRequest(url: String, params: String): String =
-    httpRequest(new HttpPatch(url), params)
-
   def httpPostRequest(
       url: String,
-      params: util.Map[String, AnyRef],
-      headers: util.Map[String, AnyRef] = Map.empty[String, AnyRef]): String = 
{
+      params: JavaMap[String, AnyRef],
+      headers: JavaMap[String, AnyRef] = Map.empty[String, AnyRef]): String = {
     httpRequest(new HttpPost(url), headers, params)
   }
 
-  def httpPatchRequest(
-      url: String,
-      params: util.Map[String, AnyRef],
-      headers: util.Map[String, AnyRef] = Map.empty[String, AnyRef]): String = 
{
-    httpRequest(new HttpPatch(url), headers, params)
-  }
-
   private[this] def httpRequest(
-      httpEntity: HttpEntityEnclosingRequestBase,
-      params: String): String = {
-    val entity = new StringEntity(params, defaultChart)
-    entity.setContentEncoding("UTF-8")
-    entity.setContentType("application/json")
-    httpEntity.setEntity(entity)
-    getHttpResult(httpEntity)
-  }
-
-  private[this] def httpRequest(
-      httpPatch: HttpEntityEnclosingRequestBase,
-      headers: util.Map[String, AnyRef],
-      params: util.Map[String, AnyRef]) = {
-    headers.entrySet.foreach(p => httpPatch.addHeader(p.getKey, 
String.valueOf(p.getValue)))
-    httpPatch.setEntity(new 
UrlEncodedFormEntity(paramsToNameValuePairs(params), defaultChart))
-    getHttpResult(httpPatch)
+      httpUri: HttpUriRequestBase,
+      headers: JavaMap[String, AnyRef],
+      params: JavaMap[String, AnyRef]) = {
+    headers.entrySet.foreach(p => httpUri.addHeader(p.getKey, 
String.valueOf(p.getValue)))
+    httpUri.setEntity(new UrlEncodedFormEntity(paramsToNameValuePairs(params), 
defaultChart))
+    getHttpResult(httpUri)
   }
 
   private[this] def paramsToNameValuePairs(
-      params: util.Map[String, AnyRef]): util.List[NameValuePair] = {
-    val pairs = new util.ArrayList[NameValuePair]
-    params.entrySet.foreach(
-      p => pairs.add(new BasicNameValuePair(p.getKey, 
String.valueOf(p.getValue))))
-    pairs
+      params: JavaMap[String, AnyRef]): JavaList[NameValuePair] = {
+    params.entrySet.map(p => new BasicNameValuePair(p.getKey, 
p.getValue.toString)).toList
   }
 
   def httpAuthGetRequest(url: String, config: RequestConfig): String = {
     def getHttpAuthClient: CloseableHttpClient = {
       val credentialsProvider = new BasicCredentialsProvider
-      credentialsProvider.setCredentials(
-        new AuthScope(null, -1, null),
-        new Credentials {
-          override def getUserPrincipal: Principal = null
 
-          override def getPassword: String = null
-        })
+      val credentials = new Credentials() {
+        def getPassword: Array[Char] = null
+        def getUserPrincipal: Principal = null
+      }
+
+      credentialsProvider.setCredentials(new AuthScope(null, -1), credentials)
 
       val authSchemeRegistry = RegistryBuilder
-        .create[AuthSchemeProvider]
-        .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true))
+        .create[AuthSchemeFactory]
+        .register(AuthSchemes.SPNEGO, SPNegoSchemeFactory.DEFAULT)

Review Comment:
   `AuthSchemes` is removed in 5.1, we can use `StandardAuthScheme` instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to