我有以下 Avro 架构定义。但是在运行应用程序时出现错误。我已经设置了值但仍然得到问题可能在哪里?
{
"type": "record",
"name": "ContractEvent,
"namespace": "com.company.pkg",
"fields": [
{
"name": "factoryId",
"type": "string"
},
{
"name": "factoryData",
"type": [
"null",
{
"type": "map",
"values": "string"
}
],
"default": null
},
{ // more types here..
}
这就是我在 Kotlin 中设置值的方式。
fun buildFactory(): Factory {
val map = mutableMapOf<String, String>()
map["1"] = "factory"
FactoryEvent.newBuilder()
// .setFactoryData(mapOf("1" to "factory")) // 1st way I tried but error.
.setFactoryData(map) // this is how 2nd way. set a map created separately, but error
.build()
}
=== 堆栈跟踪
Exception in thread "DefaultDispatcher-worker-1" Path in schema: --> event
at org.apache.avro.generic.GenericData.getDefaultValue(GenericData.java:1175)
at org.apache.avro.data.RecordBuilderBase.defaultValue(RecordBuilderBase.java:138)