Skip to content

[Bug]: S3 Writer处理NULL值逻辑缺少else分支,产生重复null值 #1344

Closed

Description

@xiaojun623

1️⃣ 问题描述 | Problem Description

使用s3writer写到oss,原始数据的某个字段是null(sqlserver数据库,varchar或bigint类型),oss文件对应的位置却是:....,\N,null,.... 产生了重复null值,测试如下:

原始数据: ....,978292584, NULL, '2010-11-05 00:00:00.000',....
如果不配置nullFormat属性,oss文件内容:....,978292584,\N,null,2010-11-05 00:00:00.0,....
如果配置"nullFormat": "null",oss文件内容:....,978292584,null,null,2010-11-05 00:00:00.0,....
如果配置"nullFormat": "",即空字符串,oss文件内容:....,978292584,,null,2010-11-05 00:00:00.0,....

分析源码,发现在 com.wgzhao.addax.plugin.writer.s3writer.writer.TextWriter.java:269-280 的 record2String方法中存在逻辑错误:

if (column == null || column.asString() == null) {
sj.add(this.nullFormat); // 这里添加了 nullFormat
}
// ... 但是代码继续执行,没有 else 分支
sj.add(column.asString()); // 这里又添加了 column.asString()

当字段为 NULL 时,代码先添加了 nullFormat,然后继续执行又添加了 column.asString()(此时为 "null"),导致出现重复的 null 值。

期望:正确输出单一null值

2️⃣ 当前使用的 Addax 版本 | Addax Version

6.0.3

3️⃣ 操作系统类型 | Operating System

Windows

4️⃣ 使用的 Java JDK 版本 | Java JDK Version

java 17.0.12 2024-07-16 LTS

5️⃣ 相关日志/输出结果 | Relevant Log Output

Activity

  1. wgzhao commented on Sep 2, 2025

    @wgzhao
    Owner

    thanks

  2. added a commit that references this issue on Sep 4, 2025
    158c184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions