【问题标题】:Avro.AvroException: Array does not implement non-generic IList in fieldAvro.AvroException:数组未在字段中实现非泛型 IList
【发布时间】:2021-11-16 17:27:06
【问题描述】:

我有 .netcore 3.1 api 我正在使用 kafka 和我正在使用的融合云库,它们的版本是:

架构注册表 1.7.0 Serdes 1.3.0

在我的架构中,我有:

{
  "name": "orderLineIds",
  "type": {
    "type": "array",
    "items": "int"
  },
  "default": [],
  "doc": "Associated order line item ids related to this promotion"
}

这会在我的课堂上生成以下内容:

        public IList<System.Int32> orderLineIds
    {
        get
        {
            return this._orderLineIds;
        }
        set
        {
            this._orderLineIds = value;
        }
    }

当我尝试产品活动时,我收到以下错误:

Avro.AvroException: 数组未在中实现非泛型 IList 字段 orderLineIds

我做错了什么或从我的架构中遗漏了什么?

【问题讨论】:

    标签: c# apache-kafka avro asp.net-core-3.1 confluent-platform


    【解决方案1】:

    我正在使用 .Net 5 和架构注册表 1.8.1,我遇到了同样的问题。我发现如果您的集合为空,Avro 序列化程序将抛出此异常,因为它试图转换为 IList

    我会仔细检查orderLineIds 是否总是至少有一个空列表并且不为空。

    一旦我这样做了,我的错误就消失了。

    【讨论】:

      猜你喜欢
      • 2013-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多