34
34
import com .google .api .services .storage .model .StorageObject ;
35
35
import com .google .common .base .Function ;
36
36
import com .google .common .base .Functions ;
37
+ import com .google .common .collect .ImmutableList ;
37
38
import com .google .common .collect .ImmutableMap ;
38
39
import com .google .common .collect .Iterables ;
39
40
import com .google .common .collect .Lists ;
@@ -234,14 +235,16 @@ public Tuple<String, Iterable<com.google.api.services.storage.model.Bucket>> cal
234
235
}
235
236
}, serviceOptions .retryParams (), EXCEPTION_HANDLER );
236
237
String cursor = result .x ();
237
- return new BaseListResult <>( new BucketPageFetcher ( serviceOptions , cursor , optionsMap ), cursor ,
238
- Iterables .transform (result .y (),
238
+ Iterable < BucketInfo > buckets =
239
+ result . y () == null ? ImmutableList .< BucketInfo > of () : Iterables .transform (result .y (),
239
240
new Function <com .google .api .services .storage .model .Bucket , BucketInfo >() {
240
241
@ Override
241
242
public BucketInfo apply (com .google .api .services .storage .model .Bucket bucketPb ) {
242
243
return BucketInfo .fromPb (bucketPb );
243
244
}
244
- }));
245
+ });
246
+ return new BaseListResult <>(new BucketPageFetcher (serviceOptions , cursor , optionsMap ), cursor ,
247
+ buckets );
245
248
}
246
249
247
250
@ Override
@@ -259,14 +262,17 @@ public Tuple<String, Iterable<StorageObject>> call() {
259
262
}
260
263
}, serviceOptions .retryParams (), EXCEPTION_HANDLER );
261
264
String cursor = result .x ();
262
- return new BaseListResult <>( new BlobPageFetcher ( bucket , serviceOptions , cursor , optionsMap ), cursor ,
263
- Iterables .transform (result .y (),
265
+ Iterable < BlobInfo > blobs =
266
+ result . y () == null ? ImmutableList .< BlobInfo > of () : Iterables .transform (result .y (),
264
267
new Function <StorageObject , BlobInfo >() {
265
268
@ Override
266
269
public BlobInfo apply (StorageObject storageObject ) {
267
270
return BlobInfo .fromPb (storageObject );
268
271
}
269
- }));
272
+ });
273
+ return new BaseListResult <>(new BlobPageFetcher (bucket , serviceOptions , cursor , optionsMap ),
274
+ cursor ,
275
+ blobs );
270
276
}
271
277
272
278
@ Override
@@ -434,7 +440,7 @@ public BlobReadChannel reader(String bucket, String blob, BlobSourceOption... op
434
440
return new BlobReadChannelImpl (options (), BlobInfo .of (bucket , blob ), optionsMap );
435
441
}
436
442
437
- @ Override
443
+ @ Override
438
444
public BlobWriteChannel writer (BlobInfo blobInfo , BlobTargetOption ... options ) {
439
445
final Map <StorageRpc .Option , ?> optionsMap = optionMap (blobInfo , options );
440
446
return new BlobWriterChannelImpl (options (), blobInfo , optionsMap );
@@ -461,12 +467,12 @@ public URL signUrl(BlobInfo blobInfo, long expiration, SignUrlOption... options)
461
467
stBuilder .append (HttpMethod .GET );
462
468
}
463
469
stBuilder .append ('\n' );
464
- if (firstNonNull ((Boolean ) optionMap .get (SignUrlOption .Option .MD5 ) , false )) {
470
+ if (firstNonNull ((Boolean ) optionMap .get (SignUrlOption .Option .MD5 ), false )) {
465
471
checkArgument (blobInfo .md5 () != null , "Blob is missing a value for md5" );
466
472
stBuilder .append (blobInfo .md5 ());
467
473
}
468
474
stBuilder .append ('\n' );
469
- if (firstNonNull ((Boolean ) optionMap .get (SignUrlOption .Option .CONTENT_TYPE ) , false )) {
475
+ if (firstNonNull ((Boolean ) optionMap .get (SignUrlOption .Option .CONTENT_TYPE ), false )) {
470
476
checkArgument (blobInfo .contentType () != null , "Blob is missing a value for content-type" );
471
477
stBuilder .append (blobInfo .contentType ());
472
478
}
0 commit comments