alibaba/canal · error · NullPointerException

KuduMapping.database

Error message

KuduMapping.database

What it means

Thrown by KuduMappingConfig.validate() when kuduMapping.database is null or empty. Validation runs inside the config loader for each parsed yml, so this surfaces during startup of the kudu adapter, before any sync begins. database represents the source schema/database name used to route events.

Source

Thrown at client-adapter/kudu/src/main/java/com/alibaba/otter/canal/client/adapter/kudu/config/KuduMappingConfig.java:84

    public KuduMapping getKuduMapping() {
        return kuduMapping;
    }

    public void setKuduMapping(KuduMapping kuduMapping) {
        this.kuduMapping = kuduMapping;
    }

    public String getDestination() {
        return destination;
    }

    public void setDestination(String destination) {
        this.destination = destination;
    }

    public void validate() {
        if (kuduMapping.database == null || kuduMapping.database.isEmpty()) {
            throw new NullPointerException("KuduMapping.database");
        }
    }

    public static class KuduMapping implements AdapterMapping {

        private String              database;                           // 数据库名或schema名
        private String              table;                              // 表名
        private Map<String, String> targetPk    = new LinkedHashMap<>(); // 目标表主键字段
        private boolean             mapAll      = false;                // 映射所有字段
        private String              targetDb;                           // 目标库名
        private String              targetTable;                        // 目标表名
        private Map<String, String> targetColumns;                      // 目标表字段映射

        private String              etlCondition;                       // etl条件sql

        private int                 readBatch   = 5000;
        private int                 commitBatch = 5000;                 // etl等批量提交大小

View on GitHub (pinned to 87be50e876)

Solutions

  1. Open the failing kudu yml and add a non-empty 'database:' under kuduMapping.
  2. Verify the kuduMapping block is indented two spaces so 'database' is its child, not a top-level key.
  3. Re-run startup; the error names only the missing field, so fix any subsequent validate failures reported next.

Example fix

# before
kuduMapping:
  table: user
# after
kuduMapping:
  database: mytest
  table: user
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate a parsed KuduMappingConfig before the loader does.
KuduMapping m = config.getKuduMapping();
if (m == null || m.getDatabase() == null || m.getDatabase().isEmpty()) {
    throw new IllegalArgumentException(
        "kudu yml missing kuduMapping.database for " + fileName);
}

Prevention

When it happens

Trigger: A kudu mapping yml is parsed successfully but its kuduMapping block omits 'database:' or sets it to an empty string, then validate() is called by KuduMappingConfigLoader.load().

Common situations: A new mapping yml was copied from a template and the 'database:' line was deleted or left blank. Indentation is wrong so 'database' is not parsed as a child of kuduMapping.

Related errors


AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14). Data as JSON: /api/errors/a637557efdf53ecf. Report an issue: GitHub.