Skip to content

Commit 0ff9433

Browse files
wilderrodriguesspark404
authored andcommitted
fixing FindBugs scariest for replaceFirst() method call that does not assign the return value
Signed-off-by: Hugo Trippaers <htrippaers@schubergphilis.com>
1 parent 16aa73c commit 0ff9433

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
import javax.inject.Inject;
2929

30-
import org.apache.log4j.Logger;
31-
3230
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
3331
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
3432
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@@ -40,6 +38,7 @@
4038
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
4139
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
4240
import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
41+
import org.apache.log4j.Logger;
4342

4443
import com.cloud.agent.AgentManager;
4544
import com.cloud.agent.api.Answer;
@@ -250,7 +249,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
250249
if (clusterId == null) {
251250
throw new IllegalArgumentException("IscsiLUN need to have clusters specified");
252251
}
253-
hostPath.replaceFirst("/", "");
252+
hostPath = hostPath.replaceFirst("/", "");
254253
parameters.setType(StoragePoolType.IscsiLUN);
255254
parameters.setHost(storageHost);
256255
parameters.setPort(port);
@@ -321,7 +320,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
321320
} else if (scheme.equalsIgnoreCase("PreSetup")) {
322321
uuid = hostPath.replace("/", "");
323322
} else {
324-
uuid = UUID.nameUUIDFromBytes(new String(storageHost + hostPath).getBytes()).toString();
323+
uuid = UUID.nameUUIDFromBytes((storageHost + hostPath).getBytes()).toString();
325324
}
326325

327326
List<StoragePoolVO> spHandles = primaryDataStoreDao.findIfDuplicatePoolsExistByUUID(uuid);
@@ -348,9 +347,9 @@ protected boolean createStoragePool(long hostId, StoragePool pool) {
348347
s_logger.debug("creating pool " + pool.getName() + " on host " + hostId);
349348

350349
if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem &&
351-
pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.VMFS &&
352-
pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2 &&
353-
pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB) {
350+
pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.VMFS &&
351+
pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2 &&
352+
pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB) {
354353
s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType());
355354
return false;
356355
}
@@ -377,7 +376,7 @@ public boolean attachCluster(DataStore store, ClusterScope scope) {
377376
PrimaryDataStoreInfo primarystore = (PrimaryDataStoreInfo)store;
378377
// Check if there is host up in this cluster
379378
List<HostVO> allHosts =
380-
_resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, primarystore.getClusterId(), primarystore.getPodId(), primarystore.getDataCenterId());
379+
_resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, primarystore.getClusterId(), primarystore.getPodId(), primarystore.getDataCenterId());
381380
if (allHosts.isEmpty()) {
382381
primaryDataStoreDao.expunge(primarystore.getId());
383382
throw new CloudRuntimeException("No host up to associate a storage pool with in cluster " + primarystore.getClusterId());

plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
public class CloudStackPrimaryDataStoreProviderImpl implements PrimaryDataStoreProvider {
3636

37-
private final String providerName = DataStoreProvider.DEFAULT_PRIMARY;
3837
protected PrimaryDataStoreDriver driver;
3938
protected HypervisorHostListener listener;
4039
protected DataStoreLifeCycle lifecycle;
@@ -45,12 +44,12 @@ public class CloudStackPrimaryDataStoreProviderImpl implements PrimaryDataStoreP
4544

4645
@Override
4746
public String getName() {
48-
return providerName;
47+
return DataStoreProvider.DEFAULT_PRIMARY;
4948
}
5049

5150
@Override
5251
public DataStoreLifeCycle getDataStoreLifeCycle() {
53-
return this.lifecycle;
52+
return lifecycle;
5453
}
5554

5655
@Override
@@ -63,12 +62,12 @@ public boolean configure(Map<String, Object> params) {
6362

6463
@Override
6564
public PrimaryDataStoreDriver getDataStoreDriver() {
66-
return this.driver;
65+
return driver;
6766
}
6867

6968
@Override
7069
public HypervisorHostListener getHostListener() {
71-
return this.listener;
70+
return listener;
7271
}
7372

7473
@Override

0 commit comments

Comments
 (0)