From 0ff943337c20e02fd39597a0977cff531a73ecae Mon Sep 17 00:00:00 2001 From: wrodrigues Date: Mon, 10 Feb 2014 15:13:56 +0100 Subject: [PATCH] fixing FindBugs scariest for replaceFirst() method call that does not assign the return value Signed-off-by: Hugo Trippaers --- .../CloudStackPrimaryDataStoreLifeCycleImpl.java | 15 +++++++-------- .../CloudStackPrimaryDataStoreProviderImpl.java | 9 ++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java index 37861b48562..b90d5fc3780 100644 --- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java +++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java @@ -27,8 +27,6 @@ import java.util.UUID; import javax.inject.Inject; -import org.apache.log4j.Logger; - import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; @@ -40,6 +38,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper; +import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; @@ -250,7 +249,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore if (clusterId == null) { throw new IllegalArgumentException("IscsiLUN need to have clusters specified"); } - hostPath.replaceFirst("/", ""); + hostPath = hostPath.replaceFirst("/", ""); parameters.setType(StoragePoolType.IscsiLUN); parameters.setHost(storageHost); parameters.setPort(port); @@ -321,7 +320,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore } else if (scheme.equalsIgnoreCase("PreSetup")) { uuid = hostPath.replace("/", ""); } else { - uuid = UUID.nameUUIDFromBytes(new String(storageHost + hostPath).getBytes()).toString(); + uuid = UUID.nameUUIDFromBytes((storageHost + hostPath).getBytes()).toString(); } List spHandles = primaryDataStoreDao.findIfDuplicatePoolsExistByUUID(uuid); @@ -348,9 +347,9 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore s_logger.debug("creating pool " + pool.getName() + " on host " + hostId); if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem && - pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.VMFS && - pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2 && - pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB) { + pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.VMFS && + pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2 && + pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB) { s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType()); return false; } @@ -377,7 +376,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore PrimaryDataStoreInfo primarystore = (PrimaryDataStoreInfo)store; // Check if there is host up in this cluster List allHosts = - _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, primarystore.getClusterId(), primarystore.getPodId(), primarystore.getDataCenterId()); + _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, primarystore.getClusterId(), primarystore.getPodId(), primarystore.getDataCenterId()); if (allHosts.isEmpty()) { primaryDataStoreDao.expunge(primarystore.getId()); throw new CloudRuntimeException("No host up to associate a storage pool with in cluster " + primarystore.getClusterId()); diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java index 410416c4499..a02e3660830 100644 --- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java +++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java @@ -34,7 +34,6 @@ import com.cloud.utils.component.ComponentContext; public class CloudStackPrimaryDataStoreProviderImpl implements PrimaryDataStoreProvider { - private final String providerName = DataStoreProvider.DEFAULT_PRIMARY; protected PrimaryDataStoreDriver driver; protected HypervisorHostListener listener; protected DataStoreLifeCycle lifecycle; @@ -45,12 +44,12 @@ public class CloudStackPrimaryDataStoreProviderImpl implements PrimaryDataStoreP @Override public String getName() { - return providerName; + return DataStoreProvider.DEFAULT_PRIMARY; } @Override public DataStoreLifeCycle getDataStoreLifeCycle() { - return this.lifecycle; + return lifecycle; } @Override @@ -63,12 +62,12 @@ public class CloudStackPrimaryDataStoreProviderImpl implements PrimaryDataStoreP @Override public PrimaryDataStoreDriver getDataStoreDriver() { - return this.driver; + return driver; } @Override public HypervisorHostListener getHostListener() { - return this.listener; + return listener; } @Override