Repository: googleapis/google-http-java-client
Pull request #2027 (2024-11-19 20:51:35)

deps: update project.appengine.version to v2.0.31
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.appengine:appengine-api-stubs](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard) | `2.0.29` -> `2.0.31` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.appengine:appengine-api-stubs/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.appengine:appengine-api-stubs/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.appengine:appengine-api-stubs/2.0.29/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.appengine:appengine-api-stubs/2.0.29/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [com.google.appengine:appengine-testing](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard) | `2.0.29` -> `2.0.31` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.appengine:appengine-testing/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.appengine:appengine-testing/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.appengine:appengine-testing/2.0.29/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.appengine:appengine-testing/2.0.29/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [com.google.appengine:appengine-api-1.0-sdk](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard) | `2.0.29` -> `2.0.31` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.29/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.appengine:appengine-api-1.0-sdk/2.0.29/2.0.31?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>GoogleCloudPlatform/appengine-java-standard (com.google.appengine:appengine-api-stubs)</summary>

### [`v2.0.31`](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/releases/tag/v2.0.31)

[Compare Source](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/compare/v2.0.30...v2.0.31)

##### What's Changed

-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/276](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/276)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/280](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/280)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/281](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/281)

**Full Changelog**: https://github.com/GoogleCloudPlatform/appengine-java-standard/compare/v2.0.30...v2.0.31

### [`v2.0.30`](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/releases/tag/v2.0.30)

[Compare Source](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/compare/v2.0.29...v2.0.30)

##### What's Changed

-   AppEngineAuthenticator does need to extend LoginAuthenticator for EE10 by [@&#8203;lachlan-roberts](https://redirect.github.com/lachlan-roberts) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/247](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/247)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/248](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/248)
-   Issue [#&#8203;251](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/issues/251) - mark baseRequest as secure for HttpConnector mode with Jetty9.4 runtimes by [@&#8203;lachlan-roberts](https://redirect.github.com/lachlan-roberts) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/252](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/252)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/253](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/253)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/254](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/254)
-   Update all non-major dependencies to v12.0.12 by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/255](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/255)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/256](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/256)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/259](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/259)
-   Initialize HttpChannel in DelegateConnection to create Violation Listeners by [@&#8203;lachlan-roberts](https://redirect.github.com/lachlan-roberts) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/260](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/260)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/261](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/261)
-   add markdown file to help with debugging by [@&#8203;lachlan-roberts](https://redirect.github.com/lachlan-roberts) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/263](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/263)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/265](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/265)
-   ensure flushOnResponseCommit is true for session caches by [@&#8203;lachlan-roberts](https://redirect.github.com/lachlan-roberts) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/267](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/267)
-   lazy initialization of AppEngineWebAppContext for HttpConnector mode by [@&#8203;lachlan-roberts](https://redirect.github.com/lachlan-roberts) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/271](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/271)
-   Update all non-major dependencies by [@&#8203;renovate-bot](https://redirect.github.com/renovate-bot) in [https://github.com/GoogleCloudPlatform/appengine-java-standard/pull/273](https://redirect.github.com/GoogleCloudPlatform/appengine-java-standard/pull/273)

**Full Changelog**: https://github.com/GoogleCloudPlatform/appengine-java-standard/compare/v2.0.29...v2.0.30

</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 these updates 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

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..109bd3df 100644
--- a/pom.xml
+++ b/pom.xml
@@ -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();
+  }
+}