Skip to content

Commit

Permalink
Update circe, logback, objenesis, bcpkix, bcprov, http4s, typesafeCon…
Browse files Browse the repository at this point in the history
…fig versions (#1732)

* Update bcpkix-jdk15on, bcprov-jdk15on to 1.78.1

* Update objenesis to 3.4

* Update circe-core, circe-generic, ... to 0.14.9

* Update logback-classic to 1.5.7

* chore: add sbt-scalafix plugin

* chore: update circe-generic-extras to version 0.14.4

* chore: update http4sVersion to 0.22.15

* chore: applied design changes of http4s 0.22.x

* chore: http4s 0.22.x migration complete

* chore: update typeSafeConfig to version 1.4.3

* chore: ignore kotlin compiler version updates

---------

Co-authored-by: Scala Steward <[email protected]>
  • Loading branch information
bekiroguz and scala-steward authored Sep 3, 2024
1 parent 91e39e9 commit 18aa9af
Show file tree
Hide file tree
Showing 24 changed files with 122 additions and 107 deletions.
5 changes: 3 additions & 2 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ updates.pin = [
{ groupId = "com.github.cb372", artifactId = "cats-retry", version = "2."}
]

# ignore updates for cats-effect 3.x compatible versions
# ignore kotlin compiler version updates and http4s updates for cats-effect 3.x compatible versions
updates.ignore = [
{ groupId = "org.http4s", version = "0.23." },
{ groupId = "org.http4s", version = "1." }
{ groupId = "org.http4s", version = "1." },
{ groupId = "org.jetbrains.kotlin" }
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.ing.bakery.smoke
import cats.effect.{ContextShift, IO, Resource, Timer}
import com.ing.bakery.smoke.k8s.{DefinitionFile, Namespace, Pod}
import org.http4s.Uri
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder

import scala.concurrent.ExecutionContext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.effect.{ContextShift, IO, Resource, Timer}
import org.http4s.Method._
import org.http4s.Uri
import org.http4s.client.Client
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import org.http4s.client.dsl.io._

import scala.concurrent.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.http4s._
import org.http4s.dsl.io._
import org.http4s.implicits._
import org.http4s.server.Router
import org.http4s.server.blaze.BlazeServerBuilder
import org.http4s.blaze.server.BlazeServerBuilder

import scala.concurrent.ExecutionContext
import scala.concurrent.duration._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.ing.bakery.metrics.MetricService
import io.prometheus.client.Counter
import org.http4s.circe._
import org.http4s.client.Client
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import org.http4s.dsl.io._
import org.http4s._

Expand All @@ -23,11 +23,14 @@ object RemoteInteractionClient {
def resource(headers: Headers,
pool: ExecutionContext,
metricService: MetricService,
tlsConfig: Option[BakeryHttp.TLSConfig])(implicit cs: ContextShift[IO], timer: Timer[IO]): Resource[IO, RemoteInteractionClient] =
BlazeClientBuilder[IO](pool, tlsConfig.map(BakeryHttp.loadSSLContext))
.withCheckEndpointAuthentication(false)
.resource
.map(new BaseRemoteInteractionClient(_, headers, metricService))
tlsConfig: Option[BakeryHttp.TLSConfig])(implicit cs: ContextShift[IO], timer: Timer[IO]): Resource[IO, RemoteInteractionClient] = {

tlsConfig.map(BakeryHttp.loadSSLContext)
.fold(BlazeClientBuilder[IO](pool))(BlazeClientBuilder[IO](pool).withSslContext)
.withCheckEndpointAuthentication(false)
.resource
.map(new BaseRemoteInteractionClient(_, headers, metricService))
}
}

trait RemoteInteractionClient {
Expand All @@ -49,12 +52,15 @@ class BaseRemoteInteractionClient(
import RemoteInteractionClient._
import com.ing.baker.runtime.serialization.InteractionExecutionJsonCodecs._
import com.ing.baker.runtime.serialization.JsonCodec._
def entityCodecs: (EntityEncoder[IO, ExecutionRequest], EntityDecoder[IO, ExecutionResult], EntityDecoder[IO, Interactions]) =
override def entityCodecs: (EntityEncoder[IO, ExecutionRequest], EntityDecoder[IO, ExecutionResult], EntityDecoder[IO, Interactions]) =
(jsonEncoderOf[IO, ExecutionRequest],
jsonOf[IO, ExecutionResult],
jsonOf[IO, Interactions])

private implicit lazy val (interactionEntityDecoder, executeRequestEntityEncoder, executeResponseEntityDecoder) = entityCodecs
private implicit lazy val (
interactionEntityDecoder: EntityEncoder[IO, ExecutionRequest],
executeRequestEntityEncoder: EntityDecoder[IO, ExecutionResult],
executeResponseEntityDecoder: EntityDecoder[IO, Interactions]) = entityCodecs

def interfaces(uri: Uri): IO[Interactions] =
client.expect[Interactions](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import io.prometheus.client.{Collector, CollectorRegistry, Counter}
import io.prometheus.jmx.JmxCollector
import org.http4s.dsl.io._
import org.http4s.implicits.http4sKleisliResponseSyntaxOptionT
import org.http4s.server.blaze.BlazeServerBuilder
import org.http4s.blaze.server.BlazeServerBuilder
import org.http4s.server.{Router, Server}
import org.http4s._
import org.typelevel.ci._

import java.io.CharArrayWriter
import java.net.InetSocketAddress
Expand Down Expand Up @@ -46,7 +47,7 @@ object MetricService extends LazyLogging {
def defaultInstance = new MetricService(new CollectorRegistry(true))

def resourceServer(socketAddress: InetSocketAddress, registry: CollectorRegistry, ec: ExecutionContext)
(implicit cs: ContextShift[IO], timer: Timer[IO]): Resource[IO, Server[IO]] = {
(implicit cs: ContextShift[IO], timer: Timer[IO]): Resource[IO, Server] = {
val encoder = EntityEncoder.stringEncoder

def fromPrometheus: String = {
Expand All @@ -68,7 +69,7 @@ object MetricService extends LazyLogging {
Response(
status = Ok,
body = encoder.toEntity(exportMetrics).body,
headers = Headers.of(Header("Content-Type", TextFormat.CONTENT_TYPE_004))
headers = Headers(Header.Raw(ci"Content-Type", TextFormat.CONTENT_TYPE_004))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import java.net.InetSocketAddress
import cats.effect.{ContextShift, IO, Resource, Timer}
import org.http4s.dsl.io.{->, /, GET, Ok, Root, _}
import org.http4s.implicits._
import org.http4s.server.blaze._
import org.http4s.blaze.server._
import org.http4s.server.{Router, Server}
import org.http4s.{HttpApp, HttpRoutes}

import scala.concurrent.ExecutionContext

object HealthService {

def resource(address: InetSocketAddress)(implicit cs: ContextShift[IO], clock: Timer[IO]): Resource[IO, Server[IO]] =
def resource(address: InetSocketAddress)(implicit cs: ContextShift[IO], clock: Timer[IO]): Resource[IO, Server] =
BlazeServerBuilder[IO](ExecutionContext.global)
.bindSocketAddress(address)
.withHttpApp(new HealthService().build)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.http4s.circe._
import org.http4s.dsl.io._
import org.http4s.implicits._
import org.http4s.metrics.prometheus.Prometheus
import org.http4s.server.blaze._
import org.http4s.blaze.server._
import org.http4s.server.middleware.{Logger, Metrics}
import org.http4s.server.{Router, Server}

Expand All @@ -36,7 +36,7 @@ object RemoteInteractionService {
metricsPort: Int = 9096,
metricsEnabled: Boolean = false,
apiUrlPrefix: String = "/api/bakery/interactions",
registry: Option[CollectorRegistry] = None)(implicit timer: Timer[IO], cs: ContextShift[IO], executionContext: ExecutionContext): Resource[IO, Server[IO]] = {
registry: Option[CollectorRegistry] = None)(implicit timer: Timer[IO], cs: ContextShift[IO], executionContext: ExecutionContext): Resource[IO, Server] = {

val idToNameMap = interactions.map(i => URLEncoder.encode(i.shaBase64, "UTF-8").take(8) -> i.name).toMap

Expand All @@ -49,8 +49,8 @@ object RemoteInteractionService {
val service = new RemoteInteractionService(interactions)

def interactionRequestClassifier(request: Request[IO]): Option[String] = if (interactionPerTypeMetricsEnabled) {
val p = request.pathInfo.split('/') // ... /interactions/<id>/execute - we take ID part we care most about
(if (p.length == 4) Some(p(2)) else None).map(v => idToNameMap.getOrElse(v.take(8), "unknown"))
val segments = request.pathInfo.segments // ... /interactions/<id>/execute - we take ID part we care most about
(if (segments.length == 4) Some(segments(2)) else None).map(v => idToNameMap.getOrElse(v.toString.take(8), "unknown"))
} else None

val collectorRegistry = registry.getOrElse(CollectorRegistry.defaultRegistry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.ing.bakery.testing.BakeryFunSpec
import org.http4s.Method._
import org.http4s.Uri
import org.http4s.client.Client
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import org.http4s.client.dsl.io._
import org.scalatest.ConfigMap
import org.scalatest.matchers.should.Matchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class RemoteInteractionSpec extends BakeryFunSpec {
val result: IO[Option[String]] = client.execute(uri, implementation0.shaBase64, Seq(ingredient0, ingredient1), Map.empty)
.map(_ => None)
.handleErrorWith {
case _: java.net.ConnectException | Command.EOF => IO.pure(Some("connection error"))
case _: java.net.SocketException | Command.EOF => IO.pure(Some("connection error"))
case e => IO.raiseError(e)
}
result.map(result => assert(result === Some("connection error")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.ing.bakery.metrics.MetricService
import com.typesafe.config.Config
import com.typesafe.scalalogging.LazyLogging
import org.http4s.client.Client
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import org.http4s.{Headers, Uri}
import scalax.collection.ChainingOps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.ing.bakery.metrics.MetricService
import com.typesafe.config.ConfigFactory
import io.prometheus.client.CollectorRegistry
import org.http4s.Status.Ok
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.ing.baker.runtime.akka.AkkaBaker
import com.ing.baker.runtime.akka.internal.CachingInteractionManager
import com.ing.baker.runtime.scaladsl._
import com.typesafe.config.ConfigFactory
import org.http4s.server.blaze.BlazeServerBuilder
import org.http4s.blaze.server.BlazeServerBuilder
import org.log4s.Logger
import webshop.webservice.recipe.{MakePaymentInstance, ReserveItemsInstance, ShipItemsInstance}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.ing.baker.compiler.RecipeCompiler
import com.ing.baker.http.client.scaladsl.BakerClient
import com.typesafe.config.ConfigFactory
import org.http4s.Uri
import org.http4s.server.blaze.BlazeServerBuilder
import org.http4s.blaze.server.BlazeServerBuilder

import scala.concurrent.{ExecutionContext, ExecutionContextExecutor}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.effect.{ContextShift, IO, Resource, Timer}
import org.http4s.Method._
import org.http4s.Uri
import org.http4s.client.Client
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import org.http4s.client.dsl.io._

import scala.concurrent.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.effect.{ContextShift, IO, Timer}
import com.ing.baker.http.client.common.TLSConfig
import com.ing.baker.http.client.scaladsl.{BakerClient => ScalaClient, EndpointConfig}
import com.ing.baker.runtime.javadsl.{Baker => JavaBaker}
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import org.http4s.{Request, Uri}

import java.util.concurrent.CompletableFuture
Expand Down Expand Up @@ -45,9 +45,8 @@ object BakerClient {
implicit val contextShift: ContextShift[IO] = IO.contextShift(ec)
implicit val timer: Timer[IO] = IO.timer(ec)

val future = BlazeClientBuilder[IO](
executionContext = connectionPool,
sslContext = sslContext)
val future = sslContext
.fold(BlazeClientBuilder[IO](connectionPool))(BlazeClientBuilder[IO](connectionPool).withSslContext)
.resource
.map { client =>
new ScalaClient(
Expand Down
Loading

0 comments on commit 18aa9af

Please sign in to comment.