diff --git a/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java b/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java index 6c58b96d33..87ff2b6a08 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java +++ b/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java @@ -88,7 +88,7 @@ public class YamlNode { public String credential_url; public String sudo_password; - public static Function toNode = new Function() { + public static final Function toNode = new Function() { @Override public Node apply(YamlNode arg0) { if (arg0 == null) @@ -106,7 +106,7 @@ public class YamlNode { return toNode.apply(this); } - public static Function inputStreamToYamlNode = new Function() { + public static final Function inputStreamToYamlNode = new Function() { @Override public YamlNode apply(InputStream in) { if (in == null) @@ -125,7 +125,7 @@ public class YamlNode { return inputStreamToYamlNode.apply(in); } - public static Function yamlNodeToInputStream = new Function() { + public static final Function yamlNodeToInputStream = new Function() { @Override public InputStream apply(YamlNode in) { if (in == null) @@ -181,7 +181,7 @@ public class YamlNode { return nodeToYamlNode.apply(in); } - public static Function nodeToYamlNode = new Function() { + public static final Function nodeToYamlNode = new Function() { @Override public YamlNode apply(Node arg0) { if (arg0 == null) diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java index fd3afb1ef9..21dac22c65 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java @@ -72,7 +72,7 @@ public class CreateServerOptions implements MapBinder { } @SuppressWarnings("unused") - private class ServerRequest { + private static class ServerRequest { final String name; final int imageId; final int flavorId; diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java index 53593618a2..8d7c700dd5 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java @@ -130,7 +130,7 @@ public class ServerInfoToNodeMetadata implements Function supportsStaticNAT = Predicates.and(new NetworkServiceNamed("Firewall"), + public static final Predicate supportsStaticNAT = Predicates.and(new NetworkServiceNamed("Firewall"), new CapabilitiesInclude("StaticNat")); - public static Predicate supportsPortForwarding = Predicates.and(new NetworkServiceNamed("Firewall"), + public static final Predicate supportsPortForwarding = Predicates.and(new NetworkServiceNamed("Firewall"), new CapabilitiesInclude("PortForwarding")); - public static Predicate isLoadBalancerService = new NetworkServiceNamed("Lb"); + public static final Predicate isLoadBalancerService = new NetworkServiceNamed("Lb"); - public static Predicate isVirtualNetwork = new GuestIPTypeIs(GuestIPType.VIRTUAL); + public static final Predicate isVirtualNetwork = new GuestIPTypeIs(GuestIPType.VIRTUAL); - public static Predicate isIsolatedNetwork = new GuestIPTypeIs(GuestIPType.ISOLATED); + public static final Predicate isIsolatedNetwork = new GuestIPTypeIs(GuestIPType.ISOLATED); - public static Predicate isSharedNetwork = new GuestIPTypeIs(GuestIPType.SHARED); + public static final Predicate isSharedNetwork = new GuestIPTypeIs(GuestIPType.SHARED); /** * diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java index 6012770b33..8e103d8b8b 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java @@ -121,7 +121,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen this.utils = checkNotNull(utils, "utils"); } - public static Function instanceToRegionAndName = new Function() { + public static final Function instanceToRegionAndName = new Function() { @Override public RegionAndName apply(RunningInstance from) { return new RegionAndName(from.getRegion(), from.getId()); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java index 1707b2197e..d48bd316b9 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java @@ -131,7 +131,7 @@ public class ServerInfoToNodeMetadata implements Function { if (obj == null || getClass() != obj.getClass()) return false; ActionOnResourceRecordSet that = ActionOnResourceRecordSet.class.cast(obj); - return equal(this.action, that.rrs); + return equal(this.action, that.action) && equal(this.rrs, that.rrs); } @Override diff --git a/apis/sts/src/main/java/org/jclouds/aws/domain/Region.java b/apis/sts/src/main/java/org/jclouds/aws/domain/Region.java index 90dfa25ebe..4339fc6d9a 100644 --- a/apis/sts/src/main/java/org/jclouds/aws/domain/Region.java +++ b/apis/sts/src/main/java/org/jclouds/aws/domain/Region.java @@ -109,10 +109,10 @@ public class Region { */ public static final String AP_NORTHEAST_1 = "ap-northeast-1"; - public static Set DEFAULT_S3 = ImmutableSet.of(US_STANDARD, US_WEST_1, US_WEST_2, EU_WEST_1, SA_EAST_1, + public static final Set DEFAULT_S3 = ImmutableSet.of(US_STANDARD, US_WEST_1, US_WEST_2, EU_WEST_1, SA_EAST_1, AP_SOUTHEAST_1, AP_SOUTHEAST_2, AP_NORTHEAST_1); - public static Set DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, US_WEST_2, SA_EAST_1, EU_WEST_1, + public static final Set DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, US_WEST_2, SA_EAST_1, EU_WEST_1, AP_SOUTHEAST_1, AP_SOUTHEAST_2, AP_NORTHEAST_1); public static Properties regionPropertiesS3() { diff --git a/apis/sts/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java b/apis/sts/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java index 94027ce126..221cbfdce9 100644 --- a/apis/sts/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java +++ b/apis/sts/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java @@ -108,7 +108,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler { else if (errorCode != null && (errorCode.indexOf("NotFound") != -1 || errorCode.endsWith(".Unknown"))) exception = new ResourceNotFoundException(message, exception); else if ("IncorrectState".equals(errorCode) - || (errorCode != null && (error.getCode().endsWith(".Duplicate") | error.getCode().endsWith( + || (errorCode != null && (error.getCode().endsWith(".Duplicate") || error.getCode().endsWith( ".InUse"))) || (message != null && (message.indexOf("already exists") != -1 || message.indexOf("is in use") != -1))) exception = new IllegalStateException(message, exception); diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java index 37299a4430..5cf75be0e8 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java @@ -238,7 +238,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra }); } - class Part { + static class Part { private int part; private long offset; private long size; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java index 1d3b25985e..c837c7c2f8 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java @@ -138,7 +138,7 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA ensureVmHasAllocationModeOrPooled(vAppResponse, vOptions.getIpAddressAllocationMode()); - int cpuCount = new Double(getCores(template.getHardware())).intValue(); + int cpuCount = (int) getCores(template.getHardware()); logger.trace(">> updating cpuCount(%d) vm(%s)", cpuCount, vm.getName()); waitForTask(updateCPUCountOfVm(vm, cpuCount)); logger.trace("<< updated cpuCount vm(%s)", vm.getName()); diff --git a/compute/src/main/java/org/jclouds/cim/functions/HardwareBuilderFromResourceAllocations.java b/compute/src/main/java/org/jclouds/cim/functions/HardwareBuilderFromResourceAllocations.java index 2d123eb23f..711ba38236 100644 --- a/compute/src/main/java/org/jclouds/cim/functions/HardwareBuilderFromResourceAllocations.java +++ b/compute/src/main/java/org/jclouds/cim/functions/HardwareBuilderFromResourceAllocations.java @@ -69,7 +69,7 @@ public class HardwareBuilderFromResourceAllocations implements public Volume apply(ResourceAllocationSettingData from) { return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null - : from.getVirtualQuantity() / 1024 / 1024f, null, "0".equals(from.getAddressOnParent()) + : from.getVirtualQuantity() / (float) (1024 * 1024), null, "0".equals(from.getAddressOnParent()) || ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true); } } diff --git a/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java b/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java index d009a89b4d..b16519980b 100644 --- a/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java +++ b/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java @@ -98,8 +98,6 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable { to.nameTask(this.getTaskName()); } - public static final TemplateOptions NONE = new ImmutableTemplateOptions(new TemplateOptions()); - public static class ImmutableTemplateOptions extends TemplateOptions { private final TemplateOptions delegate; @@ -316,6 +314,8 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable { } private static final Set DEFAULT_INBOUND_PORTS = ImmutableSet.of(22); + + public static final TemplateOptions NONE = new ImmutableTemplateOptions(new TemplateOptions()); protected Set inboundPorts = DEFAULT_INBOUND_PORTS; diff --git a/compute/src/main/java/org/jclouds/compute/predicates/OperatingSystemPredicates.java b/compute/src/main/java/org/jclouds/compute/predicates/OperatingSystemPredicates.java index c66b9f90ea..8bb0cbaae1 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/OperatingSystemPredicates.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/OperatingSystemPredicates.java @@ -78,8 +78,8 @@ public class OperatingSystemPredicates { } } for (String toMatch : searchStrings(os)) - if (toMatch != null && toMatch.toLowerCase().indexOf("ubuntu") != -1 - || toMatch.toLowerCase().indexOf("debian") != -1) + if (toMatch != null && (toMatch.toLowerCase().indexOf("ubuntu") != -1 + || toMatch.toLowerCase().indexOf("debian") != -1)) return true; return false; } diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java index 50375c2ceb..a7c427a741 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java @@ -126,8 +126,12 @@ public class ComputeServiceUtils { public static double getSpace(Hardware input) { double total = 0; - for (Volume volume : input.getVolumes()) - total += volume.getSize() != null ? volume.getSize() : 0; + for (Volume volume : input.getVolumes()) { + Float size = volume.getSize(); + if (size != null) { + total += size; + } + } return total; } diff --git a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java index 5b2565822d..b3a1eeaaab 100644 --- a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java +++ b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java @@ -76,7 +76,7 @@ import com.jcraft.jsch.Session; */ public class JschSshClient implements SshClient { - private final class CloseFtpChannelOnCloseInputStream extends FilterInputStream { + private static final class CloseFtpChannelOnCloseInputStream extends FilterInputStream { private final ChannelSftp sftp; diff --git a/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java b/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java index 81eedd1d90..f729be6a75 100644 --- a/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java +++ b/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java @@ -87,7 +87,7 @@ import com.google.inject.Inject; @SuppressWarnings("unchecked") public class SshjSshClient implements SshClient { - private final class CloseFtpChannelOnCloseInputStream extends FilterInputStream { + private static final class CloseFtpChannelOnCloseInputStream extends FilterInputStream { private final SFTPClient sftp; diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java index 8ecfc43637..c5338d2bd3 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java @@ -90,6 +90,6 @@ public class VirtualMachineTemplateInVirtualDatacenterToHardware implements } private static float toGb(final long bytes) { - return bytes / 1024 / 1024 / (float) 1024; + return bytes / (float) (1024 * 1024 * 1024); } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java index 0abdebe5cf..697ed62089 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java @@ -538,7 +538,7 @@ public class ManagedRack extends DomainWrapper { return this; } - public Builder VlansIdAvoided(final String vlansIdAvoided) { + public Builder vlansIdAvoided(final String vlansIdAvoided) { this.vlansIdAvoided = vlansIdAvoided; return this; } @@ -576,7 +576,7 @@ public class ManagedRack extends DomainWrapper { return ManagedRack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName()) .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq()) .vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin()) - .vlanPerVdcReserved(in.getVlanPerVdcReserved()).VlansIdAvoided(in.getVlansIdAvoided()) + .vlanPerVdcReserved(in.getVlanPerVdcReserved()).vlansIdAvoided(in.getVlansIdAvoided()) .port(in.getPort()).ipAddress(in.getIp()).password(in.getPassword()).user(in.getUser()) .defaultTemplate(in.getDefaultTemplate()).maxMachinesOn(in.getMaxMachinesOn()); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java index 25a1c48368..e824f0360d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java @@ -262,7 +262,7 @@ public class Rack extends DomainWrapper { return this; } - public Builder VlansIdAvoided(final String vlansIdAvoided) { + public Builder vlansIdAvoided(final String vlansIdAvoided) { this.vlansIdAvoided = vlansIdAvoided; return this; } @@ -293,7 +293,7 @@ public class Rack extends DomainWrapper { return Rack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName()) .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq()) .vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin()) - .vlanPerVdcReserved(in.getVlanPerVdcReserved()).VlansIdAvoided(in.getVlansIdAvoided()); + .vlanPerVdcReserved(in.getVlanPerVdcReserved()).vlansIdAvoided(in.getVlansIdAvoided()); } } diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java index 321d36477c..9e932d5a1c 100644 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java +++ b/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java @@ -85,7 +85,7 @@ public class KeyStoreSupplier implements Supplier { int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); - String pemCerts = ""; + StringBuilder pemCerts = new StringBuilder(); int certsBeginIdx = 0; do { @@ -93,7 +93,7 @@ public class KeyStoreSupplier implements Supplier { if (certsBeginIdx >= 0) { int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; - pemCerts += cert.substring(certsBeginIdx, certsEndIdx); + pemCerts.append(cert.substring(certsBeginIdx, certsEndIdx)); certsBeginIdx = certsEndIdx; } } while (certsBeginIdx != -1); @@ -106,7 +106,7 @@ public class KeyStoreSupplier implements Supplier { CertificateFactory cf = CertificateFactory.getInstance("X.509"); @SuppressWarnings("unchecked") Collection certs = (Collection) cf.generateCertificates(new ByteArrayInputStream( - pemCerts.getBytes(Charsets.UTF_8))); + pemCerts.toString().getBytes(Charsets.UTF_8))); keyStore.load(null); keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(), certs.toArray(new java.security.cert.Certificate[0])); diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/CDMIObject.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/CDMIObject.java index 4ec9d702ce..d422e28d0d 100644 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/CDMIObject.java +++ b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/CDMIObject.java @@ -206,7 +206,7 @@ public class CDMIObject { for (String s : cdmi_acl_member) { String cdmi_acl_key = s.substring(0, s.indexOf(":")); String cdmi_acl_value = s.substring(s.indexOf(":") + 1); - cdmi_acl_value.replace('"', ' ').trim(); + cdmi_acl_value = cdmi_acl_value.replace('"', ' ').trim(); aclMap.put(cdmi_acl_key, cdmi_acl_value); } aclMetaDataIn.add(aclMap); diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/DataObject.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/DataObject.java index 855e500aaa..bb98edbd70 100644 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/DataObject.java +++ b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/DataObject.java @@ -49,8 +49,8 @@ public class DataObject extends CDMIObject { } public static class Builder> extends CDMIObject.Builder { - private String mimetype = new String(); - private String value = new String(); + private String mimetype = ""; + private String value = ""; /** * @see DataObject#getMimetype() diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectOptions.java index 3461db7a01..a3f39673b0 100644 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectOptions.java +++ b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectOptions.java @@ -22,7 +22,7 @@ import com.google.common.io.Files; public class CreateDataObjectOptions extends CreateCDMIObjectOptions { public CreateDataObjectOptions() { - jsonObjectBody.addProperty("value", new String()); + jsonObjectBody.addProperty("value", ""); } /** @@ -66,7 +66,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions { * @return CreateDataObjectOptions */ public CreateDataObjectOptions value(String value) { - jsonObjectBody.addProperty("value", (value == null) ? new String() : value); + jsonObjectBody.addProperty("value", (value == null) ? "" : value); this.payload = jsonObjectBody.toString(); return this; } @@ -79,7 +79,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions { * @return CreateDataObjectOptions */ public CreateDataObjectOptions value(byte[] value) throws IOException { - jsonObjectBody.addProperty("value", (value == null) ? new String() : new DataInputStream( + jsonObjectBody.addProperty("value", (value == null) ? "" : new DataInputStream( new ByteArrayInputStream(value)).readUTF()); this.payload = jsonObjectBody.toString(); return this; @@ -93,7 +93,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions { * @return CreateDataObjectOptions */ public CreateDataObjectOptions value(File value) throws IOException { - jsonObjectBody.addProperty("value", (value == null) ? new String() : Files.toString(value, Charsets.UTF_8)); + jsonObjectBody.addProperty("value", (value == null) ? "" : Files.toString(value, Charsets.UTF_8)); this.payload = jsonObjectBody.toString(); return this; } @@ -108,7 +108,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions { * @return CreateDataObjectOptions */ public CreateDataObjectOptions value(File value, Charset charset) throws IOException { - jsonObjectBody.addProperty("value", (value == null) ? new String() : Files.toString(value, charset)); + jsonObjectBody.addProperty("value", (value == null) ? "" : Files.toString(value, charset)); this.payload = jsonObjectBody.toString(); return this; } @@ -122,7 +122,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions { */ public CreateDataObjectOptions value(InputStream value) throws IOException { jsonObjectBody.addProperty("value", - (value == null) ? new String() : CharStreams.toString(new InputStreamReader(value, Charsets.UTF_8))); + (value == null) ? "" : CharStreams.toString(new InputStreamReader(value, Charsets.UTF_8))); this.payload = jsonObjectBody.toString(); return this; } @@ -139,7 +139,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions { */ public CreateDataObjectOptions value(InputStream value, Charset charset) throws IOException { jsonObjectBody.addProperty("value", - (value == null) ? new String() : CharStreams.toString(new InputStreamReader(value, charset))); + (value == null) ? "" : CharStreams.toString(new InputStreamReader(value, charset))); this.payload = jsonObjectBody.toString(); return this; } diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java index d80e719b6e..7b760e0d40 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java @@ -69,7 +69,7 @@ public class HardwareBuilderFromResourceAllocations implements public Volume apply(ResourceAllocationSettingData from) { return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null - : from.getVirtualQuantity().longValue() / 1024 / 1024f, null, "0".equals(from.getAddressOnParent()) + : from.getVirtualQuantity().longValue() / (float) (1024 * 1024), null, "0".equals(from.getAddressOnParent()) || ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true); } } diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/KeyStoreSupplier.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/KeyStoreSupplier.java index b5eac29852..709589d9a0 100644 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/KeyStoreSupplier.java +++ b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/KeyStoreSupplier.java @@ -85,7 +85,7 @@ public class KeyStoreSupplier implements Supplier { int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); - String pemCerts = ""; + StringBuilder pemCerts = new StringBuilder(); int certsBeginIdx = 0; do { @@ -93,7 +93,7 @@ public class KeyStoreSupplier implements Supplier { if (certsBeginIdx >= 0) { int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; - pemCerts += cert.substring(certsBeginIdx, certsEndIdx); + pemCerts.append(cert.substring(certsBeginIdx, certsEndIdx)); certsBeginIdx = certsEndIdx; } } while (certsBeginIdx != -1); @@ -106,7 +106,7 @@ public class KeyStoreSupplier implements Supplier { CertificateFactory cf = CertificateFactory.getInstance("X.509"); @SuppressWarnings("unchecked") Collection certs = (Collection) cf.generateCertificates(new ByteArrayInputStream( - pemCerts.getBytes(Charsets.UTF_8))); + pemCerts.toString().getBytes(Charsets.UTF_8))); keyStore.load(null); keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(), certs.toArray(new java.security.cert.Certificate[0])); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/compute/util/VCloudDirectorComputeUtils.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/compute/util/VCloudDirectorComputeUtils.java index c70942bf38..8505e0f873 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/compute/util/VCloudDirectorComputeUtils.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/compute/util/VCloudDirectorComputeUtils.java @@ -81,7 +81,7 @@ public class VCloudDirectorComputeUtils { public static String getVirtualSystemIdentifierOf(Vm vm) { VirtualHardwareSection virtualHardwareSection = findVirtualHardwareSectionForVApp.apply(vm); - if (virtualHardwareSection != null && virtualHardwareSection != null) + if (virtualHardwareSection != null && virtualHardwareSection.getSystem() != null) return virtualHardwareSection.getSystem().getVirtualSystemIdentifier(); return null; } diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/StorageController.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/StorageController.java index 941c3031c9..ff5faf2bcd 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/StorageController.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/StorageController.java @@ -143,7 +143,7 @@ public class StorageController { } } - private class HardDiskPredicate implements Predicate { + private static class HardDiskPredicate implements Predicate { private String diskName; diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/YamlImage.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/YamlImage.java index a881cea9fb..b1178852e1 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/YamlImage.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/YamlImage.java @@ -133,7 +133,7 @@ public class YamlImage { public String credential_url; public String sudo_password; - public static Function toImage = new Function() { + public static final Function toImage = new Function() { @Override public Image apply(YamlImage arg0) { if (arg0 == null) diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IpAddressesLoadingCache.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IpAddressesLoadingCache.java index f56fd57e0d..4686aa8002 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IpAddressesLoadingCache.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IpAddressesLoadingCache.java @@ -81,7 +81,7 @@ public class IpAddressesLoadingCache extends @Override public String getIfPresent(Object key) { - return masters.get((String) key); + return masters.get((MachineNameOrIdAndNicSlot) key); } @Override diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/admin/UnregisterMachineIfExistsAndDeleteItsMedia.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/admin/UnregisterMachineIfExistsAndDeleteItsMedia.java index 701439990b..8fb2a9cfa8 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/admin/UnregisterMachineIfExistsAndDeleteItsMedia.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/admin/UnregisterMachineIfExistsAndDeleteItsMedia.java @@ -109,7 +109,7 @@ public class UnregisterMachineIfExistsAndDeleteItsMedia implements Function { + private static class AutoDeleteHardDiskPredicate implements Predicate { private VmSpec vmSpec; @@ -128,7 +128,7 @@ public class UnregisterMachineIfExistsAndDeleteItsMedia implements Function { + private static class DeleteChildrenOfMedium implements Function { @Override public IMedium apply(IMedium medium) { checkNotNull(medium.getChildren()); diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java index b3181a75e6..3cb76bdb7e 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java @@ -251,7 +251,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra }); } - class Part { + static class Part { private int part; private long offset; private long size;