Skip to content

Commit 604b1c4

Browse files
committed
More style fixes to Storage module
1 parent b504340 commit 604b1c4

File tree

12 files changed

+46
-55
lines changed

12 files changed

+46
-55
lines changed

gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ public Tuple<String, byte[]> read(StorageObject from, Map<Option, ?> options, lo
479479
}
480480

481481
@Override
482-
public void write(String uploadId, byte[] toWrite, int toWriteOffset, StorageObject dest,
483-
long destOffset, int length, boolean last) throws StorageException {
482+
public void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length,
483+
boolean last) throws StorageException {
484484
try {
485485
GenericUrl url = new GenericUrl(uploadId);
486486
HttpRequest httpRequest = storage.getRequestFactory().buildPutRequest(url,
@@ -571,7 +571,7 @@ private RewriteResponse rewrite(RewriteRequest req, String token) throws Storage
571571
try {
572572
Long maxBytesRewrittenPerCall = req.megabytesRewrittenPerCall != null
573573
? req.megabytesRewrittenPerCall * MEGABYTE : null;
574-
com.google.api.services.storage.model.RewriteResponse rewriteReponse = storage.objects()
574+
com.google.api.services.storage.model.RewriteResponse rewriteResponse = storage.objects()
575575
.rewrite(req.source.getBucket(), req.source.getName(), req.target.getBucket(),
576576
req.target.getName(), req.target.getContentType() != null ? req.target : null)
577577
.setSourceGeneration(req.source.getGeneration())
@@ -590,11 +590,11 @@ private RewriteResponse rewrite(RewriteRequest req, String token) throws Storage
590590
.execute();
591591
return new RewriteResponse(
592592
req,
593-
rewriteReponse.getResource(),
594-
rewriteReponse.getObjectSize().longValue(),
595-
rewriteReponse.getDone(),
596-
rewriteReponse.getRewriteToken(),
597-
rewriteReponse.getTotalBytesRewritten().longValue());
593+
rewriteResponse.getResource(),
594+
rewriteResponse.getObjectSize().longValue(),
595+
rewriteResponse.getDone(),
596+
rewriteResponse.getRewriteToken(),
597+
rewriteResponse.getTotalBytesRewritten().longValue());
598598
} catch (IOException ex) {
599599
throw translate(ex);
600600
}

gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ Tuple<String, byte[]> read(StorageObject from, Map<Option, ?> options, long posi
264264

265265
String open(StorageObject object, Map<Option, ?> options) throws StorageException;
266266

267-
void write(String uploadId, byte[] toWrite, int toWriteOffset, StorageObject dest,
268-
long destOffset, int length, boolean last) throws StorageException;
267+
void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length,
268+
boolean last) throws StorageException;
269269

270270
RewriteResponse openRewrite(RewriteRequest rewriteRequest) throws StorageException;
271271

gcloud-java-storage/src/main/java/com/google/gcloud/storage/Acl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ String toPb() {
275275
}
276276

277277
/**
278-
* Creats an ACL object.
278+
* Creates an ACL object.
279279
*
280280
* @param entity the entity for this ACL object
281281
* @param role the role to associate to the {@code entity} object

gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ Builder mediaLink(String mediaLink) {
277277
*/
278278
public Builder metadata(Map<String, String> metadata) {
279279
this.metadata = metadata != null
280-
? new HashMap(metadata) : Data.<Map>nullOf(ImmutableEmptyMap.class);
280+
? new HashMap<>(metadata) : Data.<Map<String, String>>nullOf(ImmutableEmptyMap.class);
281281
return this;
282282
}
283283

@@ -576,8 +576,9 @@ public ObjectAccessControl apply(Acl acl) {
576576
Map<String, String> pbMetadata = metadata;
577577
if (metadata != null && !Data.isNull(metadata)) {
578578
pbMetadata = Maps.newHashMapWithExpectedSize(metadata.size());
579-
for (String key : metadata.keySet()) {
580-
pbMetadata.put(key, firstNonNull(metadata.get(key), Data.<String>nullOf(String.class)));
579+
for (Map.Entry<String, String> entry : metadata.entrySet()) {
580+
pbMetadata.put(entry.getKey(),
581+
firstNonNull(entry.getValue(), Data.<String>nullOf(String.class)));
581582
}
582583
}
583584
storageObject.setMetadata(pbMetadata);

gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobWriteChannelImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private void flush() {
9191
runWithRetries(callable(new Runnable() {
9292
@Override
9393
public void run() {
94-
storageRpc.write(uploadId, buffer, 0, storageObject, position, length, false);
94+
storageRpc.write(uploadId, buffer, 0, position, length, false);
9595
}
9696
}), options.retryParams(), StorageImpl.EXCEPTION_HANDLER);
9797
} catch (RetryHelper.RetryHelperException e) {
@@ -139,7 +139,7 @@ public void close() throws IOException {
139139
runWithRetries(callable(new Runnable() {
140140
@Override
141141
public void run() {
142-
storageRpc.write(uploadId, buffer, 0, storageObject, position, limit, true);
142+
storageRpc.write(uploadId, buffer, 0, position, limit, true);
143143
}
144144
}), options.retryParams(), StorageImpl.EXCEPTION_HANDLER);
145145
} catch (RetryHelper.RetryHelperException e) {

gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private static class BlobPageFetcher implements PageImpl.NextPageFetcher<Blob> {
7171
@Override
7272
public Page<Blob> nextPage() {
7373
Page<BlobInfo> nextInfoPage = infoPage.nextPage();
74-
return new PageImpl<Blob>(new BlobPageFetcher(options, nextInfoPage),
74+
return new PageImpl<>(new BlobPageFetcher(options, nextInfoPage),
7575
nextInfoPage.nextPageCursor(), new LazyBlobIterable(options, nextInfoPage.values()));
7676
}
7777
}

gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
*/
5151
public interface Storage extends Service<StorageOptions> {
5252

53-
public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream";
53+
String DEFAULT_CONTENT_TYPE = "application/octet-stream";
5454

5555
enum PredefinedAcl {
5656
AUTHENTICATED_READ("authenticatedRead"),

gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.junit.Assert.assertArrayEquals;
2626
import static org.junit.Assert.assertEquals;
2727
import static org.junit.Assert.assertFalse;
28+
import static org.junit.Assert.assertNotNull;
2829
import static org.junit.Assert.assertNull;
2930
import static org.junit.Assert.assertSame;
3031
import static org.junit.Assert.assertTrue;
@@ -272,13 +273,13 @@ public void testDeleteNone() throws Exception {
272273

273274
@Test
274275
public void testDeleteSome() throws Exception {
275-
List<Boolean> deleleResultList = Arrays.asList(true, true, true);
276-
expect(storage.delete(BLOB_ID_ARRAY)).andReturn(deleleResultList);
276+
List<Boolean> deleteResult = Arrays.asList(true, true, true);
277+
expect(storage.delete(BLOB_ID_ARRAY)).andReturn(deleteResult);
277278
replay(storage);
278279
List<Boolean> result = Blob.delete(storage, BLOB_ID_ARRAY);
279-
assertEquals(deleleResultList.size(), result.size());
280-
for (int i = 0; i < deleleResultList.size(); i++) {
281-
assertEquals(deleleResultList.get(i), result.get(i));
280+
assertEquals(deleteResult.size(), result.size());
281+
for (int i = 0; i < deleteResult.size(); i++) {
282+
assertEquals(deleteResult.get(i), result.get(i));
282283
}
283284
}
284285

@@ -295,6 +296,7 @@ public void testLoadFromId() throws Exception {
295296
expect(storage.get(BLOB_INFO.blobId())).andReturn(BLOB_INFO);
296297
replay(storage);
297298
Blob loadedBlob = Blob.load(storage, BLOB_INFO.blobId());
299+
assertNotNull(loadedBlob);
298300
assertEquals(BLOB_INFO, loadedBlob.info());
299301
}
300302
}

gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelImplTest.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public void testWriteWithoutFlush() throws IOException {
102102
public void testWriteWithFlush() throws IOException {
103103
expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
104104
Capture<byte[]> capturedBuffer = Capture.newInstance();
105-
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0),
106-
eq(BLOB_INFO.toPb()), eq(0L), eq(CUSTOM_CHUNK_SIZE), eq(false));
105+
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L),
106+
eq(CUSTOM_CHUNK_SIZE), eq(false));
107107
replay(storageRpcMock);
108108
writer = new BlobWriteChannelImpl(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
109109
writer.chunkSize(CUSTOM_CHUNK_SIZE);
@@ -116,9 +116,8 @@ public void testWriteWithFlush() throws IOException {
116116
public void testWritesAndFlush() throws IOException {
117117
expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
118118
Capture<byte[]> capturedBuffer = Capture.newInstance();
119-
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0),
120-
eq(BLOB_INFO.toPb()), eq(0L), eq(DEFAULT_CHUNK_SIZE),
121-
eq(false));
119+
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L),
120+
eq(DEFAULT_CHUNK_SIZE), eq(false));
122121
replay(storageRpcMock);
123122
writer = new BlobWriteChannelImpl(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
124123
ByteBuffer[] buffers = new ByteBuffer[DEFAULT_CHUNK_SIZE / MIN_CHUNK_SIZE];
@@ -138,8 +137,7 @@ public void testWritesAndFlush() throws IOException {
138137
public void testCloseWithoutFlush() throws IOException {
139138
expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
140139
Capture<byte[]> capturedBuffer = Capture.newInstance();
141-
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0),
142-
eq(BLOB_INFO.toPb()), eq(0L), eq(0), eq(true));
140+
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(0), eq(true));
143141
replay(storageRpcMock);
144142
writer = new BlobWriteChannelImpl(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
145143
assertTrue(writer.isOpen());
@@ -153,8 +151,7 @@ public void testCloseWithFlush() throws IOException {
153151
expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
154152
Capture<byte[]> capturedBuffer = Capture.newInstance();
155153
ByteBuffer buffer = randomBuffer(MIN_CHUNK_SIZE);
156-
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0),
157-
eq(BLOB_INFO.toPb()), eq(0L), eq(MIN_CHUNK_SIZE),
154+
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(MIN_CHUNK_SIZE),
158155
eq(true));
159156
replay(storageRpcMock);
160157
writer = new BlobWriteChannelImpl(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
@@ -170,8 +167,7 @@ public void testCloseWithFlush() throws IOException {
170167
public void testWriteClosed() throws IOException {
171168
expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
172169
Capture<byte[]> capturedBuffer = Capture.newInstance();
173-
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0),
174-
eq(BLOB_INFO.toPb()), eq(0L), eq(0), eq(true));
170+
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(0), eq(true));
175171
replay(storageRpcMock);
176172
writer = new BlobWriteChannelImpl(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
177173
writer.close();
@@ -189,8 +185,7 @@ public void testSaveAndRestore() throws IOException {
189185
Capture<byte[]> capturedBuffer = Capture.newInstance(CaptureType.ALL);
190186
Capture<Long> capturedPosition = Capture.newInstance(CaptureType.ALL);
191187
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0),
192-
eq(BLOB_INFO.toPb()), captureLong(capturedPosition),
193-
eq(DEFAULT_CHUNK_SIZE), eq(false));
188+
captureLong(capturedPosition), eq(DEFAULT_CHUNK_SIZE), eq(false));
194189
expectLastCall().times(2);
195190
replay(storageRpcMock);
196191
ByteBuffer buffer1 = randomBuffer(DEFAULT_CHUNK_SIZE);
@@ -210,8 +205,7 @@ public void testSaveAndRestore() throws IOException {
210205
public void testSaveAndRestoreClosed() throws IOException {
211206
expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
212207
Capture<byte[]> capturedBuffer = Capture.newInstance();
213-
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0),
214-
eq(BLOB_INFO.toPb()), eq(0L), eq(0), eq(true));
208+
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(0), eq(true));
215209
replay(storageRpcMock);
216210
writer = new BlobWriteChannelImpl(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
217211
writer.close();

gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.easymock.EasyMock.verify;
2424
import static org.junit.Assert.assertEquals;
2525
import static org.junit.Assert.assertFalse;
26+
import static org.junit.Assert.assertNotNull;
2627
import static org.junit.Assert.assertSame;
2728
import static org.junit.Assert.assertTrue;
2829

@@ -219,6 +220,7 @@ public void testLoad() throws Exception {
219220
expect(storage.get(BUCKET_INFO.name())).andReturn(BUCKET_INFO);
220221
replay(storage);
221222
Bucket loadedBucket = Bucket.load(storage, BUCKET_INFO.name());
223+
assertNotNull(loadedBucket);
222224
assertEquals(BUCKET_INFO, loadedBucket.info());
223225
}
224226
}

0 commit comments

Comments
 (0)