From 8d36af003390d5f46b48b323cb7a629b8a348acb Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 13 Apr 2011 16:02:11 -0700 Subject: [PATCH] fixed NPE --- .../com/cloud/storage/StorageManagerImpl.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 8c0a4fead3f..fa46821a81b 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -1298,22 +1298,22 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag } - @DB private boolean deletePoolStats(Long poolId) { - - CapacityVO capacity1 = _capacityDao.findByHostIdType(poolId, CapacityVO.CAPACITY_TYPE_STORAGE); - CapacityVO capacity2 = _capacityDao.findByHostIdType(poolId, CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED); + CapacityVO capacity1 = _capacityDao.findByHostIdType(poolId, CapacityVO.CAPACITY_TYPE_STORAGE); + CapacityVO capacity2 = _capacityDao.findByHostIdType(poolId, CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED); Transaction txn = Transaction.currentTxn(); txn.start(); - if ( capacity1 != null ) { - _capacityDao.remove(capacity1.getId()); + try { + if ( capacity1 != null ) { + _capacityDao.remove(capacity1.getId()); + } + if ( capacity2 != null ) { + _capacityDao.remove(capacity2.getId()); + } + } finally { + txn.commit(); } - if ( capacity2 != null ) { - _capacityDao.remove(capacity2.getId()); - } - txn.commit(); return true; - } @Override