Skip to content

Commit 13572e7

Browse files
committed
Fix Blob/Bucket load javadoc, return null if not found
1 parent 3011587 commit 13572e7

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public Blob(Storage storage, BlobInfo info) {
115115
* @param storage the storage service used for issuing requests
116116
* @param bucket bucket's name
117117
* @param blob blob's name
118+
* @return the {@code Blob} object or {@code null} if not found.
119+
* @throws StorageException upon failure
118120
*/
119121
public static Blob load(Storage storage, String bucket, String blob) {
120122
return load(storage, BlobId.of(bucket, blob));
@@ -126,10 +128,12 @@ public static Blob load(Storage storage, String bucket, String blob) {
126128
*
127129
* @param storage the storage service used for issuing requests
128130
* @param blobId blob's identifier
131+
* @return the {@code Blob} object or {@code null} if not found.
132+
* @throws StorageException upon failure
129133
*/
130134
public static Blob load(Storage storage, BlobId blobId) {
131135
BlobInfo info = storage.get(blobId);
132-
return new Blob(storage, info);
136+
return info != null ? new Blob(storage, info) : null;
133137
}
134138

135139
/**

gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ public Bucket(Storage storage, BucketInfo info) {
6161
*
6262
* @param storage the storage service used for issuing requests
6363
* @param bucket bucket's name
64+
* @return the {@code Bucket} object or {@code null} if not found.
65+
* @throws StorageException upon failure
6466
*/
6567
public static Bucket load(Storage storage, String bucket) {
6668
BucketInfo info = storage.get(bucket);
67-
return new Bucket(storage, info);
69+
return info != null ? new Bucket(storage, info) : null;
6870
}
6971

7072
/**

0 commit comments

Comments
 (0)