From 90331ea3645c0fbcf450b9965ead59fd1c6342d2 Mon Sep 17 00:00:00 2001 From: "Ross A. Baker" Date: Sun, 19 Jun 2022 01:09:16 -0400 Subject: [PATCH] Upgrade to Tomcat 10 and Servlet 5 --- build.sbt | 10 +++++----- .../src/main/scala/com/example/TomcatExample.scala | 11 +++++------ .../org/http4s/tomcat/server/TomcatBuilder.scala | 6 +++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/build.sbt b/build.sbt index 4bcbae3..fea996f 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -ThisBuild / tlBaseVersion := "0.24" // your current series x.y +ThisBuild / tlBaseVersion := "0.25" // your current series x.y ThisBuild / licenses := Seq(License.Apache2) ThisBuild / developers := List( @@ -15,10 +15,10 @@ ThisBuild / scalaVersion := Scala213 // the default Scala val asyncHttpClientVersion = "2.12.3" val http4sVersion = "0.23.12" -val http4sServletVersion = "0.24.0-M1" +val http4sServletVersion = "0.25.0-M1" val munitCatsEffectVersion = "1.0.7" -val servletApiVersion = "4.0.1" -val tomcatVersion = "9.0.64" +val servletApiVersion = "5.0.0" +val tomcatVersion = "10.0.22" lazy val root = project .in(file(".")) @@ -32,7 +32,7 @@ lazy val tomcatServer = project description := "Tomcat implementation for http4s servers", startYear := Some(2014), libraryDependencies ++= Seq( - "javax.servlet" % "javax.servlet-api" % servletApiVersion % Provided, + "jakarta.servlet" % "jakarta.servlet-api" % servletApiVersion % Provided, "org.apache.tomcat" % "tomcat-catalina" % tomcatVersion, "org.apache.tomcat" % "tomcat-coyote" % tomcatVersion, "org.apache.tomcat" % "tomcat-util-scan" % tomcatVersion, diff --git a/examples/src/main/scala/com/example/TomcatExample.scala b/examples/src/main/scala/com/example/TomcatExample.scala index 587c467..cb56f43 100644 --- a/examples/src/main/scala/com/example/TomcatExample.scala +++ b/examples/src/main/scala/com/example/TomcatExample.scala @@ -17,16 +17,15 @@ package com.example import cats.effect._ +import jakarta.servlet.FilterChain +import jakarta.servlet.http.HttpFilter +import jakarta.servlet.http.HttpServlet +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import org.http4s._ import org.http4s.server.Server import org.http4s.tomcat.server.TomcatBuilder -import javax.servlet.FilterChain -import javax.servlet.http.HttpFilter -import javax.servlet.http.HttpServlet -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse - /** 1. Run as `sbt examples/run` * 2. Browse to http://localhost:8080/http4s to see `httpRoutes` * 3. Browse to http://localhost:8080/raw to see a raw servlet alongside the http4s routes diff --git a/tomcat-server/src/main/scala/org/http4s/tomcat/server/TomcatBuilder.scala b/tomcat-server/src/main/scala/org/http4s/tomcat/server/TomcatBuilder.scala index dcf5eb9..09cefb6 100644 --- a/tomcat-server/src/main/scala/org/http4s/tomcat/server/TomcatBuilder.scala +++ b/tomcat-server/src/main/scala/org/http4s/tomcat/server/TomcatBuilder.scala @@ -20,6 +20,9 @@ package server import cats.effect._ import cats.effect.std.Dispatcher +import jakarta.servlet.DispatcherType +import jakarta.servlet.http.HttpFilter +import jakarta.servlet.http.HttpServlet import org.apache.catalina.Context import org.apache.catalina.connector.Connector import org.apache.catalina.startup.Tomcat @@ -45,9 +48,6 @@ import org.log4s.getLogger import java.net.InetSocketAddress import java.util import java.util.concurrent.Executor -import javax.servlet.DispatcherType -import javax.servlet.http.HttpFilter -import javax.servlet.http.HttpServlet import scala.collection.immutable import scala.concurrent.duration._