Skip to content

Commit 2d94091

Browse files
LuciferYangsarutak
authored andcommitted
[SPARK-55193][CORE][BUILD] Use CompressionHandler as a replacement for the deprecated GzipHandler in JettyUtils
### What changes were proposed in this pull request? This PR replaces `GzipHandler` with `CompressionHandler` in `JettyUtils` because `GzipHandler` has been deprecated and marked with `forRemoval = true`. The modification follows the deprecation guideline refer to https://github.com/jetty/jetty.project/blob/e9d4cba5a9d8ed62100bb09480af6fbb39c636cb/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java#L42-L49 ``` /** * deprecated use the new {code CompressionHandler} available in {code org.eclipse.jetty.compression:jetty-compression-server} * with your choice of compression implementation (gzip is {code org.eclipse.jetty.compression:jetty-compression-gzip}, * brotli is {code org.eclipse.jetty.compression:jetty-compression-brotli}, and zstandard is * {code org.eclipse.jetty.compression:jetty-compression-zstandard}) */ Deprecated(since = "12.1.1", forRemoval = true) public class GzipHandler extends Handler.Wrapper implements GzipFactory ``` ### Why are the changes needed? Cleanup deprecated API usage. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Pass Github Actions - Manually built a Spark distribution and verified that the UI displays correctly. ### Was this patch authored or co-authored using generative AI tooling? No Closes #53928 from LuciferYang/JettyUtils-GzipHandler. Lead-authored-by: yangjie01 <yangjie01@baidu.com> Co-authored-by: YangJie <yangjie01@baidu.com> Signed-off-by: Kousuke Saruta <sarutak@apache.org>
1 parent 866a6e8 commit 2d94091

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

core/pom.xml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@
182182
<artifactId>jetty-ee10-servlets</artifactId>
183183
<scope>compile</scope>
184184
</dependency>
185+
<dependency>
186+
<groupId>org.eclipse.jetty.compression</groupId>
187+
<artifactId>jetty-compression-server</artifactId>
188+
<scope>compile</scope>
189+
</dependency>
190+
<dependency>
191+
<groupId>org.eclipse.jetty.compression</groupId>
192+
<artifactId>jetty-compression-common</artifactId>
193+
<scope>compile</scope>
194+
</dependency>
195+
<dependency>
196+
<groupId>org.eclipse.jetty.compression</groupId>
197+
<artifactId>jetty-compression-gzip</artifactId>
198+
<scope>compile</scope>
199+
</dependency>
185200
<dependency>
186201
<groupId>javax.servlet</groupId>
187202
<artifactId>javax.servlet-api</artifactId>
@@ -541,7 +556,7 @@
541556
<overWriteIfNewer>true</overWriteIfNewer>
542557
<useSubDirectoryPerType>true</useSubDirectoryPerType>
543558
<includeArtifactIds>
544-
guava,protobuf-java,jetty-io,jetty-ee10-servlet,jetty-ee10-servlets,jetty-http,jetty-ee10-plus,jetty-util,jetty-server,jetty-security,jetty-proxy,jetty-client,jetty-session
559+
guava,protobuf-java,jetty-io,jetty-ee10-servlet,jetty-ee10-servlets,jetty-http,jetty-ee10-plus,jetty-util,jetty-server,jetty-security,jetty-proxy,jetty-client,jetty-session,jetty-compression-server,jetty-compression-common,jetty-compression-gzip
545560
</includeArtifactIds>
546561
<silent>true</silent>
547562
</configuration>
@@ -568,6 +583,9 @@
568583
<include>org.eclipse.jetty:jetty-util</include>
569584
<include>org.eclipse.jetty:jetty-server</include>
570585
<include>org.eclipse.jetty:jetty-session</include>
586+
<include>org.eclipse.jetty.compression:jetty-compression-server</include>
587+
<include>org.eclipse.jetty.compression:jetty-compression-common</include>
588+
<include>org.eclipse.jetty.compression:jetty-compression-gzip</include>
571589
<include>com.google.guava:guava</include>
572590
<include>com.google.guava:failureaccess</include>
573591
<include>com.google.protobuf:*</include>
@@ -595,6 +613,9 @@
595613
</includes>
596614
</relocation>
597615
</relocations>
616+
<transformers>
617+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
618+
</transformers>
598619
</configuration>
599620
</plugin>
600621
</plugins>

core/src/main/scala/org/apache/spark/ui/JettyUtils.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ import jakarta.servlet.http._
3030
import org.eclipse.jetty.client.{Response => CResponse}
3131
import org.eclipse.jetty.client.HttpClient
3232
import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP
33+
import org.eclipse.jetty.compression.server.CompressionHandler
3334
import org.eclipse.jetty.ee10.proxy.ProxyServlet
3435
import org.eclipse.jetty.ee10.servlet._
3536
import org.eclipse.jetty.http.{HttpField, HttpFields, HttpHeader}
3637
import org.eclipse.jetty.server._
3738
import org.eclipse.jetty.server.handler.{ContextHandler, ContextHandlerCollection, ErrorHandler}
38-
import org.eclipse.jetty.server.handler.gzip.GzipHandler
3939
import org.eclipse.jetty.util.{Callback, URIUtil}
4040
import org.eclipse.jetty.util.component.LifeCycle
4141
import org.eclipse.jetty.util.thread.{QueuedThreadPool, ScheduledExecutorScheduler}
@@ -475,22 +475,23 @@ private[spark] case class ServerInfo(
475475
handler.setVirtualHosts(JettyUtils.toVirtualHosts(JettyUtils.SPARK_CONNECTOR_NAME))
476476
addFilters(handler, securityMgr)
477477

478-
val gzipHandler = new GzipHandler()
479-
gzipHandler.setHandler(handler)
480-
rootHandler.addHandler(gzipHandler)
478+
val compressionHandler = new CompressionHandler()
479+
compressionHandler.setHandler(handler)
480+
rootHandler.addHandler(compressionHandler)
481481

482482
if (!handler.isStarted()) {
483483
handler.start()
484484
}
485-
gzipHandler.start()
485+
compressionHandler.start()
486486
}
487487

488488
def removeHandler(handler: ServletContextHandler): Unit = synchronized {
489489
// Since addHandler() always adds a wrapping gzip handler, find the container handler
490490
// and remove it.
491491
rootHandler.getHandlers.asScala
492492
.find { h =>
493-
h.isInstanceOf[GzipHandler] && h.asInstanceOf[GzipHandler].getHandler() == handler
493+
h.isInstanceOf[CompressionHandler] &&
494+
h.asInstanceOf[CompressionHandler].getHandler() == handler
494495
}
495496
.foreach { h =>
496497
rootHandler.removeHandler(h)

pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,24 @@
613613
<version>${jetty.version}</version>
614614
<scope>provided</scope>
615615
</dependency>
616+
<dependency>
617+
<groupId>org.eclipse.jetty.compression</groupId>
618+
<artifactId>jetty-compression-server</artifactId>
619+
<version>${jetty.version}</version>
620+
<scope>provided</scope>
621+
</dependency>
622+
<dependency>
623+
<groupId>org.eclipse.jetty.compression</groupId>
624+
<artifactId>jetty-compression-common</artifactId>
625+
<version>${jetty.version}</version>
626+
<scope>provided</scope>
627+
</dependency>
628+
<dependency>
629+
<groupId>org.eclipse.jetty.compression</groupId>
630+
<artifactId>jetty-compression-gzip</artifactId>
631+
<version>${jetty.version}</version>
632+
<scope>provided</scope>
633+
</dependency>
616634
<dependency>
617635
<groupId>com.google.guava</groupId>
618636
<artifactId>guava</artifactId>

0 commit comments

Comments
 (0)