mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Findbugs fixes in cloud-utils project and a few other places
This commit is contained in:
parent
33d6bc278f
commit
aacf8ef77b
@ -24,7 +24,7 @@ public class NicTO extends NetworkTO {
|
||||
Integer networkRateMulticastMbps;
|
||||
boolean defaultNic;
|
||||
boolean pxeDisable;
|
||||
String uuid;
|
||||
String nicUuid;
|
||||
List<String> nicSecIps;
|
||||
|
||||
public NicTO() {
|
||||
@ -69,12 +69,12 @@ public class NicTO extends NetworkTO {
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
return nicUuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.nicUuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -756,7 +756,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
|
||||
ServiceOffering svo = _entityMgr.findById(ServiceOffering.class, vm.getServiceOfferingId());
|
||||
DiskOffering diskVO = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId());
|
||||
Long clusterId = (storagePool == null ? null : storagePool.getClusterId());
|
||||
Long clusterId = storagePool.getClusterId();
|
||||
|
||||
VolumeInfo vol = null;
|
||||
if (volume.getState() == Volume.State.Allocated) {
|
||||
|
||||
@ -88,8 +88,8 @@ public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> impl
|
||||
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
|
||||
pstmt.setLong(2, usage.getAccountId());
|
||||
pstmt.setLong(3, usage.getId());
|
||||
}
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
|
||||
@ -61,7 +61,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer
|
||||
|
||||
pstmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("DB exception on " + pstmt.toString(), e);
|
||||
throw new CloudRuntimeException("DB exception: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer
|
||||
throw new CloudRuntimeException("Invalid cluster session detected, runId " + runId + " is no longer valid", new ClusterInvalidSessionException("runId " + runId + " is no longer valid"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("DB exception on " + pstmt.toString(), e);
|
||||
throw new CloudRuntimeException("DB exception: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer
|
||||
orphanList.add(rs.getLong(1));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("DB exception on " + pstmt.toString(), e);
|
||||
throw new CloudRuntimeException("DB exception: ", e);
|
||||
}
|
||||
|
||||
return orphanList;
|
||||
|
||||
@ -101,6 +101,11 @@ public class NumbersUtil {
|
||||
* @return interval in ms
|
||||
*/
|
||||
public static long parseInterval(String str, long defaultValue) {
|
||||
try {
|
||||
if (str == null) {
|
||||
throw new ParseException("String is wrong", 0);
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = null;
|
||||
if (str.contains("D")) {
|
||||
sdf = new SimpleDateFormat("dd'D'HH'h'mm'M'ss'S'SSS'ms'");
|
||||
@ -113,12 +118,11 @@ public class NumbersUtil {
|
||||
} else if (str.contains("ms")) {
|
||||
sdf = new SimpleDateFormat("SSS'ms'");
|
||||
}
|
||||
Date date;
|
||||
try {
|
||||
if (str == null || sdf == null) {
|
||||
if (sdf == null) {
|
||||
throw new ParseException("String is wrong", 0);
|
||||
}
|
||||
date = sdf.parse(str);
|
||||
|
||||
Date date = sdf.parse(str);
|
||||
return date.getTime();
|
||||
} catch (ParseException e) {
|
||||
if (defaultValue != -1) {
|
||||
|
||||
@ -100,7 +100,7 @@ public class SwiftUtil {
|
||||
String[] lines = parser.getLines().split("\\n");
|
||||
for (String line : lines) {
|
||||
if (line.contains("Errno") || line.contains("failed") || line.contains("not found")) {
|
||||
throw new CloudRuntimeException("Failed to upload file: " + lines.toString());
|
||||
throw new CloudRuntimeException("Failed to upload file: " + Arrays.toString(lines));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,9 +205,9 @@ public class UriUtils {
|
||||
URI uri = new URI(url);
|
||||
if (uri.getScheme().equalsIgnoreCase("http")) {
|
||||
httpConn = (HttpURLConnection)uri.toURL().openConnection();
|
||||
if (httpConn != null) {
|
||||
httpConn.setConnectTimeout(2000);
|
||||
httpConn.setReadTimeout(5000);
|
||||
if (httpConn != null) {
|
||||
String contentLength = httpConn.getHeaderField("content-length");
|
||||
if (contentLength != null) {
|
||||
remoteSize = Long.parseLong(contentLength);
|
||||
|
||||
@ -1420,10 +1420,10 @@ public class NetUtils {
|
||||
public static boolean isSameIsolationId(String one, String other) {
|
||||
// check nulls
|
||||
// check empty strings
|
||||
if ((one == null || one.equals("")) && (other == null || other.equals(""))) {
|
||||
if ((one == null || one.isEmpty()) && (other == null || other.isEmpty())) {
|
||||
return true;
|
||||
}
|
||||
if ((one == null || other == null) && !(one == null && other == null)) {
|
||||
if (one == null || other == null) {
|
||||
return false;
|
||||
}
|
||||
// check 'untagged'
|
||||
|
||||
@ -69,8 +69,11 @@ public class SSHKeysHelper {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String sumString = toHexString(md5.digest(keyBytes));
|
||||
String rString = "";
|
||||
String sumString = "";
|
||||
if (md5 != null) {
|
||||
sumString = toHexString(md5.digest(keyBytes));
|
||||
}
|
||||
|
||||
for (int i = 2; i <= sumString.length(); i += 2) {
|
||||
rString += sumString.substring(i - 2, i);
|
||||
|
||||
@ -29,6 +29,7 @@ public class DecodedDataObject {
|
||||
public DecodedDataObject(String objType, Long size, String name, String path, DecodedDataStore store) {
|
||||
this.objType = objType;
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user