Address FindBugs errors

This commit is contained in:
Andrew Gaul 2013-02-22 20:05:22 -08:00
parent dc4dbd68bf
commit 1f995879d6
33 changed files with 63 additions and 59 deletions

View File

@ -88,7 +88,7 @@ public class YamlNode {
public String credential_url; public String credential_url;
public String sudo_password; public String sudo_password;
public static Function<YamlNode, Node> toNode = new Function<YamlNode, Node>() { public static final Function<YamlNode, Node> toNode = new Function<YamlNode, Node>() {
@Override @Override
public Node apply(YamlNode arg0) { public Node apply(YamlNode arg0) {
if (arg0 == null) if (arg0 == null)
@ -106,7 +106,7 @@ public class YamlNode {
return toNode.apply(this); return toNode.apply(this);
} }
public static Function<InputStream, YamlNode> inputStreamToYamlNode = new Function<InputStream, YamlNode>() { public static final Function<InputStream, YamlNode> inputStreamToYamlNode = new Function<InputStream, YamlNode>() {
@Override @Override
public YamlNode apply(InputStream in) { public YamlNode apply(InputStream in) {
if (in == null) if (in == null)
@ -125,7 +125,7 @@ public class YamlNode {
return inputStreamToYamlNode.apply(in); return inputStreamToYamlNode.apply(in);
} }
public static Function<YamlNode, InputStream> yamlNodeToInputStream = new Function<YamlNode, InputStream>() { public static final Function<YamlNode, InputStream> yamlNodeToInputStream = new Function<YamlNode, InputStream>() {
@Override @Override
public InputStream apply(YamlNode in) { public InputStream apply(YamlNode in) {
if (in == null) if (in == null)
@ -181,7 +181,7 @@ public class YamlNode {
return nodeToYamlNode.apply(in); return nodeToYamlNode.apply(in);
} }
public static Function<Node, YamlNode> nodeToYamlNode = new Function<Node, YamlNode>() { public static final Function<Node, YamlNode> nodeToYamlNode = new Function<Node, YamlNode>() {
@Override @Override
public YamlNode apply(Node arg0) { public YamlNode apply(Node arg0) {
if (arg0 == null) if (arg0 == null)

View File

@ -72,7 +72,7 @@ public class CreateServerOptions implements MapBinder {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
private class ServerRequest { private static class ServerRequest {
final String name; final String name;
final int imageId; final int imageId;
final int flavorId; final int flavorId;

View File

@ -130,7 +130,7 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
builder.id(input.getId()); builder.id(input.getId());
try { try {
DriveInfo drive = cache.getUnchecked(input.getDriveUuid()); DriveInfo drive = cache.getUnchecked(input.getDriveUuid());
builder.size(drive.getSize() / 1024 / 1024f); builder.size((float) drive.getSize());
} catch (NullPointerException e) { } catch (NullPointerException e) {
logger.debug("drive %s not found", input.getDriveUuid()); logger.debug("drive %s not found", input.getDriveUuid());
} catch (UncheckedExecutionException e) { } catch (UncheckedExecutionException e) {

View File

@ -138,7 +138,7 @@ public class CloudStackComputeServiceAdapter implements
try { try {
zone = zoneIdToZone.get().get(zoneId); zone = zoneIdToZone.get().get(zoneId);
} catch (ExecutionException e) { } catch (ExecutionException e) {
Throwables.propagate(e); throw Throwables.propagate(e);
} }
CloudStackTemplateOptions templateOptions = template.getOptions().as(CloudStackTemplateOptions.class); CloudStackTemplateOptions templateOptions = template.getOptions().as(CloudStackTemplateOptions.class);

View File

@ -189,19 +189,19 @@ public class NetworkPredicates {
} }
} }
public static Predicate<NetworkService> supportsStaticNAT = Predicates.and(new NetworkServiceNamed("Firewall"), public static final Predicate<NetworkService> supportsStaticNAT = Predicates.and(new NetworkServiceNamed("Firewall"),
new CapabilitiesInclude("StaticNat")); new CapabilitiesInclude("StaticNat"));
public static Predicate<NetworkService> supportsPortForwarding = Predicates.and(new NetworkServiceNamed("Firewall"), public static final Predicate<NetworkService> supportsPortForwarding = Predicates.and(new NetworkServiceNamed("Firewall"),
new CapabilitiesInclude("PortForwarding")); new CapabilitiesInclude("PortForwarding"));
public static Predicate<NetworkService> isLoadBalancerService = new NetworkServiceNamed("Lb"); public static final Predicate<NetworkService> isLoadBalancerService = new NetworkServiceNamed("Lb");
public static Predicate<GuestIPType> isVirtualNetwork = new GuestIPTypeIs(GuestIPType.VIRTUAL); public static final Predicate<GuestIPType> isVirtualNetwork = new GuestIPTypeIs(GuestIPType.VIRTUAL);
public static Predicate<GuestIPType> isIsolatedNetwork = new GuestIPTypeIs(GuestIPType.ISOLATED); public static final Predicate<GuestIPType> isIsolatedNetwork = new GuestIPTypeIs(GuestIPType.ISOLATED);
public static Predicate<GuestIPType> isSharedNetwork = new GuestIPTypeIs(GuestIPType.SHARED); public static final Predicate<GuestIPType> isSharedNetwork = new GuestIPTypeIs(GuestIPType.SHARED);
/** /**
* *

View File

@ -121,7 +121,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen
this.utils = checkNotNull(utils, "utils"); this.utils = checkNotNull(utils, "utils");
} }
public static Function<RunningInstance, RegionAndName> instanceToRegionAndName = new Function<RunningInstance, RegionAndName>() { public static final Function<RunningInstance, RegionAndName> instanceToRegionAndName = new Function<RunningInstance, RegionAndName>() {
@Override @Override
public RegionAndName apply(RunningInstance from) { public RegionAndName apply(RunningInstance from) {
return new RegionAndName(from.getRegion(), from.getId()); return new RegionAndName(from.getRegion(), from.getId());

View File

@ -131,7 +131,7 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
builder.id(input.getId()); builder.id(input.getId());
try { try {
DriveInfo drive = cache.getUnchecked(input.getDriveUuid()); DriveInfo drive = cache.getUnchecked(input.getDriveUuid());
builder.size(drive.getSize() / 1024 / 1024f); builder.size(drive.getSize() / (float) (1024 * 1024));
} catch (NullPointerException e) { } catch (NullPointerException e) {
logger.debug("drive %s not found", input.getDriveUuid()); logger.debug("drive %s not found", input.getDriveUuid());
} catch (UncheckedExecutionException e) { } catch (UncheckedExecutionException e) {

View File

@ -82,7 +82,7 @@ public class ChangeBatch extends ForwardingList<ActionOnResourceRecordSet> {
if (obj == null || getClass() != obj.getClass()) if (obj == null || getClass() != obj.getClass())
return false; return false;
ActionOnResourceRecordSet that = ActionOnResourceRecordSet.class.cast(obj); ActionOnResourceRecordSet that = ActionOnResourceRecordSet.class.cast(obj);
return equal(this.action, that.rrs); return equal(this.action, that.action) && equal(this.rrs, that.rrs);
} }
@Override @Override

View File

@ -109,10 +109,10 @@ public class Region {
*/ */
public static final String AP_NORTHEAST_1 = "ap-northeast-1"; public static final String AP_NORTHEAST_1 = "ap-northeast-1";
public static Set<String> DEFAULT_S3 = ImmutableSet.of(US_STANDARD, US_WEST_1, US_WEST_2, EU_WEST_1, SA_EAST_1, public static final Set<String> 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); AP_SOUTHEAST_1, AP_SOUTHEAST_2, AP_NORTHEAST_1);
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, US_WEST_2, SA_EAST_1, EU_WEST_1, public static final Set<String> 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); AP_SOUTHEAST_1, AP_SOUTHEAST_2, AP_NORTHEAST_1);
public static Properties regionPropertiesS3() { public static Properties regionPropertiesS3() {

View File

@ -108,7 +108,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
else if (errorCode != null && (errorCode.indexOf("NotFound") != -1 || errorCode.endsWith(".Unknown"))) else if (errorCode != null && (errorCode.indexOf("NotFound") != -1 || errorCode.endsWith(".Unknown")))
exception = new ResourceNotFoundException(message, exception); exception = new ResourceNotFoundException(message, exception);
else if ("IncorrectState".equals(errorCode) else if ("IncorrectState".equals(errorCode)
|| (errorCode != null && (error.getCode().endsWith(".Duplicate") | error.getCode().endsWith( || (errorCode != null && (error.getCode().endsWith(".Duplicate") || error.getCode().endsWith(
".InUse"))) ".InUse")))
|| (message != null && (message.indexOf("already exists") != -1 || message.indexOf("is in use") != -1))) || (message != null && (message.indexOf("already exists") != -1 || message.indexOf("is in use") != -1)))
exception = new IllegalStateException(message, exception); exception = new IllegalStateException(message, exception);

View File

@ -238,7 +238,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra
}); });
} }
class Part { static class Part {
private int part; private int part;
private long offset; private long offset;
private long size; private long size;

View File

@ -138,7 +138,7 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
ensureVmHasAllocationModeOrPooled(vAppResponse, vOptions.getIpAddressAllocationMode()); 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()); logger.trace(">> updating cpuCount(%d) vm(%s)", cpuCount, vm.getName());
waitForTask(updateCPUCountOfVm(vm, cpuCount)); waitForTask(updateCPUCountOfVm(vm, cpuCount));
logger.trace("<< updated cpuCount vm(%s)", vm.getName()); logger.trace("<< updated cpuCount vm(%s)", vm.getName());

View File

@ -69,7 +69,7 @@ public class HardwareBuilderFromResourceAllocations implements
public Volume apply(ResourceAllocationSettingData from) { public Volume apply(ResourceAllocationSettingData from) {
return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null 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); || ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true);
} }
} }

View File

@ -98,8 +98,6 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
to.nameTask(this.getTaskName()); to.nameTask(this.getTaskName());
} }
public static final TemplateOptions NONE = new ImmutableTemplateOptions(new TemplateOptions());
public static class ImmutableTemplateOptions extends TemplateOptions { public static class ImmutableTemplateOptions extends TemplateOptions {
private final TemplateOptions delegate; private final TemplateOptions delegate;
@ -316,6 +314,8 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
private static final Set<Integer> DEFAULT_INBOUND_PORTS = ImmutableSet.of(22); private static final Set<Integer> DEFAULT_INBOUND_PORTS = ImmutableSet.of(22);
public static final TemplateOptions NONE = new ImmutableTemplateOptions(new TemplateOptions());
protected Set<Integer> inboundPorts = DEFAULT_INBOUND_PORTS; protected Set<Integer> inboundPorts = DEFAULT_INBOUND_PORTS;

View File

@ -78,8 +78,8 @@ public class OperatingSystemPredicates {
} }
} }
for (String toMatch : searchStrings(os)) for (String toMatch : searchStrings(os))
if (toMatch != null && toMatch.toLowerCase().indexOf("ubuntu") != -1 if (toMatch != null && (toMatch.toLowerCase().indexOf("ubuntu") != -1
|| toMatch.toLowerCase().indexOf("debian") != -1) || toMatch.toLowerCase().indexOf("debian") != -1))
return true; return true;
return false; return false;
} }

View File

@ -126,8 +126,12 @@ public class ComputeServiceUtils {
public static double getSpace(Hardware input) { public static double getSpace(Hardware input) {
double total = 0; double total = 0;
for (Volume volume : input.getVolumes()) for (Volume volume : input.getVolumes()) {
total += volume.getSize() != null ? volume.getSize() : 0; Float size = volume.getSize();
if (size != null) {
total += size;
}
}
return total; return total;
} }

View File

@ -76,7 +76,7 @@ import com.jcraft.jsch.Session;
*/ */
public class JschSshClient implements SshClient { public class JschSshClient implements SshClient {
private final class CloseFtpChannelOnCloseInputStream extends FilterInputStream { private static final class CloseFtpChannelOnCloseInputStream extends FilterInputStream {
private final ChannelSftp sftp; private final ChannelSftp sftp;

View File

@ -87,7 +87,7 @@ import com.google.inject.Inject;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class SshjSshClient implements SshClient { public class SshjSshClient implements SshClient {
private final class CloseFtpChannelOnCloseInputStream extends FilterInputStream { private static final class CloseFtpChannelOnCloseInputStream extends FilterInputStream {
private final SFTPClient sftp; private final SFTPClient sftp;

View File

@ -90,6 +90,6 @@ public class VirtualMachineTemplateInVirtualDatacenterToHardware implements
} }
private static float toGb(final long bytes) { private static float toGb(final long bytes) {
return bytes / 1024 / 1024 / (float) 1024; return bytes / (float) (1024 * 1024 * 1024);
} }
} }

View File

@ -538,7 +538,7 @@ public class ManagedRack extends DomainWrapper<UcsRackDto> {
return this; return this;
} }
public Builder VlansIdAvoided(final String vlansIdAvoided) { public Builder vlansIdAvoided(final String vlansIdAvoided) {
this.vlansIdAvoided = vlansIdAvoided; this.vlansIdAvoided = vlansIdAvoided;
return this; return this;
} }
@ -576,7 +576,7 @@ public class ManagedRack extends DomainWrapper<UcsRackDto> {
return ManagedRack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName()) return ManagedRack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName())
.shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq()) .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq())
.vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin()) .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()) .port(in.getPort()).ipAddress(in.getIp()).password(in.getPassword()).user(in.getUser())
.defaultTemplate(in.getDefaultTemplate()).maxMachinesOn(in.getMaxMachinesOn()); .defaultTemplate(in.getDefaultTemplate()).maxMachinesOn(in.getMaxMachinesOn());
} }

View File

@ -262,7 +262,7 @@ public class Rack extends DomainWrapper<RackDto> {
return this; return this;
} }
public Builder VlansIdAvoided(final String vlansIdAvoided) { public Builder vlansIdAvoided(final String vlansIdAvoided) {
this.vlansIdAvoided = vlansIdAvoided; this.vlansIdAvoided = vlansIdAvoided;
return this; return this;
} }
@ -293,7 +293,7 @@ public class Rack extends DomainWrapper<RackDto> {
return Rack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName()) return Rack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName())
.shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq()) .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq())
.vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin()) .vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin())
.vlanPerVdcReserved(in.getVlanPerVdcReserved()).VlansIdAvoided(in.getVlansIdAvoided()); .vlanPerVdcReserved(in.getVlanPerVdcReserved()).vlansIdAvoided(in.getVlansIdAvoided());
} }
} }

View File

@ -85,7 +85,7 @@ public class KeyStoreSupplier implements Supplier<KeyStore> {
int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY");
String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26);
String pemCerts = ""; StringBuilder pemCerts = new StringBuilder();
int certsBeginIdx = 0; int certsBeginIdx = 0;
do { do {
@ -93,7 +93,7 @@ public class KeyStoreSupplier implements Supplier<KeyStore> {
if (certsBeginIdx >= 0) { if (certsBeginIdx >= 0) {
int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26;
pemCerts += cert.substring(certsBeginIdx, certsEndIdx); pemCerts.append(cert.substring(certsBeginIdx, certsEndIdx));
certsBeginIdx = certsEndIdx; certsBeginIdx = certsEndIdx;
} }
} while (certsBeginIdx != -1); } while (certsBeginIdx != -1);
@ -106,7 +106,7 @@ public class KeyStoreSupplier implements Supplier<KeyStore> {
CertificateFactory cf = CertificateFactory.getInstance("X.509"); CertificateFactory cf = CertificateFactory.getInstance("X.509");
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<Certificate> certs = (Collection<Certificate>) cf.generateCertificates(new ByteArrayInputStream( Collection<Certificate> certs = (Collection<Certificate>) cf.generateCertificates(new ByteArrayInputStream(
pemCerts.getBytes(Charsets.UTF_8))); pemCerts.toString().getBytes(Charsets.UTF_8)));
keyStore.load(null); keyStore.load(null);
keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(), keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(),
certs.toArray(new java.security.cert.Certificate[0])); certs.toArray(new java.security.cert.Certificate[0]));

View File

@ -206,7 +206,7 @@ public class CDMIObject {
for (String s : cdmi_acl_member) { for (String s : cdmi_acl_member) {
String cdmi_acl_key = s.substring(0, s.indexOf(":")); String cdmi_acl_key = s.substring(0, s.indexOf(":"));
String cdmi_acl_value = s.substring(s.indexOf(":") + 1); 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); aclMap.put(cdmi_acl_key, cdmi_acl_value);
} }
aclMetaDataIn.add(aclMap); aclMetaDataIn.add(aclMap);

View File

@ -49,8 +49,8 @@ public class DataObject extends CDMIObject {
} }
public static class Builder<B extends Builder<B>> extends CDMIObject.Builder<B> { public static class Builder<B extends Builder<B>> extends CDMIObject.Builder<B> {
private String mimetype = new String(); private String mimetype = "";
private String value = new String(); private String value = "";
/** /**
* @see DataObject#getMimetype() * @see DataObject#getMimetype()

View File

@ -22,7 +22,7 @@ import com.google.common.io.Files;
public class CreateDataObjectOptions extends CreateCDMIObjectOptions { public class CreateDataObjectOptions extends CreateCDMIObjectOptions {
public CreateDataObjectOptions() { public CreateDataObjectOptions() {
jsonObjectBody.addProperty("value", new String()); jsonObjectBody.addProperty("value", "");
} }
/** /**
@ -66,7 +66,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions {
* @return CreateDataObjectOptions * @return CreateDataObjectOptions
*/ */
public CreateDataObjectOptions value(String value) { public CreateDataObjectOptions value(String value) {
jsonObjectBody.addProperty("value", (value == null) ? new String() : value); jsonObjectBody.addProperty("value", (value == null) ? "" : value);
this.payload = jsonObjectBody.toString(); this.payload = jsonObjectBody.toString();
return this; return this;
} }
@ -79,7 +79,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions {
* @return CreateDataObjectOptions * @return CreateDataObjectOptions
*/ */
public CreateDataObjectOptions value(byte[] value) throws IOException { 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()); new ByteArrayInputStream(value)).readUTF());
this.payload = jsonObjectBody.toString(); this.payload = jsonObjectBody.toString();
return this; return this;
@ -93,7 +93,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions {
* @return CreateDataObjectOptions * @return CreateDataObjectOptions
*/ */
public CreateDataObjectOptions value(File value) throws IOException { 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(); this.payload = jsonObjectBody.toString();
return this; return this;
} }
@ -108,7 +108,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions {
* @return CreateDataObjectOptions * @return CreateDataObjectOptions
*/ */
public CreateDataObjectOptions value(File value, Charset charset) throws IOException { 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(); this.payload = jsonObjectBody.toString();
return this; return this;
} }
@ -122,7 +122,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions {
*/ */
public CreateDataObjectOptions value(InputStream value) throws IOException { public CreateDataObjectOptions value(InputStream value) throws IOException {
jsonObjectBody.addProperty("value", 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(); this.payload = jsonObjectBody.toString();
return this; return this;
} }
@ -139,7 +139,7 @@ public class CreateDataObjectOptions extends CreateCDMIObjectOptions {
*/ */
public CreateDataObjectOptions value(InputStream value, Charset charset) throws IOException { public CreateDataObjectOptions value(InputStream value, Charset charset) throws IOException {
jsonObjectBody.addProperty("value", 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(); this.payload = jsonObjectBody.toString();
return this; return this;
} }

View File

@ -69,7 +69,7 @@ public class HardwareBuilderFromResourceAllocations implements
public Volume apply(ResourceAllocationSettingData from) { public Volume apply(ResourceAllocationSettingData from) {
return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null 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); || ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true);
} }
} }

View File

@ -85,7 +85,7 @@ public class KeyStoreSupplier implements Supplier<KeyStore> {
int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY");
String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26);
String pemCerts = ""; StringBuilder pemCerts = new StringBuilder();
int certsBeginIdx = 0; int certsBeginIdx = 0;
do { do {
@ -93,7 +93,7 @@ public class KeyStoreSupplier implements Supplier<KeyStore> {
if (certsBeginIdx >= 0) { if (certsBeginIdx >= 0) {
int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26;
pemCerts += cert.substring(certsBeginIdx, certsEndIdx); pemCerts.append(cert.substring(certsBeginIdx, certsEndIdx));
certsBeginIdx = certsEndIdx; certsBeginIdx = certsEndIdx;
} }
} while (certsBeginIdx != -1); } while (certsBeginIdx != -1);
@ -106,7 +106,7 @@ public class KeyStoreSupplier implements Supplier<KeyStore> {
CertificateFactory cf = CertificateFactory.getInstance("X.509"); CertificateFactory cf = CertificateFactory.getInstance("X.509");
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<Certificate> certs = (Collection<Certificate>) cf.generateCertificates(new ByteArrayInputStream( Collection<Certificate> certs = (Collection<Certificate>) cf.generateCertificates(new ByteArrayInputStream(
pemCerts.getBytes(Charsets.UTF_8))); pemCerts.toString().getBytes(Charsets.UTF_8)));
keyStore.load(null); keyStore.load(null);
keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(), keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(),
certs.toArray(new java.security.cert.Certificate[0])); certs.toArray(new java.security.cert.Certificate[0]));

View File

@ -81,7 +81,7 @@ public class VCloudDirectorComputeUtils {
public static String getVirtualSystemIdentifierOf(Vm vm) { public static String getVirtualSystemIdentifierOf(Vm vm) {
VirtualHardwareSection virtualHardwareSection = findVirtualHardwareSectionForVApp.apply(vm); VirtualHardwareSection virtualHardwareSection = findVirtualHardwareSectionForVApp.apply(vm);
if (virtualHardwareSection != null && virtualHardwareSection != null) if (virtualHardwareSection != null && virtualHardwareSection.getSystem() != null)
return virtualHardwareSection.getSystem().getVirtualSystemIdentifier(); return virtualHardwareSection.getSystem().getVirtualSystemIdentifier();
return null; return null;
} }

View File

@ -143,7 +143,7 @@ public class StorageController {
} }
} }
private class HardDiskPredicate implements Predicate<HardDisk> { private static class HardDiskPredicate implements Predicate<HardDisk> {
private String diskName; private String diskName;

View File

@ -133,7 +133,7 @@ public class YamlImage {
public String credential_url; public String credential_url;
public String sudo_password; public String sudo_password;
public static Function<YamlImage, Image> toImage = new Function<YamlImage, Image>() { public static final Function<YamlImage, Image> toImage = new Function<YamlImage, Image>() {
@Override @Override
public Image apply(YamlImage arg0) { public Image apply(YamlImage arg0) {
if (arg0 == null) if (arg0 == null)

View File

@ -81,7 +81,7 @@ public class IpAddressesLoadingCache extends
@Override @Override
public String getIfPresent(Object key) { public String getIfPresent(Object key) {
return masters.get((String) key); return masters.get((MachineNameOrIdAndNicSlot) key);
} }
@Override @Override

View File

@ -109,7 +109,7 @@ public class UnregisterMachineIfExistsAndDeleteItsMedia implements Function<IMac
return null; return null;
} }
private class AutoDeleteHardDiskPredicate implements Predicate<IMedium> { private static class AutoDeleteHardDiskPredicate implements Predicate<IMedium> {
private VmSpec vmSpec; private VmSpec vmSpec;
@ -128,7 +128,7 @@ public class UnregisterMachineIfExistsAndDeleteItsMedia implements Function<IMac
}; };
private class DeleteChildrenOfMedium implements Function<IMedium, IMedium> { private static class DeleteChildrenOfMedium implements Function<IMedium, IMedium> {
@Override @Override
public IMedium apply(IMedium medium) { public IMedium apply(IMedium medium) {
checkNotNull(medium.getChildren()); checkNotNull(medium.getChildren());

View File

@ -251,7 +251,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra
}); });
} }
class Part { static class Part {
private int part; private int part;
private long offset; private long offset;
private long size; private long size;