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

chengpan pushed a commit to branch branch-1.9
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.9 by this push:
     new 89af82c183 [KYUUBI #6615] Make Jetty sending server version in 
response configurable
89af82c183 is described below

commit 89af82c183b1a63710d43bdc8546477a4a8eced7
Author: zhang_yao <[email protected]>
AuthorDate: Fri Aug 16 04:24:34 2024 +0000

    [KYUUBI #6615] Make Jetty sending server version in response configurable
    
    This pull request fixes #6615
    
    Add a config item that controls whether Jetty should send its version in 
response.
    
    Sending Jetty version could be disabled by calling 
HttpConfiguration::setSendServerVersion(false)
    
    - [ ] Bugfix (non-breaking change which fixes an issue)
    - [x] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
    
    Compiled and tested manually.
    
    ---
    
    - [ ] This patch was not authored or co-authored using [Generative 
Tooling](https://www.apache.org/legal/generative-tooling.html)
    
    **Be nice. Be informative.**
    
    Closes #6616 from paul8263/KYUUBI-6615.
    
    Closes #6615
    
    c1567fdfa [zhang_yao] [KYUUBI #6615] Make Jetty sending server version in 
response configurable
    
    Authored-by: zhang_yao <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
    (cherry picked from commit 7c20e697baa14e044ddb5459597d061304214ad5)
    Signed-off-by: Cheng Pan <[email protected]>
---
 docs/configuration/settings.md                                     | 1 +
 .../src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala       | 7 +++++++
 .../scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala | 3 ++-
 .../org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala      | 2 ++
 .../org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala      | 5 +++--
 .../src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala   | 4 +++-
 6 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/docs/configuration/settings.md b/docs/configuration/settings.md
index 9e4d60157e..0ea5ee5f05 100644
--- a/docs/configuration/settings.md
+++ b/docs/configuration/settings.md
@@ -234,6 +234,7 @@ You can configure the Kyuubi properties in 
`$KYUUBI_HOME/conf/kyuubi-defaults.co
 | kyuubi.frontend.bind.host                              | &lt;undefined&gt;  
| Hostname or IP of the machine on which to run the frontend services.          
                                                                                
                                                                                
                                                                                
                                                                                
               [...]
 | kyuubi.frontend.bind.port                              | 10009              
| (deprecated) Port of the machine on which to run the thrift frontend service 
via the binary protocol.                                                        
                                                                                
                                                                                
                                                                                
                [...]
 | kyuubi.frontend.connection.url.use.hostname            | true               
| When true, frontend services prefer hostname, otherwise, ip address. Note 
that, the default value is set to `false` when engine running on Kubernetes to 
prevent potential network issues.                                               
                                                                                
                                                                                
                    [...]
+| kyuubi.frontend.jetty.sendVersion.enabled              | true               
| Whether to send Jetty version in HTTP response.                               
                                                                                
                                                                                
                                                                                
                                                                                
               [...]
 | kyuubi.frontend.max.message.size                       | 104857600          
| (deprecated) Maximum message size in bytes a Kyuubi server will accept.       
                                                                                
                                                                                
                                                                                
                                                                                
               [...]
 | kyuubi.frontend.max.worker.threads                     | 999                
| (deprecated) Maximum number of threads in the frontend worker thread pool for 
the thrift frontend service                                                     
                                                                                
                                                                                
                                                                                
               [...]
 | kyuubi.frontend.min.worker.threads                     | 9                  
| (deprecated) Minimum number of threads in the frontend worker thread pool for 
the thrift frontend service                                                     
                                                                                
                                                                                
                                                                                
               [...]
diff --git 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
index 2a17f780ec..5e23c0fe63 100644
--- a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
+++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
@@ -640,6 +640,13 @@ object KyuubiConf {
       .booleanConf
       .createWithDefault(true)
 
+  val FRONTEND_JETTY_SEND_VERSION_ENABLED: ConfigEntry[Boolean] =
+    buildConf("kyuubi.frontend.jetty.sendVersion.enabled")
+      .doc("Whether to send Jetty version in HTTP response.")
+      .version("1.9.3")
+      .booleanConf
+      .createWithDefault(true)
+
   val FRONTEND_THRIFT_HTTP_COOKIE_AUTH_ENABLED: ConfigEntry[Boolean] =
     buildConf("kyuubi.frontend.thrift.http.cookie.auth.enabled")
       .doc("When true, Kyuubi in HTTP transport mode, " +
diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
index bee542a87b..1082cde46c 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
@@ -90,7 +90,8 @@ class KyuubiRestFrontendService(override val serverable: 
Serverable)
       host,
       port,
       conf.get(FRONTEND_REST_MAX_WORKER_THREADS),
-      conf.get(FRONTEND_REST_JETTY_STOP_TIMEOUT))
+      conf.get(FRONTEND_REST_JETTY_STOP_TIMEOUT),
+      conf.get(FRONTEND_JETTY_SEND_VERSION_ENABLED))
     super.initialize(conf)
   }
 
diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala
index 2763e9481f..1e289c6235 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala
@@ -101,8 +101,10 @@ final class KyuubiTHttpFrontendService(
       // Configure header size
       val requestHeaderSize = 
conf.get(FRONTEND_THRIFT_HTTP_REQUEST_HEADER_SIZE)
       val responseHeaderSize = 
conf.get(FRONTEND_THRIFT_HTTP_RESPONSE_HEADER_SIZE)
+      val jettySendVersionEnabled = 
conf.get(FRONTEND_JETTY_SEND_VERSION_ENABLED)
       httpConf.setRequestHeaderSize(requestHeaderSize)
       httpConf.setResponseHeaderSize(responseHeaderSize)
+      httpConf.setSendServerVersion(jettySendVersionEnabled)
       val connectionFactory = new HttpConnectionFactory(httpConf)
 
       val useSsl = conf.get(FRONTEND_THRIFT_HTTP_USE_SSL)
diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala
index bef0b6f935..88e83c6e5f 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala
@@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicBoolean
 
 import org.apache.kyuubi.{KyuubiException, Utils}
 import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.config.KyuubiConf.{FRONTEND_ADVERTISED_HOST, 
FRONTEND_TRINO_BIND_HOST, FRONTEND_TRINO_BIND_PORT, 
FRONTEND_TRINO_JETTY_STOP_TIMEOUT, FRONTEND_TRINO_MAX_WORKER_THREADS}
+import org.apache.kyuubi.config.KyuubiConf._
 import org.apache.kyuubi.server.trino.api.v1.ApiRootResource
 import org.apache.kyuubi.server.ui.JettyServer
 import org.apache.kyuubi.service.{AbstractFrontendService, Serverable, Service}
@@ -55,7 +55,8 @@ class KyuubiTrinoFrontendService(override val serverable: 
Serverable)
       host,
       port,
       conf.get(FRONTEND_TRINO_MAX_WORKER_THREADS),
-      conf.get(FRONTEND_TRINO_JETTY_STOP_TIMEOUT))
+      conf.get(FRONTEND_TRINO_JETTY_STOP_TIMEOUT),
+      conf.get(FRONTEND_JETTY_SEND_VERSION_ENABLED))
     super.initialize(conf)
   }
 
diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala
index 4da874a160..8621bb5bba 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala
@@ -78,7 +78,8 @@ object JettyServer {
       host: String,
       port: Int,
       poolSize: Int,
-      stopTimeout: Long): JettyServer = {
+      stopTimeout: Long,
+      sendServerVersion: Boolean): JettyServer = {
     val pool = new QueuedThreadPool(poolSize)
     pool.setName(name)
     pool.setDaemon(true)
@@ -95,6 +96,7 @@ object JettyServer {
 
     val serverExecutor = new 
ScheduledExecutorScheduler(s"$name-JettyScheduler", true)
     val httpConf = new HttpConfiguration()
+    httpConf.setSendServerVersion(sendServerVersion)
     val connector = new ServerConnector(
       server,
       null,

Reply via email to