mirror of https://github.com/apache/cloudstack.git
Fixed Coverity Issues Reported
This commit is contained in:
parent
5ddd0cff32
commit
45557cc020
|
|
@ -258,36 +258,25 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
|||
@Override
|
||||
public List<VMTemplateHostVO> listByTemplateStatus(long templateId, long datacenterId, long podId, VMTemplateHostVO.Status downloadState) {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
List<VMTemplateHostVO> result = new ArrayList<VMTemplateHostVO>();
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = DOWNLOADS_STATE_DC_POD;
|
||||
pstmt = txn.prepareStatement(sql);
|
||||
|
||||
String sql = DOWNLOADS_STATE_DC_POD;
|
||||
try(PreparedStatement pstmt = txn.prepareStatement(sql);) {
|
||||
pstmt.setLong(1, datacenterId);
|
||||
pstmt.setLong(2, podId);
|
||||
pstmt.setLong(3, templateId);
|
||||
pstmt.setString(4, downloadState.toString());
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
// result.add(toEntityBean(rs, false)); TODO: this is buggy in
|
||||
// GenericDaoBase for hand constructed queries
|
||||
long id = rs.getLong(1); // ID column
|
||||
result.add(findById(id));
|
||||
try(ResultSet rs = pstmt.executeQuery();) {
|
||||
while (rs.next()) {
|
||||
// result.add(toEntityBean(rs, false)); TODO: this is buggy in
|
||||
// GenericDaoBase for hand constructed queries
|
||||
long id = rs.getLong(1); // ID column
|
||||
result.add(findById(id));
|
||||
}
|
||||
}catch (SQLException e) {
|
||||
s_logger.warn("listByTemplateStatus:Exception: "+e.getMessage(), e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Exception: ", e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
if (pstmt != null) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
s_logger.warn("listByTemplateStatus:Exception: "+e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue