From 29ce28838474d8b7143584be8c94830cf6e3d78e Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Mon, 24 Jun 2024 16:48:16 +0200 Subject: [PATCH] 2.12 fixes --- 27/src/main/scala/io/circe/jackson/JacksonCompat.scala | 4 +++- shared/src/main/scala/io/circe/jackson/package.scala | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/27/src/main/scala/io/circe/jackson/JacksonCompat.scala b/27/src/main/scala/io/circe/jackson/JacksonCompat.scala index 5a19f17..61a3b56 100644 --- a/27/src/main/scala/io/circe/jackson/JacksonCompat.scala +++ b/27/src/main/scala/io/circe/jackson/JacksonCompat.scala @@ -29,8 +29,10 @@ private[jackson] trait JacksonCompat { protected def handleUnexpectedToken(context: DeserializationContext)( klass: Class[_], parser: JsonParser - ): Unit = + ): Unit = { + val _ = parser throw context.mappingException(klass) + } protected def objectNodeSetAll(node: ObjectNode, fields: java.util.Map[String, JsonNode]): JsonNode = node.setAll(fields) diff --git a/shared/src/main/scala/io/circe/jackson/package.scala b/shared/src/main/scala/io/circe/jackson/package.scala index 87516f1..f7a470a 100644 --- a/shared/src/main/scala/io/circe/jackson/package.scala +++ b/shared/src/main/scala/io/circe/jackson/package.scala @@ -23,6 +23,7 @@ import java.io._ import java.math.{ BigDecimal => JBigDecimal } import java.nio.ByteBuffer import scala.jdk.CollectionConverters._ +import scala.collection.compat._ /** * Support for Jackson-powered parsing and printing for circe. @@ -87,8 +88,8 @@ package object jackson extends WithJacksonMapper with JacksonParser with Jackson } }, TextNode.valueOf(_), - array => JsonNodeFactory.instance.arrayNode.addAll(array.map(circeToJackson).asJava), - obj => objectNodeSetAll(JsonNodeFactory.instance.objectNode, obj.toMap.view.mapValues(circeToJackson).toMap.asJava) + array => JsonNodeFactory.instance.arrayNode.addAll(array.map(circeToJackson(_)).asJava), + obj => objectNodeSetAll(JsonNodeFactory.instance.objectNode, obj.toMap.view.mapValues(circeToJackson(_)).toMap.asJava) ) /** @@ -108,9 +109,9 @@ package object jackson extends WithJacksonMapper with JacksonParser with Jackson Json.fromBigInt(node.bigIntegerValue) } case JsonNodeType.ARRAY => - Json.fromValues(node.elements.asScala.map(jacksonToCirce).iterator.to(Iterable)) + Json.fromValues(node.elements.asScala.map(jacksonToCirce(_)).to(Iterable)) case JsonNodeType.OBJECT => - Json.fromFields(node.fields.asScala.map(m => (m.getKey, jacksonToCirce(m.getValue))).iterator.to(Iterable)) + Json.fromFields(node.fields.asScala.map(m => (m.getKey, jacksonToCirce(m.getValue))).to(Iterable)) case _ => Json.Null }