You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/12/21 08:01:58 UTC

[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7003: utils,framework/db: Introduce new database encryption cipher based on AesGcmJce

DaanHoogland commented on code in PR #7003:
URL: https://github.com/apache/cloudstack/pull/7003#discussion_r1054081625


##########
engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java:
##########
@@ -417,11 +417,12 @@ private void initializeDatabaseEncryptors() {
 
             errorMessage = "Unable to get the 'init' value from 'configuration' table in the 'cloud' database";
             String sql = "SELECT value from configuration WHERE name = 'init'";
-            PreparedStatement pstmt = conn.prepareStatement(sql);
-            ResultSet result = pstmt.executeQuery();
-            if (result.next()) {
-                String init = result.getString(1);
-                s_logger.info("init = " + DBEncryptionUtil.decrypt(init));
+            try (PreparedStatement pstmt = conn.prepareStatement(sql);
+                 ResultSet result = pstmt.executeQuery()) {
+                if (result.next()) {
+                    String init = result.getString(1);
+                    s_logger.info("init = " + DBEncryptionUtil.decrypt(init));
+                }

Review Comment:
   this try is good, but it would be better to have it in a separate method. It will be clearer (from the stacktrace) in which try something went wrong. (nested try clause)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org