fix: fix a possible NPE that could happen when shutting down a grpc S… · googleapis/java-storage@56f5d0a · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit 56f5d0a

Browse files
authored
fix: fix a possible NPE that could happen when shutting down a grpc Storage instance (#3089)
1 parent 762ca13 commit 56f5d0a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static GrpcCallContext contextWithBucketName(String bucketName, GrpcCallContext
7272
static <C extends Closeable> void closeAll(Collection<C> closeables) throws IOException {
7373
IOException ioException =
7474
closeables.stream()
75+
.filter(Objects::nonNull)
7576
.map(
7677
stream -> {
7778
try {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.storage;
18+
19+
import java.io.IOException;
20+
import java.util.Collections;
21+
import org.junit.Test;
22+
23+
public final class GrpcUtilsTest {
24+
25+
@Test
26+
public void closeAll_noNpeIfNullStream() throws IOException {
27+
GrpcUtils.closeAll(Collections.singletonList(null));
28+
}
29+
}

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.