shwstppr commented on code in PR #9840: URL: https://github.com/apache/cloudstack/pull/9840#discussion_r1828889255
########## engine/schema/src/main/java/com/cloud/storage/dao/StoragePoolHostDaoImpl.java: ########## @@ -169,23 +169,23 @@ public List<Long> findHostsConnectedToPools(List<Long> poolIds) { } @Override - public List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boolean sharedOnly) { - ArrayList<Pair<Long, Integer>> l = new ArrayList<Pair<Long, Integer>>(); + public boolean hasDatacenterStoragePoolHostInfo(long dcId, boolean sharedOnly) { + Long poolCount = 0L; String sql = sharedOnly ? SHARED_STORAGE_POOL_HOST_INFO : STORAGE_POOL_HOST_INFO; TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement pstmt = null; - try { - pstmt = txn.prepareAutoCloseStatement(sql); + try (PreparedStatement pstmt = txn.prepareAutoCloseStatement(sql)) { pstmt.setLong(1, dcId); - ResultSet rs = pstmt.executeQuery(); while (rs.next()) { - l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2))); + poolCount = rs.getLong(1); Review Comment: Since the method is used to find if there is a connected storage pool and both SQLs are listing IDs of storage_pool_host_ref, this should be okay. We can otherwise add those IDs to a list and check if the list is not empty but it would return the same result. -- 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-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org