mirror of https://github.com/apache/cloudstack.git
coverity 1116511 and 1116513: try-with-resource on old upgrade script three issues seen by coverity as two. only one occurence of leakage
Signed-off-by: Daan Hoogland <daan@onecht.net>
This commit is contained in:
parent
3bedeeaacc
commit
f8691b2c69
|
|
@ -57,42 +57,40 @@ public class Upgrade218to22Premium extends Upgrade218to22 {
|
|||
}
|
||||
|
||||
private void updateUserStats(Connection conn) {
|
||||
try {
|
||||
|
||||
// update device_id information
|
||||
PreparedStatement pstmt =
|
||||
conn.prepareStatement("update cloud_usage.user_statistics uus set device_id = " + "(select device_id from cloud.user_statistics us where uus.id = us.id)");
|
||||
try ( // update device_id information
|
||||
PreparedStatement pstmt = conn.prepareStatement(
|
||||
"update cloud_usage.user_statistics uus set device_id = (select device_id from cloud.user_statistics us where uus.id = us.id)"
|
||||
);
|
||||
) {
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
|
||||
s_logger.debug("Upgraded cloud_usage user_statistics with deviceId");
|
||||
|
||||
// update host_id information in usage_network
|
||||
PreparedStatement pstmt1 =
|
||||
conn.prepareStatement("update cloud_usage.usage_network un set host_id = "
|
||||
+ "(select device_id from cloud_usage.user_statistics us where us.account_id = un.account_id and us.data_center_id = un.zone_id)");
|
||||
pstmt1.executeUpdate();
|
||||
pstmt1.close();
|
||||
|
||||
s_logger.debug("Upgraded cloud_usage usage_network with hostId");
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new CloudRuntimeException("Failed to upgrade user stats: ", e);
|
||||
}
|
||||
|
||||
try ( // update host_id information in usage_network
|
||||
PreparedStatement pstmt1 = conn.prepareStatement(
|
||||
"update cloud_usage.usage_network un set host_id = "
|
||||
+ "(select device_id from cloud_usage.user_statistics us where us.account_id = un.account_id and us.data_center_id = un.zone_id)");
|
||||
) {
|
||||
pstmt1.executeUpdate();
|
||||
|
||||
s_logger.debug("Upgraded cloud_usage usage_network with hostId");
|
||||
} catch (Exception e) {
|
||||
throw new CloudRuntimeException("Failed to upgrade network usage stats: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUsageIpAddress(Connection conn) {
|
||||
try {
|
||||
|
||||
// update id information
|
||||
try ( // update id information
|
||||
PreparedStatement pstmt =
|
||||
conn.prepareStatement("update cloud_usage.usage_ip_address uip set id = "
|
||||
+ "(select id from cloud.user_ip_address ip where uip.public_ip_address = ip.public_ip_address and ip.data_center_id = uip.zone_id)");
|
||||
) {
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
|
||||
s_logger.debug("Upgraded cloud_usage usage_ip_address with Id");
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new CloudRuntimeException("Failed to upgrade usage_ip_address: ", e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue