Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE when listing buckets in empty project and blobs in empty bucket #183

Merged
merged 1 commit into from
Sep 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.google.api.services.storage.model.StorageObject;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
Expand Down Expand Up @@ -234,14 +235,16 @@ public Tuple<String, Iterable<com.google.api.services.storage.model.Bucket>> cal
}
}, serviceOptions.retryParams(), EXCEPTION_HANDLER);
String cursor = result.x();
return new BaseListResult<>(new BucketPageFetcher(serviceOptions, cursor, optionsMap), cursor,
Iterables.transform(result.y(),
Iterable<BucketInfo> buckets =
result.y() == null ? ImmutableList.<BucketInfo>of() : Iterables.transform(result.y(),

This comment was marked as spam.

This comment was marked as spam.

new Function<com.google.api.services.storage.model.Bucket, BucketInfo>() {
@Override
public BucketInfo apply(com.google.api.services.storage.model.Bucket bucketPb) {
return BucketInfo.fromPb(bucketPb);
}
}));
});
return new BaseListResult<>(new BucketPageFetcher(serviceOptions, cursor, optionsMap), cursor,
buckets);
}

@Override
Expand All @@ -259,14 +262,17 @@ public Tuple<String, Iterable<StorageObject>> call() {
}
}, serviceOptions.retryParams(), EXCEPTION_HANDLER);
String cursor = result.x();
return new BaseListResult<>(new BlobPageFetcher(bucket, serviceOptions, cursor, optionsMap), cursor,
Iterables.transform(result.y(),
Iterable<BlobInfo> blobs =
result.y() == null ? ImmutableList.<BlobInfo>of() : Iterables.transform(result.y(),
new Function<StorageObject, BlobInfo>() {

This comment was marked as spam.

@Override
public BlobInfo apply(StorageObject storageObject) {
return BlobInfo.fromPb(storageObject);
}
}));
});
return new BaseListResult<>(new BlobPageFetcher(bucket, serviceOptions, cursor, optionsMap),
cursor,

This comment was marked as spam.

This comment was marked as spam.

blobs);
}

@Override
Expand Down Expand Up @@ -434,7 +440,7 @@ public BlobReadChannel reader(String bucket, String blob, BlobSourceOption... op
return new BlobReadChannelImpl(options(), BlobInfo.of(bucket, blob), optionsMap);
}

@Override
@Override
public BlobWriteChannel writer(BlobInfo blobInfo, BlobTargetOption... options) {
final Map<StorageRpc.Option, ?> optionsMap = optionMap(blobInfo, options);
return new BlobWriterChannelImpl(options(), blobInfo, optionsMap);
Expand All @@ -461,12 +467,12 @@ public URL signUrl(BlobInfo blobInfo, long expiration, SignUrlOption... options)
stBuilder.append(HttpMethod.GET);
}
stBuilder.append('\n');
if (firstNonNull((Boolean) optionMap.get(SignUrlOption.Option.MD5) , false)) {
if (firstNonNull((Boolean) optionMap.get(SignUrlOption.Option.MD5), false)) {
checkArgument(blobInfo.md5() != null, "Blob is missing a value for md5");
stBuilder.append(blobInfo.md5());
}
stBuilder.append('\n');
if (firstNonNull((Boolean) optionMap.get(SignUrlOption.Option.CONTENT_TYPE) , false)) {
if (firstNonNull((Boolean) optionMap.get(SignUrlOption.Option.CONTENT_TYPE), false)) {
checkArgument(blobInfo.contentType() != null, "Blob is missing a value for content-type");
stBuilder.append(blobInfo.contentType());
}
Expand Down