From be7b820519e593e9f0ba9c03910fe117101b7d5a Mon Sep 17 00:00:00 2001 From: chenmutime Date: Fri, 29 Dec 2023 17:00:50 +0800 Subject: [PATCH] fix: To avoid converting null to "null", skip null passwords (#5057) * Update RestfulApiHelper.java * fix: add missing import * fix: format code using mvn --- .../core/restful/RestfulApiHelper.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/RestfulApiHelper.java b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/RestfulApiHelper.java index 9651bb265b..72f5c9f899 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/RestfulApiHelper.java +++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/RestfulApiHelper.java @@ -66,10 +66,11 @@ public static void encryptPasswordKey( keyDefinitionList.forEach( keyDefinition -> { if (keyDefinition.getValueType() == DataSourceParamKeyDefinition.ValueType.PASSWORD) { - String password = String.valueOf(connectParams.get(keyDefinition.getKey())); + Object password = connectParams.get(keyDefinition.getKey()); if (null != password) { connectParams.put( - keyDefinition.getKey(), new String(new Base64().encode(password.getBytes()))); + keyDefinition.getKey(), + new String(new Base64().encode(String.valueOf(password).getBytes()))); } } }); @@ -86,10 +87,11 @@ public static void decryptPasswordKey( keyDefinitionList.forEach( keyDefinition -> { if (keyDefinition.getValueType() == DataSourceParamKeyDefinition.ValueType.PASSWORD) { - String password = String.valueOf(connectParams.get(keyDefinition.getKey())); + Object password = connectParams.get(keyDefinition.getKey()); if (null != password) { connectParams.put( - keyDefinition.getKey(), new String(new Base64().decode(password.getBytes()))); + keyDefinition.getKey(), + new String(new Base64().decode(String.valueOf(password).getBytes()))); } } });