简体   繁体   English

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

[英]Avro.AvroException: Array does not implement non-generic IList in field

I have .netcore 3.1 api I am using kafka with confluent cloud libraries I am using and their versions are:我有 .netcore 3.1 api 我正在使用 kafka 和我正在使用的融合云库,它们的版本是:

schema registry 1.7.0 Serdes 1.3.0架构注册表 1.7.0 Serdes 1.3.0

In my schema I have:在我的架构中,我有:

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

That generates the following in my class:这会在我的课堂上产生以下内容:

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

When I try and product event I get the following error:当我尝试和产品事件时,我收到以下错误:

Avro.AvroException: Array does not implement non-generic IList in field orderLineIds Avro.AvroException:数组未在字段 orderLineIds 中实现非泛型 IList

Am I doing something wrong or missing something from my schema?我做错了什么或从我的架构中遗漏了什么?

I'm using .Net 5 and schema registry 1.8.1 and I was having the same issue.我正在使用 .Net 5 和模式注册表 1.8.1,我遇到了同样的问题。 I found that if your collection is null , the Avro serializer will throw this exception as its trying to cast to IList .我发现如果你的集合是null ,Avro 序列化程序会抛出这个异常,因为它试图强制转换为IList

I would double check that orderLineIds always has at least an empty list and is not null.我会仔细检查orderLineIds始终至少有一个空列表并且不为空。

Once I did this, my errors went away.一旦我这样做了,我的错误就消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM