Fixed NullPointerException when filter contain tags

This commit is contained in:
greenart7c3
2026-01-30 09:00:52 -03:00
parent 8bfd670f8b
commit f2d7b115d9
2 changed files with 15 additions and 2 deletions
@@ -55,8 +55,8 @@ class ManualFilterDeserializer {
ids = jsonObject.get("ids")?.mapNotNull { it.asTextOrNull() },
authors = jsonObject.get("authors")?.mapNotNull { it.asTextOrNull() },
kinds = jsonObject.get("kinds")?.mapNotNull { it.asIntOrNull() },
tags = tagsIn.associateWith { jsonObject.get(it).mapNotNull { it.asTextOrNull() } },
tagsAll = tagsAll.associateWith { jsonObject.get(it).mapNotNull { it.asTextOrNull() } },
tags = tagsIn.associateWith { jsonObject.get("#$it").mapNotNull { it.asTextOrNull() } },
tagsAll = tagsAll.associateWith { jsonObject.get("&$it").mapNotNull { it.asTextOrNull() } },
since = jsonObject.get("since")?.asLongOrNull(),
until = jsonObject.get("until")?.asLongOrNull(),
limit = jsonObject.get("limit")?.asIntOrNull(),
@@ -161,4 +161,17 @@ class JacksonMapperTest {
assertEquals(null, deserialized.ids)
}
@Test
fun shouldNotThrowExceptionWhenDeserializingFilterTags() {
val json =
Filter(
tags = mapOf("p" to listOf("123")),
tagsAll = mapOf("p" to listOf("123")),
).toJson()
val deserialized = JacksonMapper.fromJsonTo<Filter>(json)
assertEquals(true, deserialized.tags?.keys?.contains("p"))
assertEquals(true, deserialized.tagsAll?.keys?.contains("p"))
}
}