Skip to content

Commit 5543079

Browse files
committed
Merge remote-tracking branch 'FasterXML/2.19'
2 parents 9b375ff + d7f058f commit 5543079

File tree

8 files changed

+75
-4
lines changed

8 files changed

+75
-4
lines changed

.github/workflows/dep_build_v2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
java_version: ['8', '17', '21', '23']
1818
# Versions need to align with ones in 'main.yml' workflow
19-
kotlin_version: ['1.9.24', '2.0.21', '2.1.0']
19+
kotlin_version: ['1.9.24', '2.0.21', '2.1.10']
2020
env:
2121
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
2222
steps:

.github/workflows/dep_build_v3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
java_version: ['17', '21', '23']
1818
# Versions need to align with ones in 'main.yml' workflow
19-
kotlin_version: ['1.9.24', '2.0.21', '2.1.0']
19+
kotlin_version: ['1.9.24', '2.0.21', '2.1.10']
2020
env:
2121
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
2222
steps:

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
max-parallel: 5
2727
matrix:
2828
java_version: ['17', '21', '23']
29-
kotlin_version: ['1.9.25', '2.0.21', '2.1.0']
29+
kotlin_version: ['1.9.25', '2.0.21', '2.1.10']
3030
include:
3131
- java_version: '17'
3232
kotlin_version: '1.9.25'

release-notes/CREDITS-2.x

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Contributors:
1717

1818
# 2.19.0 (not yet released)
1919

20+
Tatu Saloranta (@cowtowncoder)
21+
* #889: Upgrade kotlin dep to 1.9.25 (from 1.9.24)
22+
2023
WrongWrong (@k163377)
2124
* #914: Add test case to serialize Nothing? (for #314)
2225
* #910: Add default KeyDeserializer for value class
@@ -33,6 +36,7 @@ WrongWrong (@k163377)
3336
# 2.18.4 (not yet released)
3437

3538
WrongWrong (@k163377)
39+
* #923: Fixed hasRequiredMarker to only process content defined in Kotlin
3640
* #920: Minor refactors that do not affect behavior
3741

3842
# 2.18.3 (28-Feb-2025)

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Co-maintainers:
3838

3939
2.18.4 (not yet released)
4040

41+
#923: Fixed a problem where the result of processing `hasRequiredMarker ` by a `KotlinModule` would also apply to
42+
classes defined in `Java` when `NullToEmptyCollection` or `NullToEmptyMap` was enabled.
4143
#920: Minor refactorings were made that did not affect behavior.
4244

4345
2.18.3 (28-Feb-2025)

src/main/kotlin/tools/jackson/module/kotlin/KotlinAnnotationIntrospector.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ internal class KotlinAnnotationIntrospector(
4242
// TODO: implement nullIsSameAsDefault flag, which represents when TRUE that if something has a default value, it can be passed a null to default it
4343
// this likely impacts this class to be accurate about what COULD be considered required
4444

45-
override fun hasRequiredMarker(cfg : MapperConfig<*>, m: AnnotatedMember): Boolean? =
45+
override fun hasRequiredMarker(
46+
cfg : MapperConfig<*>,
47+
m: AnnotatedMember
48+
): Boolean? = m.takeIf { it.member.declaringClass.isKotlinClass() }?.let { _ ->
4649
cache.javaMemberIsRequired(m) {
4750
try {
4851
when {
@@ -59,6 +62,7 @@ internal class KotlinAnnotationIntrospector(
5962
} catch (_: UnsupportedOperationException) {
6063
null
6164
}
65+
}
6266
}
6367

6468
override fun findSerializationConverter(config: MapperConfig<*>?, a: Annotated): Converter<*, *>? = when (a) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package tools.jackson.module.kotlin.test.github
2+
3+
import tools.jackson.databind.BeanDescription
4+
import tools.jackson.databind.ObjectMapper
5+
import tools.jackson.module.kotlin.KotlinFeature
6+
import tools.jackson.module.kotlin.jacksonObjectMapper
7+
import kotlin.test.Test
8+
import kotlin.test.assertTrue
9+
10+
class GitHub922 {
11+
private inline fun <reified T : Any> ObjectMapper.introspectSerialization(): BeanDescription =
12+
_serializationContext().introspectBeanDescription(_serializationContext().constructType(T::class.java))
13+
14+
private inline fun <reified T : Any> ObjectMapper.introspectDeserialization(): BeanDescription =
15+
_deserializationContext().introspectBeanDescription(_deserializationContext().constructType(T::class.java))
16+
17+
private fun BeanDescription.isRequired(propertyName: String): Boolean =
18+
this.findProperties().first { it.name == propertyName }.isRequired
19+
20+
@Test
21+
fun `nullToEmpty does not override specification by Java annotation`() {
22+
val mapper = jacksonObjectMapper {
23+
enable(KotlinFeature.NullToEmptyCollection)
24+
enable(KotlinFeature.NullToEmptyMap)
25+
}
26+
27+
val desc = mapper.introspectDeserialization<GitHub922RequiredCollectionsDtoJava>()
28+
29+
assertTrue(desc.isRequired("list"))
30+
assertTrue(desc.isRequired("map"))
31+
}
32+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package tools.jackson.module.kotlin.test.github;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
public class GitHub922RequiredCollectionsDtoJava {
10+
private final List<String> list;
11+
private final Map<String, String> map;
12+
13+
@JsonCreator
14+
public GitHub922RequiredCollectionsDtoJava(
15+
@JsonProperty(value = "list", required = true) List<String> list,
16+
@JsonProperty(value = "map", required = true) Map<String, String> map
17+
) {
18+
this.list = list;
19+
this.map = map;
20+
}
21+
22+
public List<String> getList() {
23+
return list;
24+
}
25+
26+
public Map<String, String> getMap() {
27+
return map;
28+
}
29+
}

0 commit comments

Comments
 (0)