首页 > 解决方案 > 数据融合 - 参数设置器插件抛出空指针异常

问题描述

参数设置器 - HTTP 发布端点 url。下面是参数设置器插件配置。

 {
            "name": "Argument Setter",
            "plugin": {
                "name": "ArgumentSetter",
                "type": "action",
                "label": "Argument Setter",
                "artifact": {
                    "name": "argument-setter-plugins",
                    "version": "1.1.1",
                    "scope": "USER"
                },
                "properties": {
                    "method": "POST",
                    "connectTimeout": "60000",
                    "readTimeout": "60000",
                    "numRetries": "0",
                    "followRedirects": "true",
                    "url": "-----url----",
                    "body": "{\"type\": \"DELTA\", \"fileType\": \"CSV\", \"targetName\": \"DATAFUSION_TEST_1\", \"dataPoolId\": \"4d3164d9-c8e4-4042-9c69-ff758a17b140\"}"
                }
            },
            "outputSchema": [
                     {
                    "name": "id",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "targetName",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "lastModified",
                    "type": "int",
                    "nullable" : true
                },
                {
                    "name": "lastPing",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "status",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "type",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "fileType",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "targetSchema",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "upsertStrategy",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "fallbackVarcharLength",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "dataPoolId",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "connectionId",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "postExecutionQuery",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "sanitizedPostExecutionQuery",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "allowDuplicate",
                    "type": "boolean",
                    "nullable" : true
                },
                {
                    "name": "tableSchema",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "mirrorTargetNames",
                    "type": "array",
                    "nullable" : true
                },
                {
                    "name": "changeDate",
                    "type": "int",
                    "nullable" : true
                },
                {
                    "name": "keys",
                    "type": "array",
                    "nullable" : true
                },
                {
                    "name": "logs",
                    "type": "array",
                    "nullable" : true
                },
                {
                    "name": "csvParsingOptions",
                    "type": "string",
                    "nullable" : true
                },
                {
                    "name": "optionalTenantId",
                    "type": "string",
                    "nullable" : true
                }
            ]
        }
    ],

来自端点 url 的响应如下所示

[{
    "id": "b489dc71-96fd-4e94-bcc5-9a4b3732855e",
    "targetName": "POSTMAN_TBL",
    "lastModified": 1631598169840,
    "lastPing": null,
    "status": "NEW",
    "type": "DELTA",
    "fileType": "PARQUET",
    "targetSchema": null,
    "upsertStrategy": "UPSERT_WITH_UNCHANGED_METADATA",
    "fallbackVarcharLength": null,
    "dataPoolId": "f37b8619-30e2-4804-9355-38d123142ac4",
    "connectionId": null,
    "postExecutionQuery": null,
    "sanitizedPostExecutionQuery": null,
    "allowDuplicate": false,
    "tableSchema": null,
    "changeDate": 1631598169840,
    "mirrorTargetNames": [],
    "keys": [],
    "logs": [],
    "csvParsingOptions": null,
    "optionalTenantId": null
}
 ]

当我执行此操作时,我在点击端点 url 后得到 200 响应。但是管道因 NullPointerException 而失败

java.lang.NullPointerException: null
    at io.cdap.plugin.ArgumentSetter.handleResponse(ArgumentSetter.java:73) ~[na:na]
    at io.cdap.plugin.http.HTTPArgumentSetter.run(HTTPArgumentSetter.java:76) ~[na:na]
    at io.cdap.cdap.etl.common.plugin.WrappedAction.lambda$run$1(WrappedAction.java:49) ~[na:na]        

有人可以帮我我在这里想念什么吗?

标签: google-cloud-platformnullpointerexceptiongoogle-cloud-data-fusioncdap

解决方案


如评论中所述,来自服务器的响应必须采用以下格式构建:

{
    "arguments" : [
        { argument }, { argument }, ..., {argument}
    ]
}

由于您的响应不是以这种格式构建的,因此您NullPointerException在执行管道时会得到一个。

请参阅文档以供参考https://github.com/data-integrations/argument-setter/tree/9f6aabbf28e00644726d485188235b406cac522f#usage


推荐阅读