mirror of https://github.com/apache/jclouds.git
Avoid eager evaluation of Preconditions messages
Found via error-prone.
This commit is contained in:
parent
e5f65a4791
commit
66cda12b50
|
@ -125,7 +125,7 @@ public class BlockDeviceMapping implements Comparable<BlockDeviceMapping> {
|
||||||
|
|
||||||
if (sizeInGib != null) {
|
if (sizeInGib != null) {
|
||||||
checkArgument(sizeInGib >= VOLUME_SIZE_MIN_VALUE && sizeInGib <= VOLUME_SIZE_MAX_VALUE,
|
checkArgument(sizeInGib >= VOLUME_SIZE_MIN_VALUE && sizeInGib <= VOLUME_SIZE_MAX_VALUE,
|
||||||
String.format("Size in Gib must be between %s and %s GB", VOLUME_SIZE_MIN_VALUE, VOLUME_SIZE_MAX_VALUE));
|
"Size in Gib must be between %s and %s GB", VOLUME_SIZE_MIN_VALUE, VOLUME_SIZE_MAX_VALUE);
|
||||||
}
|
}
|
||||||
this.deviceName = deviceName;
|
this.deviceName = deviceName;
|
||||||
this.virtualName = virtualName;
|
this.virtualName = virtualName;
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedReq
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
checkNotNull(regionToZones, String.format("zone %s not in %s", zone, regionToZones));
|
checkNotNull(regionToZones, "zone %s not in %s", zone, regionToZones);
|
||||||
} else {
|
} else {
|
||||||
region = defaultRegion.get();
|
region = defaultRegion.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class OAuthTestUtils {
|
||||||
if (System.getProperties().containsKey(testKey)) {
|
if (System.getProperties().containsKey(testKey)) {
|
||||||
val = System.getProperty(testKey);
|
val = System.getProperty(testKey);
|
||||||
}
|
}
|
||||||
checkNotNull(val, String.format("the property %s must be set (pem private key file path or private key as a string)", testKey));
|
checkNotNull(val, "the property %s must be set (pem private key file path or private key as a string)", testKey);
|
||||||
|
|
||||||
if (val.startsWith("-----BEGIN")) {
|
if (val.startsWith("-----BEGIN")) {
|
||||||
return val;
|
return val;
|
||||||
|
@ -86,7 +86,7 @@ public class OAuthTestUtils {
|
||||||
checkNotNull(properties);
|
checkNotNull(properties);
|
||||||
checkNotNull(key);
|
checkNotNull(key);
|
||||||
String value = properties.getProperty(key);
|
String value = properties.getProperty(key);
|
||||||
return checkNotNull(value, String.format("mandatory property %s or test.%s was not present", key, key));
|
return checkNotNull(value, "mandatory property %s or test.%s was not present", key, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,7 @@ public final class TestProperties {
|
||||||
val = System.getProperty(testKey);
|
val = System.getProperty(testKey);
|
||||||
}
|
}
|
||||||
checkNotNull(val,
|
checkNotNull(val,
|
||||||
String.format("the property %s must be set (pem private key file path or private key as a string)",
|
"the property %s must be set (pem private key file path or private key as a string)", testKey);
|
||||||
testKey));
|
|
||||||
|
|
||||||
if (val.startsWith("-----BEGIN")) {
|
if (val.startsWith("-----BEGIN")) {
|
||||||
return val;
|
return val;
|
||||||
|
|
|
@ -242,7 +242,7 @@ public class HttpRequest extends HttpMessage {
|
||||||
super(headers, payload);
|
super(headers, payload);
|
||||||
this.method = checkNotNull(method, "method");
|
this.method = checkNotNull(method, "method");
|
||||||
this.endpoint = checkNotNull(endpoint, "endpoint");
|
this.endpoint = checkNotNull(endpoint, "endpoint");
|
||||||
checkArgument(endpoint.getHost() != null, String.format("endpoint.getHost() is null for %s", endpoint));
|
checkArgument(endpoint.getHost() != null, "endpoint.getHost() is null for %s", endpoint);
|
||||||
this.filters = ImmutableList.<HttpRequestFilter> copyOf(checkNotNull(filters, "filters"));
|
this.filters = ImmutableList.<HttpRequestFilter> copyOf(checkNotNull(filters, "filters"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class ParseSax<T> implements Function<HttpResponse, T>, InvocationContext
|
||||||
|
|
||||||
private void validateXml(String from) {
|
private void validateXml(String from) {
|
||||||
checkNotNull(from, "xml string");
|
checkNotNull(from, "xml string");
|
||||||
checkArgument(from.indexOf('<') >= 0, String.format("not an xml document [%s] ", from));
|
checkArgument(from.indexOf('<') >= 0, "not an xml document [%s] ", from);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T parse(InputStream from) {
|
public T parse(InputStream from) {
|
||||||
|
|
|
@ -511,7 +511,7 @@ public class RestAnnotationProcessor implements Function<Invocation, HttpRequest
|
||||||
try {
|
try {
|
||||||
URI returnVal = parser.apply(invocation.getArgs().get(position));
|
URI returnVal = parser.apply(invocation.getArgs().get(position));
|
||||||
checkArgument(returnVal != null,
|
checkArgument(returnVal != null,
|
||||||
format("endpoint for [%s] not configured for %s", position, invocation.getInvokable()));
|
"endpoint for [%s] not configured for %s", position, invocation.getInvokable());
|
||||||
return returnVal;
|
return returnVal;
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new IllegalArgumentException(format("argument at index %d on invocation.getInvoked() %s was null",
|
throw new IllegalArgumentException(format("argument at index %d on invocation.getInvoked() %s was null",
|
||||||
|
|
|
@ -154,8 +154,8 @@ public class JschSshClient implements SshClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkConnected() {
|
private void checkConnected() {
|
||||||
checkState(sessionConnection.getSession() != null && sessionConnection.getSession().isConnected(), String.format(
|
checkState(sessionConnection.getSession() != null && sessionConnection.getSession().isConnected(),
|
||||||
"(%s) Session not connected!", toString()));
|
"(%s) Session not connected!", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Connection<T> {
|
public interface Connection<T> {
|
||||||
|
|
|
@ -172,8 +172,8 @@ public class SshjSshClient implements SshClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkConnected() {
|
private void checkConnected() {
|
||||||
checkState(sshClientConnection.ssh != null && sshClientConnection.ssh.isConnected(), String
|
checkState(sshClientConnection.ssh != null && sshClientConnection.ssh.isConnected(),
|
||||||
.format("(%s) ssh not connected!", toString()));
|
"(%s) ssh not connected!", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Connection<T> {
|
public interface Connection<T> {
|
||||||
|
|
|
@ -127,8 +127,8 @@ public class AWSEC2ComputeService extends EC2ComputeService {
|
||||||
try {
|
try {
|
||||||
client.getPlacementGroupApi().get().deletePlacementGroupInRegion(region, placementGroup);
|
client.getPlacementGroupApi().get().deletePlacementGroupInRegion(region, placementGroup);
|
||||||
checkState(placementGroupDeleted.apply(new PlacementGroup(region, placementGroup, "cluster",
|
checkState(placementGroupDeleted.apply(new PlacementGroup(region, placementGroup, "cluster",
|
||||||
State.PENDING)), String.format("placementGroup region(%s) name(%s) failed to delete", region,
|
State.PENDING)), "placementGroup region(%s) name(%s) failed to delete", region,
|
||||||
placementGroup));
|
placementGroup);
|
||||||
placementGroupMap.invalidate(new RegionAndName(region, placementGroup));
|
placementGroupMap.invalidate(new RegionAndName(region, placementGroup));
|
||||||
logger.debug("<< deleted placementGroup(%s)", placementGroup);
|
logger.debug("<< deleted placementGroup(%s)", placementGroup);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
|
|
|
@ -63,8 +63,8 @@ public class CreatePlacementGroupIfNeeded extends CacheLoader<RegionAndName, Str
|
||||||
try {
|
try {
|
||||||
ec2Api.getPlacementGroupApi().get().createPlacementGroupInRegion(region, name);
|
ec2Api.getPlacementGroupApi().get().createPlacementGroupInRegion(region, name);
|
||||||
logger.debug("<< created placementGroup(%s)", name);
|
logger.debug("<< created placementGroup(%s)", name);
|
||||||
checkState(placementGroupAvailable.apply(new PlacementGroup(region, name, "cluster", State.PENDING)), String
|
checkState(placementGroupAvailable.apply(new PlacementGroup(region, name, "cluster", State.PENDING)),
|
||||||
.format("placementGroup region(%s) name(%s) failed to become available", region, name));
|
"placementGroup region(%s) name(%s) failed to become available", region, name);
|
||||||
} catch (AWSResponseException e) {
|
} catch (AWSResponseException e) {
|
||||||
if (e.getError().getCode().equals("InvalidPlacementGroup.Duplicate")) {
|
if (e.getError().getCode().equals("InvalidPlacementGroup.Duplicate")) {
|
||||||
logger.debug("<< reused placementGroup(%s)", name);
|
logger.debug("<< reused placementGroup(%s)", name);
|
||||||
|
|
Loading…
Reference in New Issue