Repository: googleapis/google-http-java-client
Pull request #2038 (2024-11-19 20:52:10)

deps: update dependency io.grpc:grpc-context to v1.68.2
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [io.grpc:grpc-context](https://redirect.github.com/grpc/grpc-java) | `1.66.0` -> `1.68.2` | [![age](https://developer.mend.io/api/mc/badges/age/maven/io.grpc:grpc-context/1.68.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.grpc:grpc-context/1.68.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.grpc:grpc-context/1.66.0/1.68.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.grpc:grpc-context/1.66.0/1.68.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>grpc/grpc-java (io.grpc:grpc-context)</summary>

### [`v1.68.2`](https://redirect.github.com/grpc/grpc-java/releases/tag/v1.68.2)

[Compare Source](https://redirect.github.com/grpc/grpc-java/compare/v1.68.1...v1.68.2)

#### Bug Fixes

-   api: When forwarding from Listener onAddresses to Listener2 continue to use onResult ([https://github.com/grpc/grpc-java/pull/11688](https://redirect.github.com/grpc/grpc-java/pull/11688)). This fixes a 1.68.1 "IllegalStateException: Not called from the SynchronizationContext" regression ([#&#8203;11662](https://redirect.github.com/grpc/grpc-java/issues/11662)) that could be seen in certain custom NameResolvers
-   okhttp: If the frame handler thread is null do not schedule it on the executor ([https://github.com/grpc/grpc-java/pull/11716](https://redirect.github.com/grpc/grpc-java/pull/11716)). This fixes a 1.68.1 NullPointerException regression when a custom transportExecutor was provided to the channel and it did not have enough threads to run new tasks

#### Improvements

-   examples: Use xds-enabled server and xds credentials in example-gcp-csm-observability ([https://github.com/grpc/grpc-java/pull/11707](https://redirect.github.com/grpc/grpc-java/pull/11707))

### [`v1.68.1`](https://redirect.github.com/grpc/grpc-java/releases/tag/v1.68.1)

[Compare Source](https://redirect.github.com/grpc/grpc-java/compare/v1.68.0...v1.68.1)

##### gRPC Java 1.68.1 Release Notes

v1.68.0 was a mistake. This is the first release of version 1.68.x

##### Bug Fixes

-   xds: Fix NullPointerException introduced in "Fix load reporting when pick first is used for locality-routing" ([#&#8203;11553](https://redirect.github.com/grpc/grpc-java/issues/11553)). This was in 1.67.1 but not 1.68.0

##### Behavior Changes

-   core: JSON parsing rejects duplicate keys in objects ([#&#8203;11575](https://redirect.github.com/grpc/grpc-java/issues/11575)) ([`4be69e3`](https://redirect.github.com/grpc/grpc-java/commit/4be69e3f8)). This is the existing behavior in C core. Duplicate keys in objects are dangerous as which value takes effect is undefined. Previously, the last value was used
-   okhttp: Detect transport executors with no remaining threads ([#&#8203;11503](https://redirect.github.com/grpc/grpc-java/issues/11503)) ([`3a6be9c`](https://redirect.github.com/grpc/grpc-java/commit/3a6be9ca1)). The transport uses two threads, but one is on-demand. If the executor provided to `builder.transportExecutor()` runs out of threads (e.g., it is a fixed-size thread pool), *all* transports can be wedged, unable to run on-demand tasks, until keepalive kills one of them. Two threads are now used when handshaking a new transport, and the transport will time out after 1 second with “Timed out waiting for second handshake thread” if two threads are unavailable
-   gcp-csm-o11y: Get  `mesh_id` value from `CSM_MESH_ID` environment variable, instead of getting it from bootstrap file ([`84d30af`](https://redirect.github.com/grpc/grpc-java/commit/84d30afad))

##### Improvements

-   New grpc-context-override-opentelemetry artifact ([#&#8203;11523](https://redirect.github.com/grpc/grpc-java/issues/11523)) ([`782a44a`](https://redirect.github.com/grpc/grpc-java/commit/782a44ad6)) ([#&#8203;11599](https://redirect.github.com/grpc/grpc-java/issues/11599)) ([`e59ae5f`](https://redirect.github.com/grpc/grpc-java/commit/e59ae5fad)). This is a `io.grpc.Context` storage override to store its state in `io.opentelemetry.context.Context`. Libraries should not add a dependency on this artifact, as applications can only have one storage override in their classpath
-   New grpc-s2a artifact. It is a transport that offloads the handshake similar to ALTS, but for TLS. It provides `io.grpc.s2a.S2AChannelCredentials`
-   api: Enhance name resolver \`ResolutionResult\` to hold addresses or error so the single listener API *onResult2* is used to convey both success and error cases for name resolution ([#&#8203;11330](https://redirect.github.com/grpc/grpc-java/issues/11330)) ([`1ded8af`](https://redirect.github.com/grpc/grpc-java/commit/1ded8aff8))
-   core: Handle NameResolver/LoadBalancer exceptions when panicking ([`b692b9d`](https://redirect.github.com/grpc/grpc-java/commit/b692b9d26)). This expands the class of bugs that will fail RPCs with the panic error, versus some undefined behavior
-   core: Use the default service config in case of initial name resolver address resolution error ([#&#8203;11577](https://redirect.github.com/grpc/grpc-java/issues/11577)) ([`fa26a8b`](https://redirect.github.com/grpc/grpc-java/commit/fa26a8bc5))
-   core: `StreamTracer.inboundMessageRead()` now reports uncompressed message size when the message does not need compression ([#&#8203;11598](https://redirect.github.com/grpc/grpc-java/issues/11598)) ([`2aae68e`](https://redirect.github.com/grpc/grpc-java/commit/2aae68e11)). Previously it always reported `-1` (unknown)
-   netty: Avoid TCP_USER_TIMEOUT warning when explicitly specifying a non-epoll channel type to use ([#&#8203;11564](https://redirect.github.com/grpc/grpc-java/issues/11564)) ([`62f4098`](https://redirect.github.com/grpc/grpc-java/commit/62f409810))
-   okhttp: Don't warn about missing Conscrypt ([`6f35422`](https://redirect.github.com/grpc/grpc-java/commit/6f3542297)). This is especially helpful when using TLS but not running on Android
-   android: For `UdsChannelBuilder`, use fake IP instead of localhost ([`a908b5e`](https://redirect.github.com/grpc/grpc-java/commit/a908b5e40)). This avoids an unnecessary DNS lookup
-   xds: Add xDS node ID in select control plane errors to enable cross-referencing with control plane logs when debugging ([`f3cf7c3`](https://redirect.github.com/grpc/grpc-java/commit/f3cf7c3c7))
-   xds: Enhanced how ADS stream terminations are handled, specifically addressing cases where a response has or hasn't been received (#&#8203;2e9c3e19f)
-   binder: Update status code documentation for Android 11's package visibility rules. ([#&#8203;11551](https://redirect.github.com/grpc/grpc-java/issues/11551)) ([`99be6e9`](https://redirect.github.com/grpc/grpc-java/commit/99be6e985))
-   binder: Update binderDied() error description to spell out the possibilities for those unfamiliar with Android internals. ([#&#8203;11628](https://redirect.github.com/grpc/grpc-java/issues/11628)) ([`46c1b38`](https://redirect.github.com/grpc/grpc-java/commit/46c1b387f))
-   example-gauth: Use application default creds instead of file argument ([#&#8203;11595](https://redirect.github.com/grpc/grpc-java/issues/11595)) ([`94a0a0d`](https://redirect.github.com/grpc/grpc-java/commit/94a0a0d1c))
-   opentelemetry: Experimental OpenTelemetry tracing is available. Set the `GRPC_EXPERIMENTAL_ENABLE_OTEL_TRACING` environment variable to `true` to enable tracing support in `GrpcOpenTelemetry` ([#&#8203;11409](https://redirect.github.com/grpc/grpc-java/issues/11409), [#&#8203;11477](https://redirect.github.com/grpc/grpc-java/issues/11477))([`043ba55`](https://redirect.github.com/grpc/grpc-java/commit/043ba55), [`421e237`](https://redirect.github.com/grpc/grpc-java/commit/421e237))

##### Dependencies

-   Updated protobuf-java to 3.25.5. This helps avoid CVE-2024-7254 ([`2ff837a`](https://redirect.github.com/grpc/grpc-java/commit/2ff837ab6))

Thanks to:\
[@&#8203;Juneezee](https://redirect.github.com/Juneezee)\
[@&#8203;lgalfaso](https://redirect.github.com/lgalfaso)\
[@&#8203;bestbeforetoday](https://redirect.github.com/bestbeforetoday)\
[@&#8203;hlx502](https://redirect.github.com/hlx502)\
[@&#8203;JoeCqupt](https://redirect.github.com/JoeCqupt)

### [`v1.68.0`](https://redirect.github.com/grpc/grpc-java/releases/tag/v1.68.0): MISTAKE

[Compare Source](https://redirect.github.com/grpc/grpc-java/compare/v1.67.1...v1.68.0)

This was supposed to be v1.67.0, but there was a mistake during the release process. This has everything in v1.67.1, *except* for:

-   xds: Fix NullPointerException introduced in "Fix load reporting when pick first is used for locality-routing" ([https://github.com/grpc/grpc-java/pull/11553](https://redirect.github.com/grpc/grpc-java/pull/11553))

### [`v1.67.1`](https://redirect.github.com/grpc/grpc-java/releases/tag/v1.67.1)

[Compare Source](https://redirect.github.com/grpc/grpc-java/compare/v1.66.0...v1.67.1)

##### gRPC Java 1.67.1 Release Notes

There was no 1.67.0 release. There was a problem making the release and it went to Maven Central as 1.68.0 instead. This is a version-corrected release.

##### Improvements

-   Petiole load balancing policies (e.g., round_robin, weighted_round_robin, ring_hash, least_request) had internal refactorings. This should not have changed their behavior
-   api: Introduce onResult2 in NameResolver Listener2 that returns Status ([`90d0fab`](https://redirect.github.com/grpc/grpc-java/commit/90d0fabb1))
-   core: touch() buffer when detach()ing ([`e821d5e`](https://redirect.github.com/grpc/grpc-java/commit/e821d5e15)). This makes it clearer whether a leak is a gRPC leak or an application leak when the Detachable API is being used
-   example: delete duplicate and unused code in KeepAliveClient.java ([`6a9bc3b`](https://redirect.github.com/grpc/grpc-java/commit/6a9bc3ba1))
-   example: Added Dualstack example ([#&#8203;11451](https://redirect.github.com/grpc/grpc-java/issues/11451)) ([`72a977b`](https://redirect.github.com/grpc/grpc-java/commit/72a977bf7))
-   stub: Add newAttachMetadataServerInterceptor() MetadataUtil ([#&#8203;11458](https://redirect.github.com/grpc/grpc-java/issues/11458)) ([`6dbd1b9`](https://redirect.github.com/grpc/grpc-java/commit/6dbd1b9d5))
-   xds: Separate xds clients for each channel target, each with its own connection to an xds server. ([#&#8203;11484](https://redirect.github.com/grpc/grpc-java/issues/11484)) ([`d034a56`](https://redirect.github.com/grpc/grpc-java/commit/d034a56cb))
-   xds: Envoy proto sync to 2024-07-06 ([#&#8203;11401](https://redirect.github.com/grpc/grpc-java/issues/11401)) ([`96a788a`](https://redirect.github.com/grpc/grpc-java/commit/96a788a34))
-   xds: cncf/xds proto sync to 2024-07-24 ([#&#8203;11417](https://redirect.github.com/grpc/grpc-java/issues/11417)) ([`0017c98`](https://redirect.github.com/grpc/grpc-java/commit/0017c98f6))
-   xds: Import RLQS protos ([#&#8203;11418](https://redirect.github.com/grpc/grpc-java/issues/11418)) ([`c29763d`](https://redirect.github.com/grpc/grpc-java/commit/c29763d88))
-   xds: ClusterManagerLB must update child configuration ([`10d6002`](https://redirect.github.com/grpc/grpc-java/commit/10d6002cb)). Previously, RLS configuration would not have been updated

##### Bug Fixes

-   core: Revert "Enable new PickFirst LB ([#&#8203;11348](https://redirect.github.com/grpc/grpc-java/issues/11348))" ([#&#8203;11425](https://redirect.github.com/grpc/grpc-java/issues/11425)) ([`cc1cbe9`](https://redirect.github.com/grpc/grpc-java/commit/cc1cbe987))
-   rls: Fix log statements incorrectly referring to "LRS" ([#&#8203;11497](https://redirect.github.com/grpc/grpc-java/issues/11497)) ([`c63e354`](https://redirect.github.com/grpc/grpc-java/commit/c63e35488))
-   util: Stop using SocketAddress.toString() for checking address equality ([`f866c80`](https://redirect.github.com/grpc/grpc-java/commit/f866c805c)). This change applies to all petiole load balancing policies. For regular usages that use dns name resolution, this is unlikely to matter as the default dns name resolver returns consistent addresses. But this might improve LB behavior for some custom load balancers
-   xds: Fix load reporting when pick first is used for locality-routing. ([#&#8203;11495](https://redirect.github.com/grpc/grpc-java/issues/11495)) ([`1dae144`](https://redirect.github.com/grpc/grpc-java/commit/1dae144f0))
-   xds: Fix NullPointerException introduced in "Fix load reporting when pick first is used for locality-routing" ([#&#8203;11553](https://redirect.github.com/grpc/grpc-java/issues/11553)). This change is not present in 1.68.0
-   xds: XdsClient should unsubscribe on last resource ([#&#8203;11264](https://redirect.github.com/grpc/grpc-java/issues/11264)) ([`448ec4f`](https://redirect.github.com/grpc/grpc-java/commit/448ec4f37))

##### Dependencies

-   Upgrade Netty to 4.1.110 and tcnative to 2.0.65 ([#&#8203;11444](https://redirect.github.com/grpc/grpc-java/issues/11444)) ([`70ae832`](https://redirect.github.com/grpc/grpc-java/commit/70ae83288))
-   examples: Upgrade Maven plugin versions ([`75012a5`](https://redirect.github.com/grpc/grpc-java/commit/75012a5be))
-   Remove direct dependency on j2objc ([`ff8e413`](https://redirect.github.com/grpc/grpc-java/commit/ff8e41376))

##### Thanks to

[@&#8203;Juneezee](https://redirect.github.com/Juneezee)
[@&#8203;lujiajing1126](https://redirect.github.com/lujiajing1126)
[@&#8203;JarvisCraft](https://redirect.github.com/JarvisCraft)
[@&#8203;sunpe](https://redirect.github.com/sunpe)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/googleapis/google-http-java-client).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xOS4wIiwidXBkYXRlZEluVmVyIjoiMzkuMTkuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->


dpebot: /gcbrun
dpebot: /gcbrun
dpebot: /gcbrun

Patch:
diff --git a/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5HttpResponse.java b/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5HttpResponse.java
index 1574c8c8..ae3c2ffb 100644
--- a/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5HttpResponse.java
+++ b/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5HttpResponse.java
@@ -46,7 +46,8 @@ final class Apache5HttpResponse extends LowLevelHttpResponse {
 
   @Override
   public InputStream getContent() throws IOException {
-    return new Apache5ResponseContent(entity.getContent(), response);
+    InputStream content = entity == null ? null : entity.getContent();
+    return new Apache5ResponseContent(content, response);
   }
 
   @Override
diff --git a/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5ResponseContent.java b/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5ResponseContent.java
index c2d3091d..dfb6da8a 100644
--- a/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5ResponseContent.java
+++ b/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5ResponseContent.java
@@ -59,8 +59,12 @@ public class Apache5ResponseContent extends InputStream {
 
   @Override
   public void close() throws IOException {
-    wrappedStream.close();
-    response.close();
+    if (wrappedStream != null) {
+      wrappedStream.close();
+    }
+    if (response != null) {
+      response.close();
+    }
   }
 
   @Override
diff --git a/pom.xml b/pom.xml
index eb087eca..bd6c3d94 100644
--- a/pom.xml
+++ b/pom.xml
@@ -258,7 +258,7 @@
       <dependency>
         <groupId>io.grpc</groupId>
         <artifactId>grpc-context</artifactId>
-        <version>1.66.0</version>
+        <version>1.68.2</version>
       </dependency>
       <dependency>
         <groupId>io.opencensus</groupId>
@@ -610,7 +610,7 @@
       - Internally, update the default features.json file
     -->
     <project.http-client.version>1.45.1</project.http-client.version><!-- {x-version-update:google-http-client-parent:current} -->
-    <project.appengine.version>2.0.29</project.appengine.version>
+    <project.appengine.version>2.0.31</project.appengine.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.jsr305.version>3.0.2</project.jsr305.version>
     <project.gson.version>2.11.0</project.gson.version>


Test patch:
diff --git a/google-http-client-apache-v5/src/test/java/com/google/api/client/http/apache/v5/Apache5HttpResponseTest.java b/google-http-client-apache-v5/src/test/java/com/google/api/client/http/apache/v5/Apache5HttpResponseTest.java
new file mode 100644
index 00000000..d2712b35
--- /dev/null
+++ b/google-http-client-apache-v5/src/test/java/com/google/api/client/http/apache/v5/Apache5HttpResponseTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.api.client.http.apache.v5;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
+import org.junit.Test;
+
+public class Apache5HttpResponseTest {
+  @Test
+  public void testNullContent() throws Exception {
+    HttpUriRequestBase base = new HttpPost("http://www.google.com");
+    MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
+    mockResponse.setEntity(null);
+    Apache5HttpResponse response = new Apache5HttpResponse(base, mockResponse);
+
+    InputStream content = response.getContent();
+
+    assertNotNull(content);
+  }
+}
diff --git a/google-http-client-apache-v5/src/test/java/com/google/api/client/http/apache/v5/Apache5ResponseContentTest.java b/google-http-client-apache-v5/src/test/java/com/google/api/client/http/apache/v5/Apache5ResponseContentTest.java
new file mode 100644
index 00000000..ddbda0dd
--- /dev/null
+++ b/google-http-client-apache-v5/src/test/java/com/google/api/client/http/apache/v5/Apache5ResponseContentTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.api.client.http.apache.v5;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.junit.Test;
+
+public class Apache5ResponseContentTest {
+  @Test
+  public void testNullResponseContent_doesNotThrowExceptionOnClose() throws Exception {
+    Apache5ResponseContent response =
+        new Apache5ResponseContent(
+            new InputStream() {
+              @Override
+              public int read() throws IOException {
+                return 0;
+              }
+            },
+            null);
+
+    response.close();
+  }
+
+  @Test
+  public void testNullWrappedContent_doesNotThrowExceptionOnClose() throws Exception {
+    MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
+    Apache5ResponseContent response = new Apache5ResponseContent(null, mockResponse);
+
+    response.close();
+  }
+}