mirror of https://github.com/apache/jclouds.git
Merge pull request #1207 from jclouds/compile-warnings-core
removed all compile warnings in core except json package
This commit is contained in:
commit
78d1bad411
|
@ -19,12 +19,14 @@
|
|||
package org.jclouds.reflect;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
|
@ -43,6 +45,19 @@ public final class Invocation {
|
|||
return new Invocation(invokable, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* invocation without arguments.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if in invokable requires arguments
|
||||
*/
|
||||
public static Invocation create(Invokable<?, ?> invokable) {
|
||||
checkArgument(
|
||||
invokable.getParameters().size() == 0 || (invokable.getParameters().size() == 1 && invokable.isVarArgs()),
|
||||
"please specify arguments to %s", invokable);
|
||||
return create(invokable, ImmutableList.of());
|
||||
}
|
||||
|
||||
private final Invokable<?, ?> invokable;
|
||||
private final List<Object> args;
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ package org.jclouds.rest;
|
|||
*/
|
||||
public class AuthorizationException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AuthorizationException() {
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ package org.jclouds.rest;
|
|||
*/
|
||||
public class InsufficientResourcesException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InsufficientResourcesException() {
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ package org.jclouds.rest;
|
|||
*/
|
||||
public class ResourceNotFoundException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ResourceNotFoundException() {
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.jclouds.http.HttpRequest;
|
|||
*/
|
||||
public class BindException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private HttpRequest request;
|
||||
|
||||
public BindException(final HttpRequest request) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.Context;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.IntegrationTestAsyncClient;
|
||||
import org.jclouds.http.IntegrationTestClient;
|
||||
|
@ -48,7 +49,7 @@ import com.google.inject.Injector;
|
|||
@Test(groups = "unit", testName = "BindRestContextWithWildcardExtendsExplicitAndRawTypeTest")
|
||||
public class BindRestContextWithWildcardExtendsExplicitAndRawTypeTest {
|
||||
|
||||
@SuppressWarnings( { "unused", "unchecked" })
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static class ExpectedBindings {
|
||||
|
||||
private final RestContext raw;
|
||||
|
@ -92,7 +93,7 @@ public class BindRestContextWithWildcardExtendsExplicitAndRawTypeTest {
|
|||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unused", "unchecked" })
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static class ExpectedBindingsWithWildCardExtends {
|
||||
|
||||
private final RestContext raw;
|
||||
|
@ -110,13 +111,13 @@ public class BindRestContextWithWildcardExtendsExplicitAndRawTypeTest {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testRawExplicitAndWildCardExtends() {
|
||||
ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(
|
||||
IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost");
|
||||
|
||||
TypeToken wildCardExtendsType = new TypeToken<RestContext<? extends IntegrationTestClient, ? extends IntegrationTestAsyncClient>>() {
|
||||
TypeToken<? extends Context> wildCardExtendsType = new TypeToken<RestContext<? extends IntegrationTestClient, ? extends IntegrationTestAsyncClient>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
};
|
||||
|
||||
md = md.toBuilder().apiMetadata(md.getApiMetadata().toBuilder().context(wildCardExtendsType).build()).build();
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.jclouds.http.HttpCommand;
|
|||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.IntegrationTestAsyncClient;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.reflect.Invocation;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -127,7 +128,7 @@ public class BackoffLimitedRetryHandlerTest {
|
|||
private HttpCommand createCommand() throws SecurityException, NoSuchMethodException {
|
||||
Invokable<IntegrationTestAsyncClient, String> method = method(IntegrationTestAsyncClient.class, "download", String.class);
|
||||
|
||||
return new HttpCommand(processor.createRequest(method, ImmutableList.<Object> of("1")));
|
||||
return new HttpCommand(processor.apply(Invocation.create(method, ImmutableList.<Object> of("1"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -71,7 +71,6 @@ public class FilterStringsBoundToInjectorByNameTest {
|
|||
|
||||
public void testReturnsJavaNamedString() {
|
||||
FilterStringsBoundToInjectorByName fn = Guice.createInjector(new AbstractModule() {
|
||||
@SuppressWarnings("unused")
|
||||
@Named("foo")
|
||||
@Provides
|
||||
String provideFoo() {
|
||||
|
|
|
@ -85,6 +85,7 @@ public class GsonExperimentsTest {
|
|||
}
|
||||
|
||||
public class OptionalTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
|
||||
Type type = typeToken.getType();
|
||||
if (typeToken.getRawType() != Optional.class || !(type instanceof ParameterizedType)) {
|
||||
|
|
|
@ -67,11 +67,8 @@ public class ProvideIso3166CodesByLocationIdViaPropertiesTest {
|
|||
.<String, Set<String>> of("us-east", ImmutableSet.of("US"), "us-easta", ImmutableSet.of("US-CA")));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
private LocationIdToIso3166CodesSupplier createWithValue(final ImmutableMap<String, String> value) {
|
||||
LocationIdToIso3166CodesSupplier fn = Guice.createInjector(new AbstractModule() {
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
Function<Predicate<String>, Map<String, String>> provide() {
|
||||
return new Function<Predicate<String>, Map<String, String>>() {
|
||||
|
|
|
@ -98,7 +98,6 @@ public class BindLoggersAnnotatedWithResourceTest {
|
|||
}
|
||||
|
||||
public static class C {
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
private Logger logger = Logger.NULL;
|
||||
}
|
||||
|
@ -111,11 +110,9 @@ public class BindLoggersAnnotatedWithResourceTest {
|
|||
}
|
||||
|
||||
public static class D {
|
||||
@SuppressWarnings("unused")
|
||||
@Resource
|
||||
private Logger logger = Logger.NULL;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Resource
|
||||
private Logger blogger;
|
||||
|
||||
|
|
|
@ -64,21 +64,21 @@ public class InputParamValidatorTest {
|
|||
String.class, String.class);
|
||||
Invokable<?, ?> oneParamValidatedMethod = method(InputParamValidatorForm.class, "oneParamValidated",
|
||||
String.class, String.class);
|
||||
restAnnotationProcessor.createRequest(allParamsValidatedMethod, ImmutableList.<Object> of("blah", "blah"));
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, ImmutableList.<Object> of("blah", "blah"));
|
||||
restAnnotationProcessor.apply(Invocation.create(allParamsValidatedMethod, ImmutableList.<Object> of("blah", "blah")));
|
||||
restAnnotationProcessor.apply(Invocation.create(oneParamValidatedMethod, ImmutableList.<Object> of("blah", "blah")));
|
||||
|
||||
try {
|
||||
restAnnotationProcessor.createRequest(allParamsValidatedMethod, ImmutableList.<Object> of("BLAH", "blah"));
|
||||
restAnnotationProcessor.apply(Invocation.create(allParamsValidatedMethod, ImmutableList.<Object> of("BLAH", "blah")));
|
||||
throw new TestException(
|
||||
"AllLowerCaseValidator shouldn't have passed 'BLAH' as a parameter because it's uppercase.");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// supposed to happen - continue
|
||||
}
|
||||
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, ImmutableList.<Object> of("BLAH", "blah"));
|
||||
restAnnotationProcessor.apply(Invocation.create(oneParamValidatedMethod, ImmutableList.<Object> of("BLAH", "blah")));
|
||||
|
||||
try {
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, ImmutableList.<Object> of("blah", "BLAH"));
|
||||
restAnnotationProcessor.apply(Invocation.create(oneParamValidatedMethod, ImmutableList.<Object> of("blah", "BLAH")));
|
||||
throw new TestException(
|
||||
"AllLowerCaseValidator shouldn't have passed 'BLAH' as the second parameter because it's uppercase.");
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
|
|
@ -127,10 +127,10 @@ public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest
|
|||
ImplicitOptionalConverter fn = forApiVersion("2011-07-15");
|
||||
Stopwatch watch = new Stopwatch().start();
|
||||
fn.apply(keyPairApi);
|
||||
long first = watch.stop().elapsedTime(TimeUnit.MICROSECONDS);
|
||||
long first = watch.stop().elapsed(TimeUnit.MICROSECONDS);
|
||||
watch.reset().start();
|
||||
fn.apply(keyPairApi);
|
||||
long cached = watch.stop().elapsedTime(TimeUnit.MICROSECONDS);
|
||||
long cached = watch.stop().elapsed(TimeUnit.MICROSECONDS);
|
||||
assertTrue(cached < first, String.format("cached [%s] should be less than initial [%s]", cached, first));
|
||||
Logger.getAnonymousLogger().info(
|
||||
"lookup cache saved " + (first - cached) + " microseconds when no annotation present");
|
||||
|
@ -141,10 +141,10 @@ public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest
|
|||
ImplicitOptionalConverter fn = forApiVersion("2011-07-15");
|
||||
Stopwatch watch = new Stopwatch().start();
|
||||
fn.apply(floatingIpApi);
|
||||
long first = watch.stop().elapsedTime(TimeUnit.MICROSECONDS);
|
||||
long first = watch.stop().elapsed(TimeUnit.MICROSECONDS);
|
||||
watch.reset().start();
|
||||
fn.apply(floatingIpApi);
|
||||
long cached = watch.stop().elapsedTime(TimeUnit.MICROSECONDS);
|
||||
long cached = watch.stop().elapsed(TimeUnit.MICROSECONDS);
|
||||
assertTrue(cached < first, String.format("cached [%s] should be less than initial [%s]", cached, first));
|
||||
Logger.getAnonymousLogger().info(
|
||||
"lookup cache saved " + (first - cached) + " microseconds when annotation present");
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.util;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.jclouds.util.Predicates2.retry;
|
||||
import static org.testng.Assert.fail;
|
||||
|
@ -99,7 +100,7 @@ public class Predicates2Test {
|
|||
}
|
||||
|
||||
});
|
||||
long duration = stopwatch.elapsedMillis();
|
||||
long duration = stopwatch.elapsed(MILLISECONDS);
|
||||
assertOrdered(duration, SLOW_BUILD_SERVER_GRACE);
|
||||
}
|
||||
|
||||
|
@ -109,7 +110,7 @@ public class Predicates2Test {
|
|||
Predicate<String> predicate = retry(Predicates.<String> alwaysTrue(), 3, 1, SECONDS);
|
||||
stopwatch.start();
|
||||
predicate.apply("");
|
||||
long duration = stopwatch.elapsedMillis();
|
||||
long duration = stopwatch.elapsed(MILLISECONDS);
|
||||
assertOrdered(duration, SLOW_BUILD_SERVER_GRACE);
|
||||
}
|
||||
|
||||
|
@ -120,7 +121,7 @@ public class Predicates2Test {
|
|||
Predicate<String> predicate = retry(Predicates.<String> alwaysFalse(), 3, 1, SECONDS);
|
||||
stopwatch.start();
|
||||
predicate.apply("");
|
||||
long duration = stopwatch.elapsedMillis();
|
||||
long duration = stopwatch.elapsed(MILLISECONDS);
|
||||
assertOrdered(3000-EARLY_RETURN_GRACE, duration, 3000+SLOW_BUILD_SERVER_GRACE);
|
||||
}
|
||||
|
||||
|
@ -133,7 +134,7 @@ public class Predicates2Test {
|
|||
|
||||
stopwatch.start();
|
||||
predicate.apply("");
|
||||
long duration = stopwatch.elapsedMillis();
|
||||
long duration = stopwatch.elapsed(MILLISECONDS);
|
||||
|
||||
assertOrdered(2500-EARLY_RETURN_GRACE, duration, 2500+SLOW_BUILD_SERVER_GRACE);
|
||||
assertCallTimes(rawPredicate.callTimes, 0, 1000, 1000+1500);
|
||||
|
@ -148,7 +149,7 @@ public class Predicates2Test {
|
|||
|
||||
stopwatch.start();
|
||||
predicate.apply("");
|
||||
long duration = stopwatch.elapsedMillis();
|
||||
long duration = stopwatch.elapsed(MILLISECONDS);
|
||||
|
||||
assertOrdered(2000-EARLY_RETURN_GRACE, duration, 2000+SLOW_BUILD_SERVER_GRACE);
|
||||
assertCallTimes(rawPredicate.callTimes, 0, 1000, 2000);
|
||||
|
@ -167,7 +168,7 @@ public class Predicates2Test {
|
|||
}
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
callTimes.add(stopwatch.elapsedMillis());
|
||||
callTimes.add(stopwatch.elapsed(MILLISECONDS));
|
||||
return count++ == succeedOnAttempt;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue