Skip to content

Commit 3fa3ad5

Browse files
authored
2.12 creator test (#510)
1 parent cd885d2 commit 3fa3ad5

File tree

5 files changed

+29
-44
lines changed

5 files changed

+29
-44
lines changed

build.sbt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,14 @@ libraryDependencies ++= Seq(
3939
"com.fasterxml.jackson.core" % "jackson-core" % jacksonVersion,
4040
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVersion,
4141
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion,
42-
) ++ {
43-
CrossVersion.partialVersion(scalaVersion.value) match {
44-
case Some((2, scalaMajor)) if scalaMajor <= 11 =>
45-
Seq("com.thoughtworks.paranamer" % "paranamer" % "2.8")
46-
case _ => Seq.empty
47-
}
48-
} ++ Seq(
42+
"com.thoughtworks.paranamer" % "paranamer" % "2.8",
4943
// test dependencies
5044
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % jacksonVersion % Test,
5145
"com.fasterxml.jackson.datatype" % "jackson-datatype-guava" % jacksonVersion % Test,
5246
"com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % jacksonVersion % Test,
5347
"com.fasterxml.jackson.module" % "jackson-module-jsonSchema" % jacksonJsonSchemaVersion % Test,
5448
"io.swagger" % "swagger-core" % "1.6.2" % Test,
55-
"org.scalatest" %% "scalatest" % "3.2.3" % Test
49+
"org.scalatest" %% "scalatest" % "3.2.5" % Test
5650
)
5751

5852
// build.properties

src/main/scala-2.12/com/fasterxml/jackson/module/scala/introspect/JavaParameterIntrospector.scala

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/main/scala-2.13/com/fasterxml/jackson/module/scala/introspect/JavaParameterIntrospector.scala

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/test/scala/com/fasterxml/jackson/module/scala/deser/CreatorTest.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ object PositiveLong {
1515
def apply(str: String): PositiveLong = new PositiveLong(str.toLong)
1616
}
1717

18+
// Minimal reproducing class for the first failure case.
19+
// The `apply` methods have the same _parameter names_, which causes:
20+
// Conflicting property-based creators: already had explicitly marked creator [method regression.ConflictingJsonCreator#apply(long)],
21+
// encountered another: [method regression.ConflictingJsonCreator#apply(java.lang.String)]
22+
class ConflictingJsonCreator private (val value: Long) {
23+
override def toString() = s"ConflictingJsonCreator($value)"
24+
}
25+
object ConflictingJsonCreator {
26+
@JsonCreator
27+
def apply(value: Long): ConflictingJsonCreator = new ConflictingJsonCreator(value)
28+
@JsonCreator
29+
def apply(value: String): ConflictingJsonCreator = new ConflictingJsonCreator(value.toLong)
30+
}
31+
1832
object CreatorTest
1933
{
2034
class CreatorTestBean(val a: String, var b: String)
@@ -163,4 +177,17 @@ class CreatorTest extends DeserializationFixture {
163177
val node: JsonNode = f.valueToTree[IntNode](10)
164178
f.convertValue(node, new TypeReference[PositiveLong] {}).value shouldEqual node.asLong()
165179
}
180+
181+
it should "support multiple creator annotations with the same parameter names" in { f =>
182+
val node: JsonNode = f.valueToTree[IntNode](10)
183+
// Ensure that the parameters are actually named `value`
184+
ConflictingJsonCreator(value=10L).value shouldEqual node.asLong()
185+
ConflictingJsonCreator(value="10").value shouldEqual node.asLong()
186+
f.convertValue(node, new TypeReference[ConflictingJsonCreator] {}).value shouldEqual node.asLong()
187+
}
188+
189+
it should "not have a problem constructors and member name conflicts" in { f =>
190+
val node: JsonNode = f.valueToTree[IntNode](10)
191+
f.convertValue(node, new TypeReference[PositiveLong] {}).value shouldEqual node.asLong()
192+
}
166193
}

0 commit comments

Comments
 (0)