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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to