From d0eec713a4c838c67b3421b87eefa67500947e5d Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 10 Dec 2015 08:59:05 -0800 Subject: [PATCH] Add generic type to ServiceOption definition + minor fixes --- .../src/main/java/com/google/gcloud/PageImpl.java | 3 +-- .../main/java/com/google/gcloud/ServiceOptions.java | 12 +++--------- .../java/com/google/gcloud/datastore/ValueTest.java | 2 +- .../gcloud/storage/BlobWriteChannelImplTest.java | 3 ++- .../com/google/gcloud/storage/ITStorageTest.java | 3 +-- .../com/google/gcloud/storage/SerializationTest.java | 3 ++- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/PageImpl.java b/gcloud-java-core/src/main/java/com/google/gcloud/PageImpl.java index 97c2931e0cfb..1c7a61ec471f 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/PageImpl.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/PageImpl.java @@ -71,10 +71,9 @@ public PageImpl(NextPageFetcher pageFetcher, String cursor, Iterable resul this.results = results; } - @SuppressWarnings("unchecked") @Override public Iterable values() { - return results == null ? Collections.EMPTY_LIST : results; + return results == null ? Collections.emptyList() : results; } @Override diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java index 9e5d6730f551..862d3f7b533d 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java @@ -53,12 +53,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -@SuppressWarnings("rawtypes") -public abstract class ServiceOptions< - ServiceT extends Service, - ServiceRpcT, - OptionsT extends ServiceOptions> - implements Serializable { +public abstract class ServiceOptions, ServiceRpcT, + OptionsT extends ServiceOptions> implements Serializable { private static final String DEFAULT_HOST = "https://www.googleapis.com"; private static final long serialVersionUID = 1203687993961393350L; @@ -154,9 +150,7 @@ private Object readResolve() throws ObjectStreamException { } } - protected abstract static class Builder< - ServiceT extends Service, - ServiceRpcT, + protected abstract static class Builder, ServiceRpcT, OptionsT extends ServiceOptions, B extends Builder> { diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/ValueTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/ValueTest.java index 3867e194d060..891668990f66 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/ValueTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/ValueTest.java @@ -66,7 +66,7 @@ private class TestBuilder extends Value.BaseBuilder, TestBuilder super(ValueType.LIST); } - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"unchecked"}) @Override public Value build() { return new Value(this) { diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelImplTest.java index 5d44fcb5f320..c2107ff13998 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelImplTest.java @@ -234,7 +234,8 @@ public void testStateEquals() { .times(2); replay(storageRpcMock); writer = new BlobWriteChannelImpl(options, BLOB_INFO, EMPTY_RPC_OPTIONS); - @SuppressWarnings("resource") // avoid closing when you don't want partial writes to GCS + // avoid closing when you don't want partial writes to GCS upon failure + @SuppressWarnings("resource") BlobWriteChannel writer2 = new BlobWriteChannelImpl(options, BLOB_INFO, EMPTY_RPC_OPTIONS); RestorableState state = writer.capture(); RestorableState state2 = writer2.capture(); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java index 05055e9c3ca9..22b0a35c0620 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java @@ -74,8 +74,7 @@ public static void beforeClass() { } @AfterClass - public static void afterClass() -throws ExecutionException, InterruptedException { + public static void afterClass() throws ExecutionException, InterruptedException { if (storage != null && !RemoteGcsHelper.forceDelete(storage, BUCKET, 5, TimeUnit.SECONDS)) { if (log.isLoggable(Level.WARNING)) { log.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index af779512e0e8..555e231f7f0e 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -128,7 +128,8 @@ public void testWriteChannelState() throws IOException, ClassNotFoundException { .projectId("p2") .retryParams(RetryParams.defaultInstance()) .build(); - @SuppressWarnings("resource") // avoid closing when you don't want partial writes to GCS + // avoid closing when you don't want partial writes to GCS upon failure + @SuppressWarnings("resource") BlobWriteChannelImpl writer = new BlobWriteChannelImpl( options, BlobInfo.builder(BlobId.of("b", "n")).build(), "upload-id"); RestorableState state = writer.capture();