Skip to content

Commit fdd30fe

Browse files
committed
---
yaml --- r: 5973 b: refs/heads/tswast-patch-1 c: 01d873e h: refs/heads/master i: 5971: d20e817
1 parent 4bc4513 commit fdd30fe

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: e84ff219c770d8fe6e9f9dde337208cff9fd3027
60+
refs/heads/tswast-patch-1: 01d873ef0e5d9c1eb285fe9d33259ab2b0e3e9c8
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/src/main/java/com/google/gcloud/examples/StorageExample.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.util.Arrays;
4141
import java.util.HashMap;
4242
import java.util.Map;
43+
import java.util.Random;
4344

4445
/**
4546
* An example of using the Google Cloud Storage.
@@ -194,12 +195,17 @@ private static class UploadAction extends StorageAction<Tuple<Path, Blob>> {
194195
@Override
195196
public void run(StorageService storage, Tuple<Path, Blob> tuple) throws Exception {
196197
if (Files.size(tuple.x()) > 1024) {
198+
Random rnd = new Random();
197199
try (BlobWriteChannel writer = storage.writer(tuple.y())) {
198200
byte[] buffer = new byte[1024];
199201
try (InputStream input = Files.newInputStream(tuple.x())) {
200202
int limit;
201203
while ((limit = input.read(buffer)) >= 0) {
202-
writer.write(ByteBuffer.wrap(buffer, 0, limit));
204+
try {
205+
writer.write(ByteBuffer.wrap(buffer, 0, limit));
206+
} catch (Exception ex) {
207+
ex.printStackTrace();
208+
}
203209
}
204210
}
205211
}

0 commit comments

Comments
 (0)