Avro模式问题-抛出空指针异常,但数据有效

问题描述 投票:1回答:1

这是正在发送的数据的示例,但由于某种原因,我收到了空指针异常,我试图剥离一些代码以使其更小,但认为可能我需要保留很多架构显示格式以及嵌套字段是什么。已编辑为仅显示相关部分,因为不希望在线发布我的架构]

{
    "eventType": "XXX",
    "correlationId": "XXX",
    "timestamp": XXX,
    "policy": {
        "policyNumber": "XXX",
        "policyId": "XXX",
        "customerNumber": "XXX",
        ......(lots more fields like this)
        "insuredsAndDrivers": [{
            ......(lots more fields )
            "driver": {
                "relationshipToInsuredCd": "IN",
                "driverTypeCd": "P",
                "occupationCd": null,
                "driverLicenses": [{
                    "licenseTypeCd": null,
                    "licenseDate": null,
                    "licenseStateProvCd": null,
                    "licensePermitNumber": null
                }]
            }
        }, {
            ......(lots more fields like this)
            },
            "driver": null
        }],
        "vehicles": [{
            .....(lots of single fields here)
            "coverages": {
                .....(lots of single fields here)
            }
        }],
        "customer": {
            "extensionFields": {
                "nif": "XXX"
            },
            "individualDetails": {
                ......(lots more fields like this)
            },
            "phones": [{
                "phoneNumber": "1234567890"
            }],
            "addresses": [{
                ......(lots more fields like this)
            }]
        },
        "previous_policy": null
    }
}

这里是Avro模式,很长一段时间对不起

{
    "type": "record",
    "namespace": "my.namespace",
    "name": "MyEvent",
    "fields": [
                    ....lots of fields here
                    {
                        "name": "insuredsAndDrivers",
                        "default": [],
                        "type": {
                            "type": "array",
                            "items": {
                                "name": "InsuredsAndDrivers_Record",
                                "default": "",
                                "type": "record",
                                "fields": [
                                     ......(lots more fields here),
                                    {
                                        "name": "driver",
                                        "type": {
                                            "name": "Driver",
                                            "default": "",
                                            "type": "record",
                                            "fields": [{
                                                    "name": "relationshipToInsuredCd",
                                                    "type": ["string", "null"],
                                                    "default": ""
                                                },
                                                {
                                                    "name": "driverTypeCd",
                                                    "type": ["string", "null"],
                                                    "default": ""
                                                },
                                                {
                                                    "name": "occupationCd",
                                                    "type": ["string", "null"],
                                                    "default": ""
                                                },
                                                {
                                                    "name": "driverLicenses",
                                                    "default": [],
                                                    "type": {
                                                        "type": "array",
                                                        "items": {
                                                            "name": "DiverLicenses_Record",
                                                            "default": "",
                                                            "type": "record",
                                                            "fields": [{
                                                                    "name": "licenseTypeCd",
                                                                    "type": ["string", "null"],
                                                                    "default": ""
                                                                },
                                                                {
                                                                    "name": "licenseDate",
                                                                    "type": ["string", "null"],
                                                                    "default": ""
                                                                },
                                                                {
                                                                    "name": "licenseStateProvCd",
                                                                    "type": ["string", "null"],
                                                                    "default": ""
                                                                },
                                                                {
                                                                    "name": "licensePermitNumber",
                                                                    "type": ["string", "null"],
                                                                    "default": ""
                                                                }
                                                            ]
                                                        }
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                ]
                            }
                        }
                    }

               ...rest of schema not relevant

我收到错误Caused by: java.lang.NullPointerException: null of com.lm.gde.eventing.avro.Driver of com.lm.gde.eventing.avro.InsuredsAndDrivers_Record of array of com.lm.gde.eventing.avro.Policy of com.lm.gde.eventing.avro.EnrichedPolicyEvent

apache-kafka schema avro confluent confluent-schema-registry
1个回答
1
投票

数组“ insuredsAndDrivers”的第二个“ InsuredsAndDrivers_Record”元素:

© www.soinside.com 2019 - 2024. All rights reserved.