From 15b0d653c28a1ce6e91cb4626a34e638039d7ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20Alt=C4=B1nda=C4=9F?= Date: Thu, 23 May 2024 00:17:14 +0200 Subject: [PATCH] Update dependencies (#105) * Bumped Ktor * Removed unused import statement * Bumped scala compiler * Bumped kotlin compiler * Bumped kotlin coroutines * Bumped sslcontext kickstart * Bumped cucumber * Bumped failsafe and surefire * Bumped aspectjweaver * Revert "Bumped cucumber" This reverts commit aceee848 * Bumped cucumber reporting * Bumped apache commons lang * Bumped apache commons langio * Bumped exec maven plugin * Added todos * Bumped jetty-reactive-httpclient * Bumped jersey * Bumped apache cxf * Revert "Bumped apache cxf" This reverts commit dfe5c149435afa7324373a6ebbc7b51bce5bc18a. * Added todo * Bumped scala maven plugin * Bumped google http client * Bumped unirest * Bumped retrofit * Bumped finagle * Bumped Akka * Bumped Sttp * Bumped requests * Configured finagle to always use http1 * Reverted finagle * Bumped http4s and cats * Bumped awaitility jackson-module-scala jacoco-maven-plugin junit-jupiter assertj * Bumped mockito byte-buddy mockito-kotlin scalatest scalatest-maven-plugin mockito-scala mockserver * Bumped maven-compiler-plugin maven-shade-plugin * Set minimal requirement to java 17 --- .github/workflows/maven.yml | 4 +- .gitpod.Dockerfile | 2 +- EXERCISES.MD | 2 +- client/pom.xml | 10 +- .../java/nl/altindag/client/ClientConfig.java | 5 +- .../service/Http4sBlazeClientService.scala | 6 +- .../service/Http4sJavaNetClientService.scala | 6 +- .../client/service/Http4sService.scala | 3 +- .../client/service/KtorHttpClientService.kt | 5 +- .../service/SttpHttpClientService.scala | 13 +-- .../service/SttpHttpClientServiceShould.scala | 25 +++-- pom.xml | 100 +++++++++--------- 12 files changed, 88 insertions(+), 93 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a1c57352..65341b1d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest ] - java: [ '11', '17', '21' ] + java: [ '17', '21' ] steps: - uses: actions/checkout@v2 @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: os: [ windows-latest ] - java: [ '11', '17', '21' ] + java: [ '17', '21' ] steps: - uses: actions/checkout@v2 diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 141f54e0..95fc6d1d 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -1,4 +1,4 @@ -FROM adoptopenjdk/maven-openjdk11:latest +FROM adoptopenjdk/maven-openjdk17:latest RUN apt-get update run apt-get install git -y \ No newline at end of file diff --git a/EXERCISES.MD b/EXERCISES.MD index be3baad3..0781cc7f 100644 --- a/EXERCISES.MD +++ b/EXERCISES.MD @@ -12,7 +12,7 @@ These are the following steps: ## Starting the server **Minimum requirements:** -1. Java 11 +1. Java 17 2. Maven 3.5.0 3. Eclipse, Intellij IDEA (or any other text editor like VIM) 4. A terminal diff --git a/client/pom.xml b/client/pom.xml index 75df747f..6389ff56 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -103,7 +103,7 @@ fuel - com.softwaremill.sttp.client + com.softwaremill.sttp.client4 core_${version.scala} @@ -156,19 +156,19 @@ io.ktor - ktor-client-apache + ktor-client-apache-jvm io.ktor - ktor-client-okhttp + ktor-client-okhttp-jvm io.ktor - ktor-client-android + ktor-client-android-jvm io.ktor - ktor-client-java + ktor-client-java-jvm org.http4k diff --git a/client/src/main/java/nl/altindag/client/ClientConfig.java b/client/src/main/java/nl/altindag/client/ClientConfig.java index 9d5e8599..df6c3fd5 100644 --- a/client/src/main/java/nl/altindag/client/ClientConfig.java +++ b/client/src/main/java/nl/altindag/client/ClientConfig.java @@ -246,10 +246,9 @@ public Retrofit retrofit(OkHttpClient okHttpClient) { @Bean public Service finagle(SSLFactory sslFactory) throws URISyntaxException { var uri = new URI(Constants.getServerUrl()); - var client = Http.client(); + var client = Http.client().withNoHttp2(); if (uri.getScheme().equals("https")) { - client = client.withNoHttp2() - .withTransport() + client = client.withTransport() .tls(sslFactory.getSslContext()); } return client.newService(uri.getHost() + ":" + uri.getPort()); diff --git a/client/src/main/java/nl/altindag/client/service/Http4sBlazeClientService.scala b/client/src/main/java/nl/altindag/client/service/Http4sBlazeClientService.scala index 0392fb24..29429c3c 100644 --- a/client/src/main/java/nl/altindag/client/service/Http4sBlazeClientService.scala +++ b/client/src/main/java/nl/altindag/client/service/Http4sBlazeClientService.scala @@ -19,14 +19,12 @@ import cats.effect.{ExitCode, IO, IOApp, Resource} import nl.altindag.client.ClientType import nl.altindag.client.ClientType.HTTP4S_BLAZE_CLIENT import nl.altindag.ssl.SSLFactory +import org.http4s.blaze.client.BlazeClientBuilder import org.http4s.client.Client -import org.http4s.client.blaze.BlazeClientBuilder import org.springframework.beans.factory.annotation.Qualifier import org.springframework.context.annotation.Bean import org.springframework.stereotype.{Component, Service} -import scala.concurrent.ExecutionContext.Implicits.global - @Service class Http4sBlazeClientService(@Qualifier("blazeClient") client: Resource[IO, Client[IO]]) extends Http4sService(client) { @@ -39,7 +37,7 @@ class BlazeClientConfiguration extends IOApp { @Bean(name = Array("blazeClient")) def createBlazeClient(sslFactory: SSLFactory): Resource[IO, Client[IO]] = { - BlazeClientBuilder[IO](global) + BlazeClientBuilder[IO] .withSslContext(sslFactory.getSslContext) .resource } diff --git a/client/src/main/java/nl/altindag/client/service/Http4sJavaNetClientService.scala b/client/src/main/java/nl/altindag/client/service/Http4sJavaNetClientService.scala index 3a2282c5..31e3e503 100644 --- a/client/src/main/java/nl/altindag/client/service/Http4sJavaNetClientService.scala +++ b/client/src/main/java/nl/altindag/client/service/Http4sJavaNetClientService.scala @@ -15,7 +15,7 @@ */ package nl.altindag.client.service -import cats.effect.{Blocker, ExitCode, IO, IOApp, Resource} +import cats.effect.{ExitCode, IO, IOApp, Resource} import nl.altindag.client.ClientType import nl.altindag.client.ClientType.HTTP4S_JAVA_NET_CLIENT import nl.altindag.ssl.SSLFactory @@ -24,8 +24,6 @@ import org.springframework.beans.factory.annotation.Qualifier import org.springframework.context.annotation.Bean import org.springframework.stereotype.{Component, Service} -import scala.concurrent.ExecutionContext.Implicits.global - @Service class Http4sJavaNetClientService(@Qualifier("javaNetClient") client: Resource[IO, Client[IO]]) extends Http4sService(client) { @@ -38,7 +36,7 @@ class JavaNetClientConfiguration extends IOApp { @Bean(name = Array("javaNetClient")) def createJavaNetClient(sslFactory: SSLFactory): Resource[IO, Client[IO]] = { - JavaNetClientBuilder[IO](Blocker.liftExecutionContext(global)) + JavaNetClientBuilder[IO] .withSslSocketFactory(sslFactory.getSslSocketFactory) .withHostnameVerifier(sslFactory.getHostnameVerifier) .resource diff --git a/client/src/main/java/nl/altindag/client/service/Http4sService.scala b/client/src/main/java/nl/altindag/client/service/Http4sService.scala index 2a0cae29..e34facc4 100644 --- a/client/src/main/java/nl/altindag/client/service/Http4sService.scala +++ b/client/src/main/java/nl/altindag/client/service/Http4sService.scala @@ -15,6 +15,7 @@ */ package nl.altindag.client.service +import cats.effect.unsafe.implicits.global import cats.effect.{IO, Resource} import nl.altindag.client.Constants.HEADER_KEY_CLIENT_TYPE import nl.altindag.client.model.ClientResponse @@ -32,7 +33,7 @@ abstract class Http4sService(client: Resource[IO, Client[IO]]) extends RequestSe val responseBody = client .use(client => client.expect[String](request)) - .unsafeRunSync() + .unsafeRunSync // the client will throw a runtime exception for any other status code than 2xx // therefore it won't even reach to this point if it gets a non 2xx status code. diff --git a/client/src/main/java/nl/altindag/client/service/KtorHttpClientService.kt b/client/src/main/java/nl/altindag/client/service/KtorHttpClientService.kt index a613a499..9ecbf698 100644 --- a/client/src/main/java/nl/altindag/client/service/KtorHttpClientService.kt +++ b/client/src/main/java/nl/altindag/client/service/KtorHttpClientService.kt @@ -18,8 +18,7 @@ package nl.altindag.client.service import io.ktor.client.HttpClient import io.ktor.client.request.get import io.ktor.client.request.header -import io.ktor.client.statement.HttpResponse -import io.ktor.utils.io.readUTF8Line +import io.ktor.client.statement.* import kotlinx.coroutines.runBlocking import nl.altindag.client.Constants.HEADER_KEY_CLIENT_TYPE import nl.altindag.client.model.ClientResponse @@ -32,7 +31,7 @@ abstract class KtorHttpClientService(var client: HttpClient): RequestService { header(HEADER_KEY_CLIENT_TYPE, clientType.value) } - ClientResponse(httpResponse.content.readUTF8Line(), httpResponse.status.value) + ClientResponse(httpResponse.bodyAsText(), httpResponse.status.value) } } diff --git a/client/src/main/java/nl/altindag/client/service/SttpHttpClientService.scala b/client/src/main/java/nl/altindag/client/service/SttpHttpClientService.scala index 5c974983..319a3bbb 100644 --- a/client/src/main/java/nl/altindag/client/service/SttpHttpClientService.scala +++ b/client/src/main/java/nl/altindag/client/service/SttpHttpClientService.scala @@ -15,9 +15,6 @@ */ package nl.altindag.client.service -import java.net.URI - -import javax.net.ssl.HttpsURLConnection import nl.altindag.client.ClientType import nl.altindag.client.ClientType._ import nl.altindag.client.Constants.HEADER_KEY_CLIENT_TYPE @@ -25,11 +22,15 @@ import nl.altindag.client.model.ClientResponse import nl.altindag.ssl.SSLFactory import org.springframework.context.annotation.Bean import org.springframework.stereotype.{Component, Service} -import sttp.client._ +import sttp.client4.httpurlconnection.HttpURLConnectionBackend +import sttp.client4.{SyncBackend, basicRequest} import sttp.model._ +import java.net.URI +import javax.net.ssl.HttpsURLConnection + @Service -class SttpHttpClientService(sttpBackend: SttpBackend[Identity, Any]) extends RequestService { +class SttpHttpClientService(sttpBackend: SyncBackend) extends RequestService { override def executeRequest(url: String): ClientResponse = { val request = basicRequest.get(uri = Uri(javaUri = URI.create(url))) @@ -47,7 +48,7 @@ class SttpHttpClientService(sttpBackend: SttpBackend[Identity, Any]) extends Req class SttpHttpClientConfiguration { @Bean - def createSttpBackendClient(sslFactory: SSLFactory): SttpBackend[Identity, Any] = { + def createSttpBackendClient(sslFactory: SSLFactory): SyncBackend = { HttpURLConnectionBackend(customizeConnection = { case httpsConnection: HttpsURLConnection => httpsConnection.setHostnameVerifier(sslFactory.getHostnameVerifier) diff --git a/client/src/test/java/nl/altindag/client/service/SttpHttpClientServiceShould.scala b/client/src/test/java/nl/altindag/client/service/SttpHttpClientServiceShould.scala index d140c3b4..dd4d2ec9 100644 --- a/client/src/test/java/nl/altindag/client/service/SttpHttpClientServiceShould.scala +++ b/client/src/test/java/nl/altindag/client/service/SttpHttpClientServiceShould.scala @@ -16,7 +16,6 @@ package nl.altindag.client.service import java.net.URI - import nl.altindag.client.TestConstants.{HTTPS_URL, HTTP_URL} import nl.altindag.client.model.ClientResponse import nl.altindag.client.util.SSLFactoryTestHelper @@ -24,23 +23,23 @@ import org.assertj.core.api.Assertions.{assertThat, assertThatThrownBy} import org.mockito.ArgumentCaptor import org.mockito.scalatest.MockitoSugar import org.scalatest.funspec.AnyFunSpec -import sttp.client.{Identity, Request, RequestT, Response, SttpBackend, basicRequest} +import sttp.client4.{GenericRequest, Identity, Response, SyncBackend, basicRequest} import sttp.model.{Header, StatusCode, Uri} class SttpHttpClientServiceShould extends AnyFunSpec with MockitoSugar { describe("execute request") { - val mockedBackend = mock[SttpBackend[Identity, Any]] + val mockedBackend = mock[SyncBackend] val mockedResponse = mock[Identity[Response[Either[String, String]]]] val mockedBody = mock[Either[String, String]] - when(mockedBackend.send(any[RequestT[Identity, Either[String, String], Any]])).thenReturn(mockedResponse) + when(mockedBackend.send(any[GenericRequest[Any, Any]])).thenReturn(mockedResponse) when(mockedResponse.code).thenReturn(StatusCode.Ok) when(mockedResponse.body).thenReturn(mockedBody) when(mockedBody.toOption).thenReturn(Option.apply("Hello")) - val requestArgumentCaptor: ArgumentCaptor[RequestT[Identity, Either[String, String], Any]] = { - ArgumentCaptor.forClass(classOf[RequestT[Identity, Either[String, String], Any]]) + val requestArgumentCaptor: ArgumentCaptor[GenericRequest[Any, Any]] = { + ArgumentCaptor.forClass(classOf[GenericRequest[Any, Any]]) } val victim = new SttpHttpClientService(mockedBackend) @@ -54,15 +53,15 @@ class SttpHttpClientServiceShould extends AnyFunSpec with MockitoSugar { } describe("create Sttp backend client without ssl") { - val victim: SttpBackend[Identity, Any] = new SttpHttpClientConfiguration().createSttpBackendClient(null) + val victim: SyncBackend = new SttpHttpClientConfiguration().createSttpBackendClient(null) assertThat(victim).isNotNull } describe("create Sttp backend client with ssl") { val sslFactory = SSLFactoryTestHelper.createSSLFactory(true, true) - val request: Request[Either[String, String], Any] = basicRequest.get(uri = Uri(javaUri = URI.create(HTTPS_URL))) - val victim: SttpBackend[Identity, Any] = new SttpHttpClientConfiguration().createSttpBackendClient(sslFactory) + val request: GenericRequest[Any, Any] = basicRequest.get(uri = Uri(javaUri = URI.create(HTTPS_URL))) + val victim: SyncBackend = new SttpHttpClientConfiguration().createSttpBackendClient(sslFactory) assertThat(victim).isNotNull assertThatThrownBy(() => victim.send(request)) @@ -72,8 +71,8 @@ class SttpHttpClientServiceShould extends AnyFunSpec with MockitoSugar { } describe("create Sttp backend client without ssl when sslFactory is absent") { - val request: Request[Either[String, String], Any] = basicRequest.get(uri = Uri(javaUri = URI.create(HTTPS_URL))) - val victim: SttpBackend[Identity, Any] = new SttpHttpClientConfiguration().createSttpBackendClient(null) + val request: GenericRequest[Any, Any] = basicRequest.get(uri = Uri(javaUri = URI.create(HTTPS_URL))) + val victim: SyncBackend = new SttpHttpClientConfiguration().createSttpBackendClient(null) assertThat(victim).isNotNull assertThatThrownBy(() => victim.send(request)) @@ -82,8 +81,8 @@ class SttpHttpClientServiceShould extends AnyFunSpec with MockitoSugar { describe("create Sttp backend client without ssl when url is http scheme") { val sslFactory = SSLFactoryTestHelper.createSSLFactory(true, true) - val request: Request[Either[String, String], Any] = basicRequest.get(uri = Uri(javaUri = URI.create(HTTP_URL))) - val victim: SttpBackend[Identity, Any] = new SttpHttpClientConfiguration().createSttpBackendClient(sslFactory) + val request: GenericRequest[Any, Any] = basicRequest.get(uri = Uri(javaUri = URI.create(HTTP_URL))) + val victim: SyncBackend = new SttpHttpClientConfiguration().createSttpBackendClient(sslFactory) assertThat(victim).isNotNull assertThatThrownBy(() => victim.send(request)) diff --git a/pom.xml b/pom.xml index bcf63673..daa5ae17 100644 --- a/pom.xml +++ b/pom.xml @@ -15,45 +15,45 @@ - 11 + 17 2.13 - 2.13.13 - 1.9.22 - 1.6.0-native-mt - 8.1.1 - 2.7.18 + 2.13.14 + 2.0.0 + 1.8.1 + 8.3.5 + 2.7.18 1.7.33 4.5.13 - 7.2.3 - 3.0.0-M5 - 3.0.0-M5 - 1.9.7 - 5.4.0 - 3.12.0 - 2.11.0 - 1.6.0 - 4.9.3 - 1.1.10 + 7.2.3 + 3.2.5 + 3.2.5 + 1.9.22.1 + 5.8.0 + 3.14.0 + 2.16.1 + 3.2.0 + 4.12.0 + 1.1.16 1.19.4 - 3.0.3 - 3.5.0 - 1.41.1 - 3.13.6 - 2.9.0 - 22.1.0 - 10.2.7 - 2.6.18 + 3.1.6 + 3.5.0 + 1.44.2 + 3.14.5 + 2.11.0 + 22.1.0 + 10.5.3 + 2.8.5 1.2.0 2.4.2 2.12.3 2.3.1 - 3.0.0-RC3 - 0.7.0 + 4.0.0-M14 + 0.8.2 0.12.0 - 1.0-234-d1a2b53 + 0.23.16 11.8 1.6.0 - 1.6.7 + 2.3.11 3.285.1 4.2.4 1.3.2 @@ -63,24 +63,24 @@ 2.1.1 4.1.99.Final 2.0.62.Final - 2.7.0 - 4.1.1 - 2.13.1 - 0.8.7 - 5.8.2 - 4.8.1 - 3.22.0 + 2.10.0 + 4.2.1 + 2.17.1 + 0.8.12 + 5.10.2 + 5.12.0 + 3.25.3 2.7.8 - 1.14.12 - 5.2.1 - 3.2.10 - 2.0.2 - 1.17.30 - 5.11.2 - 3.8.1 - 3.2.4 - 4.8.1 - 4.2.rc3 + 1.14.15 + 5.3.1 + 3.2.18 + 2.2.0 + 1.17.31 + 5.15.0 + 3.13.0 + 3.5.3 + 4.9.1 + 4.5 UTF-8 2018 false @@ -226,7 +226,7 @@ ${version.fuel} - com.softwaremill.sttp.client + com.softwaremill.sttp.client4 core_${version.scala} ${version.sttp} @@ -287,22 +287,22 @@ io.ktor - ktor-client-apache + ktor-client-apache-jvm ${version.ktor} io.ktor - ktor-client-okhttp + ktor-client-okhttp-jvm ${version.ktor} io.ktor - ktor-client-android + ktor-client-android-jvm ${version.ktor} io.ktor - ktor-client-java + ktor-client-java-jvm ${version.ktor}