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