Skip to content

upgrade to jackson 2.14.2 #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class AskSpec extends PekkoSpec("""
}))

val f = (act ? "ask").mapTo[String]
val (promiseActorRef, "ask") = p.expectMsgType[(ActorRef, String)]
val (promiseActorRef, "ask") = p.expectMsgType[(ActorRef, String)]: @unchecked

watch(promiseActorRef)
promiseActorRef ! "complete"
Expand All @@ -258,12 +258,12 @@ class AskSpec extends PekkoSpec("""
}), "myName")

(act ? "ask").mapTo[String]
val (promiseActorRef, "ask") = p.expectMsgType[(ActorRef, String)]
val (promiseActorRef, "ask") = p.expectMsgType[(ActorRef, String)]: @unchecked

promiseActorRef.path.name should startWith("myName")

(system.actorSelection("/user/myName") ? "ask").mapTo[String]
val (promiseActorRefForSelection, "ask") = p.expectMsgType[(ActorRef, String)]
val (promiseActorRefForSelection, "ask") = p.expectMsgType[(ActorRef, String)]: @unchecked
promiseActorRefForSelection.path.name should startWith("_user_myName")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ import pekko.actor.typed.scaladsl.TimerScheduler
import pekko.pattern.StatusReply
import org.scalatest.wordspec.AnyWordSpecLike

// #per-session-child
// dummy data types just for this sample
case class Keys()
case class Wallet()

// #per-session-child

class InteractionPatternsSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with LogCapturing {

"The interaction patterns docs" must {
Expand Down Expand Up @@ -359,12 +366,6 @@ class InteractionPatternsSpec extends ScalaTestWithActorTestKit with AnyWordSpec
}

"contain a sample for per session child" in {
// #per-session-child
// dummy data types just for this sample
case class Keys()
case class Wallet()

// #per-session-child

object KeyCabinet {
case class GetKeys(whoseKeys: String, replyTo: ActorRef[Keys])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MetricNumericConverterSpec extends AnyWordSpec with Matchers with MetricNu
}

"define a new metric" in {
val Some(metric) = Metric.create(HeapMemoryUsed, 256L, decayFactor = Some(0.18))
val Some(metric) = Metric.create(HeapMemoryUsed, 256L, decayFactor = Some(0.18)): @unchecked
metric.name should ===(HeapMemoryUsed)
metric.value should ===(256L)
metric.isSmooth should ===(true)
Expand Down
37 changes: 11 additions & 26 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,12 @@ object Dependencies {
val protobufJavaVersion = "3.16.1"
val logbackVersion = "1.2.11"

val jacksonCoreVersion = Def.setting {
if (scalaVersion.value.startsWith("3.")) {
"2.13.2"
} else {
"2.11.4"
}
}

val jacksonDatabindVersion = Def.setting {
if (scalaVersion.value.startsWith("3.")) {
"2.13.2.2"
} else {
jacksonCoreVersion.value
}
}
val jacksonCoreVersion = "2.14.2"
val jacksonDatabindVersion = jacksonCoreVersion

val scala212Version = "2.12.17"
val scala213Version = "2.13.10"
// To get the fix for https://github.com/lampepfl/dotty/issues/13106
// and restored static forwarders
val scala3Version = "3.1.2"
val scala3Version = "3.2.2" // Needed for Jackson 2.14.2
val allScalaVersions = Seq(scala213Version, scala212Version, scala3Version)

val reactiveStreamsVersion = "1.0.3"
Expand Down Expand Up @@ -138,28 +123,28 @@ object Dependencies {
val asnOne = ("com.hierynomus" % "asn-one" % "0.5.0").exclude("org.slf4j", "slf4j-api") // ApacheV2

val jacksonCore = Def.setting {
"com.fasterxml.jackson.core" % "jackson-core" % jacksonCoreVersion.value
"com.fasterxml.jackson.core" % "jackson-core" % jacksonCoreVersion
} // ApacheV2
val jacksonAnnotations = Def.setting {
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonCoreVersion.value
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonCoreVersion
} // ApacheV2
val jacksonDatabind = Def.setting {
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonDatabindVersion.value
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonDatabindVersion
} // ApacheV2
val jacksonJdk8 = Def.setting {
"com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % jacksonCoreVersion.value
"com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % jacksonCoreVersion
} // ApacheV2
val jacksonJsr310 = Def.setting {
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % jacksonCoreVersion.value
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % jacksonCoreVersion
} // ApacheV2
val jacksonScala = Def.setting {
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonCoreVersion.value
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonCoreVersion
} // ApacheV2
val jacksonParameterNames = Def.setting {
"com.fasterxml.jackson.module" % "jackson-module-parameter-names" % jacksonCoreVersion.value
"com.fasterxml.jackson.module" % "jackson-module-parameter-names" % jacksonCoreVersion
} // ApacheV2
val jacksonCbor = Def.setting {
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-cbor" % jacksonCoreVersion.value
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-cbor" % jacksonCoreVersion
} // ApacheV2
val lz4Java = "org.lz4" % "lz4-java" % "1.8.0" // ApacheV2

Expand Down
4 changes: 3 additions & 1 deletion project/PekkoDisciplinePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ object PekkoDisciplinePlugin extends AutoPlugin {
// references to deprecated PARSER fields in generated message formats?
"pekko-persistence-query",
"pekko-docs",
// references to deprecated Jackson methods that would involve a significant refactor to avoid
"pekko-serialization-jackson",
// use varargs of `Graph` in alsoTo and etc operators
"pekko-stream-tests")

Expand Down Expand Up @@ -134,7 +136,7 @@ object PekkoDisciplinePlugin extends AutoPlugin {
case Some((2, 12)) =>
disciplineScalacOptions
case _ =>
Nil
Seq("-Wconf:cat=deprecation:s")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean we disable all deprecation warnings for Scala 3 for all submodules. Is that really what we want?

You can also match by other factors, so maybe we can restrict the silencing to Jackson in particular?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To provide some context, this flag is needed for Scala 3.2.x in general, not Jackson specifically. It appears there was an issue in Scala 3.1.x where it wasn't reporting deprecations as it should and this was fixed in Scala 3.2. I also had to the do the same fix in the PR I created that only updates to Scala 3.3 (with no other changes), see https://github.com/apache/incubator-pekko/pull/270/files#diff-676691b2e85cad6026adb107942b7c9325394e20e015b131fdcebd3b2b7794b0R137.

}).toSeq,
Compile / scalacOptions --=
(if (looseProjects.contains(name.value)) undisciplineScalacOptions.toSeq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class AccrualFailureDetectorSpec extends PekkoSpec("pekko.loglevel = INFO") {
cdf(fd.phi(35L, 0, 10)) should ===(0.99977 +- 0.001)
cdf(fd.phi(40L, 0, 10)) should ===(0.99997 +- 0.0001)

for (x :: y :: Nil <- (0 to 40).toList.sliding(2)) {
fd.phi(x, 0, 10) should be < (fd.phi(y, 0, 10))
for (case x :: y :: Nil <- (0 to 40).toList.sliding(2)) {
fd.phi(x, 0, 10) should be < fd.phi(y, 0, 10)
}

cdf(fd.phi(22, 20.0, 3)) should ===(0.7475 +- 0.001)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package org.apache.pekko.serialization.jackson

import java.util.Optional
import java.util.concurrent.ConcurrentHashMap

import scala.annotation.nowarn
import scala.collection.immutable
import scala.compat.java8.OptionConverters._
import scala.util.Failure
Expand All @@ -40,7 +40,6 @@ import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule
import com.typesafe.config.Config

import org.apache.pekko
import pekko.actor.ActorSystem
import pekko.actor.ClassicActorSystemProvider
Expand Down Expand Up @@ -136,6 +135,7 @@ object JacksonObjectMapperProvider extends ExtensionId[JacksonObjectMapperProvid
jsonFactory
}

@nowarn("msg=deprecated")
private def configureObjectMapperFeatures(
bindingName: String,
objectMapper: ObjectMapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ import org.apache.pekko.serialization.jackson.JacksonMigration
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ObjectNode

import scala.annotation.nowarn

class CustomerMigration extends JacksonMigration {

override def currentVersion: Int = 2

@nowarn("msg=deprecated")
override def transform(fromVersion: Int, json: JsonNode): JsonNode = {
val root = json.asInstanceOf[ObjectNode]
if (fromVersion <= 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ActorMaterializerSpec extends StreamSpec with ImplicitSender {

p.expectMsg("hello")
a ! PoisonPill
val Failure(_) = p.expectMsgType[Try[Done]]
val Failure(_) = p.expectMsgType[Try[Done]]: @unchecked
}

"report correctly if it has been shut down from the side" in {
Expand Down