Skip to content

Commit 75d9533

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 925 b: refs/heads/master c: 21cde60 h: refs/heads/master i: 923: 9f1eaab v: v3
1 parent 38789cd commit 75d9533

7 files changed

Lines changed: 134 additions & 271 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
refs/heads/master: d82500d1409dc58dd0fdeb34d015cd8a4068ae84
2+
refs/heads/master: 21cde602e81a34499461db4e843e91ed82d02757
33
refs/heads/travis: 0fa997e2fc9c6b61b2d91e6d163655aae67d44b6
44
refs/heads/gh-pages: 5a10432ecc75f29812e33a8236c900379509fe99

trunk/.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ env:
2424
- secure: "CUM2l73KFm7U4eDsUKkh1WyEUzF3v94Ltvs7MnKU9olE1dNp3YmRBL9Lqhx3hSDqm/xv0ETQsPy29Fs2+VFkhQQxSley6iS/4trr2fioTB680txfXo/zDdmGSP1q1/U40fv1S+jvuBRAhDV5W+8dhWOGtzMH0tJp/TszeDGlmCY="
2525
- secure: "YBbdzseg5yDFpQIiMoc3P2BTmqef4o+KAvrLMEbobXjIkiglUQ7UHCoRWClX74fTKAwuC7JvK7o5xJGLnaY43jJADXrGtE8/d44HNJaieE67mNosDYtOiA0iI2uIRFCAnXJCZ8f/iHx2xVMHMNWlwyoil4IUcjj+D7FRcsT5alE="
2626
- secure: "Od7BwllgFXVfzFe8ooTNm05TR+Xd5QjHW0oqhU8vclaQs2oX4e0eNIsebXQfLi3xDgd1pz5uUQC/Z4S0NqACwyUuUvPdGYYmRPTR7Dh8HgGJ4ojSdN3RwaHsxUqG7Ajts9rIHOtRpY28xOChVRNX0Z7eAPlvxYU4Ed2ZEo356r0="
27-
- secure: "PZ7dnp9Gp5HY1Iu5Z5n/wjkArWExJ958hC60nzE/r7uh9iRIEbIfbWW5KTkqlmxTsTVUR5JH2hjqu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jwURd76kYHaFyXwU7zgG3/JTePTSXGCfdWAbaKG43nEf6Kmz6my1VCQmwhWdrCNna/VD8YN49TKKlNj9b2A88mHmEqnHHL6xtvR7JqUF1I6WKmQqb9z1VCV9hHgVfPJro+PAer5Qrb6mFkSdg1JNv+aIIz3fEXX0SLbQyrRsWbnAR8kfO6wN4uT7RcGn/5q/vphxcUdU1klJ4bs/GQVFxWt12DfMmcMrqcf/M="
27+
- secure: "ROxa8HHuba+Dfixljq6poW1+Uwv8EaZUtTTTB7KEtAHJRN8rwoNS4TC0U0PEHcYAL+ivxP3zIfWOCoWreJGoa+V8y9BtLSuamUj/SSsuoHRdJjq5BmcHI/77P11HAzCH6Ul/GxsRB52/IRHwJyfKkh8XUMVSsCl7AG4CKUgt63Y="
28+
- secure: "MKZ3y6IYp3Z67T+BO4Brw+my8sRMSMdWWgvUcyBpwQZ64w7ccHJCce4W8WHCPNko/eczHHCJELPG28VNyPTWIV/Jt2ZJ6L9qLCjsQpDPOdJdDaAKc9Df4sm8fB0FBiPVDwMYPQF1/Sy2gK7FZf0YR3LOeoyzswRgmj5bQMdVEeU="

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannelImpl.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static com.google.gcloud.RetryHelper.runWithRetries;
2020

2121
import com.google.api.services.storage.model.StorageObject;
22-
import com.google.gcloud.RetryHelper;
2322
import com.google.gcloud.spi.StorageRpc;
2423

2524
import java.io.IOException;
@@ -120,16 +119,12 @@ public int read(ByteBuffer byteBuffer) throws IOException {
120119
return -1;
121120
}
122121
final int toRead = Math.max(byteBuffer.remaining(), chunkSize);
123-
try {
124-
buffer = runWithRetries(new Callable<byte[]>() {
125-
@Override
126-
public byte[] call() {
127-
return storageRpc.read(storageObject, requestOptions, position, toRead);
128-
}
129-
}, serviceOptions.retryParams(), StorageImpl.EXCEPTION_HANDLER);
130-
} catch (RetryHelper.RetryHelperException e) {
131-
throw StorageException.translateAndThrow(e);
132-
}
122+
buffer = runWithRetries(new Callable<byte[]>() {
123+
@Override
124+
public byte[] call() {
125+
return storageRpc.read(storageObject, requestOptions, position, toRead);
126+
}
127+
}, serviceOptions.retryParams(), StorageImpl.EXCEPTION_HANDLER);
133128
if (toRead > buffer.length) {
134129
endOfStream = true;
135130
if (buffer.length == 0) {

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static java.util.concurrent.Executors.callable;
2121

2222
import com.google.api.services.storage.model.StorageObject;
23-
import com.google.gcloud.RetryHelper;
2423
import com.google.gcloud.spi.StorageRpc;
2524

2625
import java.io.IOException;
@@ -69,16 +68,12 @@ private void writeObject(ObjectOutputStream out) throws IOException {
6968
private void flush(boolean compact) {
7069
if (limit >= chunkSize || compact && limit >= MIN_CHUNK_SIZE) {
7170
final int length = limit - limit % MIN_CHUNK_SIZE;
72-
try {
73-
runWithRetries(callable(new Runnable() {
74-
@Override
75-
public void run() {
76-
storageRpc.write(uploadId, buffer, 0, storageObject, position, length, false);
77-
}
78-
}), options.retryParams(), StorageImpl.EXCEPTION_HANDLER);
79-
} catch (RetryHelper.RetryHelperException e) {
80-
throw StorageException.translateAndThrow(e);
81-
}
71+
runWithRetries(callable(new Runnable() {
72+
@Override
73+
public void run() {
74+
storageRpc.write(uploadId, buffer, 0, storageObject, position, length, false);
75+
}
76+
}), options.retryParams(), StorageImpl.EXCEPTION_HANDLER);
8277
position += length;
8378
limit -= length;
8479
byte[] temp = new byte[compact ? limit : chunkSize];
@@ -129,16 +124,12 @@ public boolean isOpen() {
129124
@Override
130125
public void close() throws IOException {
131126
if (isOpen) {
132-
try {
133-
runWithRetries(callable(new Runnable() {
134-
@Override
135-
public void run() {
136-
storageRpc.write(uploadId, buffer, 0, storageObject, position, limit, true);
137-
}
138-
}), options.retryParams(), StorageImpl.EXCEPTION_HANDLER);
139-
} catch (RetryHelper.RetryHelperException e) {
140-
throw StorageException.translateAndThrow(e);
141-
}
127+
runWithRetries(callable(new Runnable() {
128+
@Override
129+
public void run() {
130+
storageRpc.write(uploadId, buffer, 0, storageObject, position, limit, true);
131+
}
132+
}), options.retryParams(), StorageImpl.EXCEPTION_HANDLER);
142133
position += buffer.length;
143134
isOpen = false;
144135
buffer = null;

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageException.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package com.google.gcloud.storage;
1818

19-
import com.google.gcloud.RetryHelper;
20-
import com.google.gcloud.RetryHelper.RetryHelperException;
21-
2219
/**
2320
* Storage service exception.
2421
*
@@ -28,7 +25,6 @@
2825
public class StorageException extends RuntimeException {
2926

3027
private static final long serialVersionUID = -3748432005065428084L;
31-
private static final int UNKNOWN_CODE = -1;
3228

3329
private final int code;
3430
private final boolean retryable;
@@ -49,21 +45,4 @@ public int code() {
4945
public boolean retryable() {
5046
return retryable;
5147
}
52-
53-
/**
54-
* Translate RetryHelperException to the StorageException that caused the error. This method will
55-
* always throw an exception.
56-
*
57-
* @throws StorageException when {@code ex} was caused by a {@code StorageException}
58-
* @throws RetryInterruptedException when {@code ex} is a {@code RetryInterruptedException}
59-
*/
60-
static StorageException translateAndThrow(RetryHelperException ex) {
61-
if (ex.getCause() instanceof StorageException) {
62-
throw (StorageException) ex.getCause();
63-
}
64-
if (ex instanceof RetryHelper.RetryInterruptedException) {
65-
RetryHelper.RetryInterruptedException.propagate();
66-
}
67-
throw new StorageException(UNKNOWN_CODE, ex.getMessage(), false);
68-
}
6948
}

0 commit comments

Comments
 (0)