From 127525ebe2bf7ca48f9ccaaf653cdfc8878910e5 Mon Sep 17 00:00:00 2001 From: zy-kkk Date: Wed, 22 Nov 2023 15:22:06 +0800 Subject: [PATCH] [hotfix](jdbc catalog) fix realColumnNames serialize npe (#27280) In the previous PR #27124, we used `objectMapper.readValue` for deserialization. However, this method does not handle null fields, which can lead to issues when upgrading from older versions. Specifically, if a required field is missing in the persistent data, `String realColumnNamesJson = serializeMap.get(REAL_COLUMNS);` will return null, resulting in deserialization errors and frontend startup failure. This issue is likely to occur when upgrading from an older version that uses Jdbc Catalog to a new version including PR #27124. As this represents a specific upgrade scenario involving compatibility with old version data structures, it was not covered in the regular PR test cases. Given the specificity and difficulty in replicating such a scenario, no special test cases were added for this PR. --- .../src/main/java/org/apache/doris/catalog/JdbcTable.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcTable.java index fe397929ac..6dfd7ffc68 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcTable.java @@ -244,8 +244,12 @@ public class JdbcTable extends Table { realDatabaseName = serializeMap.get(REAL_DATABASE); realTableName = serializeMap.get(REAL_TABLE); String realColumnNamesJson = serializeMap.get(REAL_COLUMNS); - realColumnNames = objectMapper.readValue(realColumnNamesJson, new TypeReference>() { - }); + if (realColumnNamesJson != null) { + realColumnNames = objectMapper.readValue(realColumnNamesJson, new TypeReference>() { + }); + } else { + realColumnNames = Maps.newHashMap(); + } } public String getResourceName() {