mirror of https://github.com/apache/cloudstack.git
Fixed Coverity Issues Reported
This commit is contained in:
parent
3bb344281a
commit
2018d7d977
|
|
@ -115,33 +115,21 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
|||
// TODO: order by rand() is slow if there are lot of hosts
|
||||
sbuilder.append(" ORDER by rand() limit 1");
|
||||
String sql = sbuilder.toString();
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
HostVO host = null;
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
|
||||
try {
|
||||
pstmt = txn.prepareStatement(sql);
|
||||
try(PreparedStatement pstmt = txn.prepareStatement(sql);) {
|
||||
pstmt.setLong(1, poolId);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
long id = rs.getLong(1);
|
||||
host = hostDao.findById(id);
|
||||
try(ResultSet rs = pstmt.executeQuery();) {
|
||||
while (rs.next()) {
|
||||
long id = rs.getLong(1);
|
||||
host = hostDao.findById(id);
|
||||
}
|
||||
}catch (SQLException e) {
|
||||
s_logger.warn("can't find endpoint", e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
s_logger.warn("can't find endpoint", e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
if (pstmt != null) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (host == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue