diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 07d2a65984f4a..8620c4dccfbab 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -32,6 +32,7 @@ 1. Sharding: Remove ShardingRouteAlgorithmException check logic temporarily to support different actual table name config - [#33367](https://github.com/apache/shardingsphere/pull/33367) 1. Sharding: Fix SQL COUNT with GROUP BY to prevent incorrect row returns - [#33380](https://github.com/apache/shardingsphere/pull/33380) 1. Sharding: Fix avg, sum, min, max function return empty data when no query result return - [#33449](https://github.com/apache/shardingsphere/pull/33449) +1. Encrypt: Fix merge exception without encrypt rule in database - [#33708](https://github.com/apache/shardingsphere/pull/33708) ### Change Logs diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java index c36d8075c8e0b..654378c557f94 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java +++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java @@ -65,12 +65,12 @@ public Object getValue(final int columnIndex, final Class type) throws SQLExc ShardingSphereDatabase database = metaData.containsDatabase(columnProjection.get().getColumnBoundInfo().getOriginalDatabase().getValue()) ? metaData.getDatabase(columnProjection.get().getColumnBoundInfo().getOriginalDatabase().getValue()) : this.database; - EncryptRule rule = database.getRuleMetaData().getSingleRule(EncryptRule.class); - if (!rule.findEncryptTable(originalTableName).map(optional -> optional.isEncryptColumn(originalColumnName)).orElse(false)) { + Optional rule = database.getRuleMetaData().findSingleRule(EncryptRule.class); + if (!rule.isPresent() || !rule.get().findEncryptTable(originalTableName).map(optional -> optional.isEncryptColumn(originalColumnName)).orElse(false)) { return mergedResult.getValue(columnIndex, type); } Object cipherValue = mergedResult.getValue(columnIndex, Object.class); - EncryptColumn encryptColumn = rule.getEncryptTable(originalTableName).getEncryptColumn(originalColumnName); + EncryptColumn encryptColumn = rule.get().getEncryptTable(originalTableName).getEncryptColumn(originalColumnName); String schemaName = selectStatementContext.getTablesContext().getSchemaName() .orElseGet(() -> new DatabaseTypeRegistry(selectStatementContext.getDatabaseType()).getDefaultSchemaName(database.getName())); try {