Skip to content

Commit 9f1eaab

Browse files
committed
---
yaml --- r: 923 b: refs/heads/master c: 36f2867 h: refs/heads/master i: 921: ec113d1 919: 3f5f348 v: v3
1 parent d19bde3 commit 9f1eaab

10 files changed

Lines changed: 274 additions & 143 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: f3a19a61fbc8e5c1d3a63e4b39e6b7d3dc399420
2+
refs/heads/master: 36f2867dbf16b82f9ab6d62db79d835d7470d095
33
refs/heads/travis: 0fa997e2fc9c6b61b2d91e6d163655aae67d44b6
44
refs/heads/gh-pages: 5a10432ecc75f29812e33a8236c900379509fe99

trunk/.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ jdk:
66
before_install:
77
- mvn clean
88
- git clone -b travis `git config --get remote.origin.url` target/travis
9-
- openssl aes-256-cbc -K $encrypted_631490ecae8f_key -iv $encrypted_631490ecae8f_iv -in target/travis/signing-tools.tar.enc -out target/travis/signing-tools.tar -d
10-
- mkdir target/travis/signing-tools
11-
- chmod 700 target/travis/signing-tools
12-
- tar xvf target/travis/signing-tools.tar -C target/travis/signing-tools
139
- cp target/travis/settings.xml ~/.m2/settings.xml
1410
install: mvn install -DskipTests=true -Dgpg.skip=true
1511
script: mvn verify
@@ -24,5 +20,3 @@ env:
2420
- secure: "CUM2l73KFm7U4eDsUKkh1WyEUzF3v94Ltvs7MnKU9olE1dNp3YmRBL9Lqhx3hSDqm/xv0ETQsPy29Fs2+VFkhQQxSley6iS/4trr2fioTB680txfXo/zDdmGSP1q1/U40fv1S+jvuBRAhDV5W+8dhWOGtzMH0tJp/TszeDGlmCY="
2521
- secure: "YBbdzseg5yDFpQIiMoc3P2BTmqef4o+KAvrLMEbobXjIkiglUQ7UHCoRWClX74fTKAwuC7JvK7o5xJGLnaY43jJADXrGtE8/d44HNJaieE67mNosDYtOiA0iI2uIRFCAnXJ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3ZYg9TeVRW3/fc0v4Cv+1/ZbA6iVCTWijYqeSNCWDAm685R3Twm0HcXodjUfanF+u8NLltjMeg3E3O9QskRBxo72zTP4sh30yap/ngkifTNI6AP5+S6dKgHc1Uinzm9o9p1LOIWn1xDhk5o17B5Uy5cw2B1wOlPFc8ZlrOzJAsC3KQEh1rq5sNXLkm2kevQQLsw1yjUagxjRSJBizh3OYaP5EFFr9iC80W7Is/OEvkAicFz8jswUpFKuKdnLdglOu5ZiQYQ2d4FQR2dq0GraOfUk0UVxw1RIW75eoUh8vfSPInWZkQ+kfa4OJEwhSR5jwURd76kYHaFyXwU7zgG3/JTePTSXGCfdWAbaKG43nEf6Kmz6my1VCQmwhWdrCNna/VD8YN49TKKlNj9b2A88mHmEqnHHL6xtvR7JqUF1I6WKmQqb9z1VCV9hHgVfPJro+PAer5Qrb6mFkSdg1JNv+aIIz3fEXX0SLbQyrRsWbnAR8kfO6wN4uT7RcGn/5q/vphxcUdU1klJ4bs/GQVFxWt12DfMmcMrqcf/M="

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ public void write(String uploadId, byte[] toWrite, int toWriteOffset, StorageObj
451451
long destOffset, int length, boolean last) throws StorageException {
452452
try {
453453
GenericUrl url = new GenericUrl(uploadId);
454-
HttpRequest httpRequest = storage.getRequestFactory().buildPutRequest(url,
454+
HttpRequest httpRequest = storage.getRequestFactory().buildPostRequest(url,
455455
new ByteArrayContent(null, toWrite, toWriteOffset, length));
456456
long limit = destOffset + length;
457457
StringBuilder range = new StringBuilder("bytes ");

trunk/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
@@ -34,8 +34,8 @@ enum Option {
3434
PREDEFINED_DEFAULT_OBJECT_ACL("predefinedDefaultObjectAcl"),
3535
IF_METAGENERATION_MATCH("ifMetagenerationMatch"),
3636
IF_METAGENERATION_NOT_MATCH("ifMetagenerationNotMatch"),
37-
IF_GENERATION_MATCH("ifGenerationMatch"),
38-
IF_GENERATION_NOT_MATCH("ifGenerationNotMatch"),
37+
IF_GENERATION_NOT_MATCH("ifGenerationMatch"),
38+
IF_GENERATION_MATCH("ifGenerationNotMatch"),
3939
IF_SOURCE_METAGENERATION_MATCH("ifSourceMetagenerationMatch"),
4040
IF_SOURCE_METAGENERATION_NOT_MATCH("ifSourceMetagenerationNotMatch"),
4141
IF_SOURCE_GENERATION_MATCH("ifSourceGenerationMatch"),

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

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

2121
import com.google.api.services.storage.model.StorageObject;
22+
import com.google.gcloud.RetryHelper;
2223
import com.google.gcloud.spi.StorageRpc;
2324

2425
import java.io.IOException;
@@ -119,12 +120,16 @@ public int read(ByteBuffer byteBuffer) throws IOException {
119120
return -1;
120121
}
121122
final int toRead = Math.max(byteBuffer.remaining(), chunkSize);
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);
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+
}
128133
if (toRead > buffer.length) {
129134
endOfStream = true;
130135
if (buffer.length == 0) {

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

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

2222
import com.google.api.services.storage.model.StorageObject;
23+
import com.google.gcloud.RetryHelper;
2324
import com.google.gcloud.spi.StorageRpc;
2425

2526
import java.io.IOException;
@@ -68,12 +69,16 @@ private void writeObject(ObjectOutputStream out) throws IOException {
6869
private void flush(boolean compact) {
6970
if (limit >= chunkSize || compact && limit >= MIN_CHUNK_SIZE) {
7071
final int length = limit - limit % MIN_CHUNK_SIZE;
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);
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+
}
7782
position += length;
7883
limit -= length;
7984
byte[] temp = new byte[compact ? limit : chunkSize];
@@ -124,12 +129,16 @@ public boolean isOpen() {
124129
@Override
125130
public void close() throws IOException {
126131
if (isOpen) {
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);
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+
}
133142
position += buffer.length;
134143
isOpen = false;
135144
buffer = null;

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

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

1717
package com.google.gcloud.storage;
1818

19+
import com.google.gcloud.RetryHelper;
20+
import com.google.gcloud.RetryHelper.RetryHelperException;
21+
1922
/**
2023
* Storage service exception.
2124
*
@@ -25,6 +28,7 @@
2528
public class StorageException extends RuntimeException {
2629

2730
private static final long serialVersionUID = -3748432005065428084L;
31+
private static final int UNKNOWN_CODE = -1;
2832

2933
private final int code;
3034
private final boolean retryable;
@@ -45,4 +49,21 @@ public int code() {
4549
public boolean retryable() {
4650
return retryable;
4751
}
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+
}
4869
}

0 commit comments

Comments
 (0)