diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache index bc9a8833c12d..e9e12ce7bd2b 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache @@ -65,7 +65,7 @@ import java.util.concurrent.CompletableFuture; {{>generatedAnnotation}} {{#operations}} -public class {{classname}} { +public class {{classname}} implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -955,5 +955,20 @@ public class {{classname}} { {{/hasParams}} {{/vendorExtensions.x-group-parameters}} {{/operation}} + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } {{/operations}} \ No newline at end of file diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java index bd330607f637..d995acd9923d 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java @@ -45,7 +45,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class AuthApi { +public class AuthApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -367,4 +367,19 @@ private HttpRequest.Builder testAuthHttpBearerRequestBuilder(Map return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java index 4b3a88d46280..03c141a2a6d2 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/BodyApi.java @@ -55,7 +55,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class BodyApi { +public class BodyApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1376,4 +1376,19 @@ private HttpRequest.Builder testEchoBodyTagResponseStringRequestBuilder(@javax.a return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java index 29b40e5c6c7a..abe687cf3ca8 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/FormApi.java @@ -52,7 +52,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FormApi { +public class FormApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -607,4 +607,19 @@ private HttpRequest.Builder testFormOneofRequestBuilder(@javax.annotation.Nullab return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/HeaderApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/HeaderApi.java index 84bf5bc73ba3..2903d9a56877 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/HeaderApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/HeaderApi.java @@ -52,7 +52,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class HeaderApi { +public class HeaderApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -306,4 +306,19 @@ private HttpRequest.Builder testHeaderIntegerBooleanStringEnumsRequestBuilder(@j return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/PathApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/PathApi.java index bad5e1e95325..8e00c4c9504d 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/PathApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/PathApi.java @@ -52,7 +52,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class PathApi { +public class PathApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -307,4 +307,19 @@ private HttpRequest.Builder testsPathStringPathStringIntegerPathIntegerEnumNonre return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java index e35b535834e9..401053070fbc 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java @@ -58,7 +58,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class QueryApi { +public class QueryApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1567,4 +1567,19 @@ private HttpRequest.Builder testQueryStyleJsonSerializationObjectRequestBuilder( return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index f0e67fd8b910..46d4445fa757 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -48,7 +48,7 @@ import java.util.concurrent.CompletableFuture; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class AnotherFakeApi { +public class AnotherFakeApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -297,4 +297,19 @@ private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotati return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/DefaultApi.java index cc59ce24aca9..7299f841b693 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -48,7 +48,7 @@ import java.util.concurrent.CompletableFuture; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class DefaultApi { +public class DefaultApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -283,4 +283,19 @@ private HttpRequest.Builder fooGetRequestBuilder(Map headers) th return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java index 1362de4f52db..bb29de4e2bc9 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java @@ -65,7 +65,7 @@ import java.util.concurrent.CompletableFuture; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FakeApi { +public class FakeApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -3051,4 +3051,19 @@ private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotati return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 738f9fb75aa0..b19af910281f 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -54,7 +54,7 @@ import java.util.concurrent.CompletableFuture; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FakeClassnameTags123Api { +public class FakeClassnameTags123Api implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -303,4 +303,19 @@ private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnul return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java index 2069a0e69fee..7fd046a0c7c3 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java @@ -56,7 +56,7 @@ import java.util.concurrent.CompletableFuture; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class PetApi { +public class PetApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1429,4 +1429,19 @@ private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.anno return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/StoreApi.java index 3ebe91accd79..a33900a1f7dc 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/StoreApi.java @@ -54,7 +54,7 @@ import java.util.concurrent.CompletableFuture; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class StoreApi { +public class StoreApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -660,4 +660,19 @@ private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull O return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java index 701e2d166b43..bcc60d50fe12 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java @@ -55,7 +55,7 @@ import java.util.concurrent.CompletableFuture; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class UserApi { +public class UserApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1142,4 +1142,19 @@ private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull S return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java index 15e1d2bf65a1..38a893bf0898 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java @@ -47,7 +47,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FileApi { +public class FileApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -281,4 +281,19 @@ private HttpRequest.Builder fileIdGetRequestBuilder(String id, Map{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FooApi.java b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FooApi.java index cc8ff7d3a886..273b3a571025 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FooApi.java +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FooApi.java @@ -49,7 +49,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FooApi { +public class FooApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -308,4 +308,19 @@ private HttpRequest.Builder fooDtParamGetRequestBuilder(java.time.@Nullable Inst return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java index 0209382a5611..8abae28350ec 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java @@ -47,7 +47,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class RequiredAndNullableApi { +public class RequiredAndNullableApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -286,4 +286,19 @@ private HttpRequest.Builder requiredAndNullablePostRequestBuilder(RequiredAndNul return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/UploadApi.java b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/UploadApi.java index 71362edfe174..5a8aaff1a26e 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/UploadApi.java +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/UploadApi.java @@ -54,7 +54,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class UploadApi { +public class UploadApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -438,4 +438,19 @@ private HttpRequest.Builder uploadPostRequestBuilder(@Nullable File _file, Map{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 5ed1f4e3cfde..a782d4bef1ee 100644 --- a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -47,7 +47,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class AnotherFakeApi { +public class AnotherFakeApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -286,4 +286,19 @@ private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotati return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/DefaultApi.java index f6e4d43894ab..94c4defadd24 100644 --- a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -47,7 +47,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class DefaultApi { +public class DefaultApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -272,4 +272,19 @@ private HttpRequest.Builder fooGetRequestBuilder(Map headers) th return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/FakeApi.java index 616320a9bb0a..42a451821a44 100644 --- a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/FakeApi.java @@ -64,7 +64,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FakeApi { +public class FakeApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -2878,4 +2878,19 @@ private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotati return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index edf8566ddaf3..d2f3a5c3e2a1 100644 --- a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -53,7 +53,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FakeClassnameTags123Api { +public class FakeClassnameTags123Api implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -292,4 +292,19 @@ private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnul return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/PetApi.java index a6a912dba95e..55b42525c3f4 100644 --- a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/PetApi.java @@ -55,7 +55,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class PetApi { +public class PetApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1350,4 +1350,19 @@ private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.anno return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/StoreApi.java index ae9774007059..d972395f349e 100644 --- a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/StoreApi.java @@ -53,7 +53,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class StoreApi { +public class StoreApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -623,4 +623,19 @@ private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull O return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/UserApi.java index 4661cd9bce3c..9eb44fd91c9e 100644 --- a/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native-jackson3/src/main/java/org/openapitools/client/api/UserApi.java @@ -54,7 +54,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class UserApi { +public class UserApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1074,4 +1074,19 @@ private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull S return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java index f0f859337a3d..6bf82622c7fe 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java @@ -54,7 +54,7 @@ import java.util.function.Consumer; @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class PetApi { +public class PetApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1218,4 +1218,19 @@ private HttpRequest.Builder uploadFileRequestBuilder(@jakarta.annotation.Nonnull return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java index 6bad55659cc9..9470d0da7652 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java @@ -52,7 +52,7 @@ import java.util.function.Consumer; @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class StoreApi { +public class StoreApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -622,4 +622,19 @@ private HttpRequest.Builder placeOrderRequestBuilder(@jakarta.annotation.Nonnull return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java index 6ca1975fb1d3..9b63c5fe522c 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java @@ -53,7 +53,7 @@ import java.util.function.Consumer; @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class UserApi { +public class UserApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1073,4 +1073,19 @@ private HttpRequest.Builder updateUserRequestBuilder(@jakarta.annotation.Nonnull return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native-useGzipFeature/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-useGzipFeature/src/main/java/org/openapitools/client/api/PetApi.java index 7bb13aefb65e..fef3e5fdf84c 100644 --- a/samples/client/petstore/java/native-useGzipFeature/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-useGzipFeature/src/main/java/org/openapitools/client/api/PetApi.java @@ -47,7 +47,7 @@ import java.util.function.Supplier; @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class PetApi { +public class PetApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -289,4 +289,19 @@ private HttpRequest.Builder addPetRequestBuilder(@jakarta.annotation.Nonnull Pet return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index c4a50c649bf7..4b78f076304d 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -46,7 +46,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class AnotherFakeApi { +public class AnotherFakeApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -285,4 +285,19 @@ private HttpRequest.Builder call123testSpecialTagsRequestBuilder(@javax.annotati return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java index c992098e1f09..1f0d27c7c054 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -46,7 +46,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class DefaultApi { +public class DefaultApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -271,4 +271,19 @@ private HttpRequest.Builder fooGetRequestBuilder(Map headers) th return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java index 1e62b57aaaf7..6465d568c4bb 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java @@ -63,7 +63,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FakeApi { +public class FakeApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -2877,4 +2877,19 @@ private HttpRequest.Builder testStringMapReferenceRequestBuilder(@javax.annotati return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index f8d7893fc79c..34de6aac1dbb 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -52,7 +52,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class FakeClassnameTags123Api { +public class FakeClassnameTags123Api implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -291,4 +291,19 @@ private HttpRequest.Builder testClassnameRequestBuilder(@javax.annotation.Nonnul return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java index 315e3cf68a95..2471bc42da95 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java @@ -54,7 +54,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class PetApi { +public class PetApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1349,4 +1349,19 @@ private HttpRequest.Builder uploadFileWithRequiredFileRequestBuilder(@javax.anno return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java index ec93ee23484a..01eadd8e3407 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/StoreApi.java @@ -52,7 +52,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class StoreApi { +public class StoreApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -622,4 +622,19 @@ private HttpRequest.Builder placeOrderRequestBuilder(@javax.annotation.Nonnull O return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java index 63704487316a..d68182bb7c93 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java @@ -53,7 +53,7 @@ import java.util.function.Consumer; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") -public class UserApi { +public class UserApi implements AutoCloseable { /** * Utility class for extending HttpRequest.Builder functionality. */ @@ -1073,4 +1073,19 @@ private HttpRequest.Builder updateUserRequestBuilder(@javax.annotation.Nonnull S return localVarRequestBuilder; } + /** + * Closes the {@link HttpClient} that this instance created from the {@link ApiClient} + * it was constructed with. {@code ApiClient.getHttpClient()} builds a new client on + * every call, so the client held here is owned exclusively by this instance and is not + * shared with any other API instance. + * + *

{@link HttpClient} only became {@link AutoCloseable} in Java 21, hence the guard; + * on earlier runtimes there is no way to release the client's threads early. + */ + @Override + public void close() throws Exception { + if (memberVarHttpClient instanceof AutoCloseable) { + ((AutoCloseable) memberVarHttpClient).close(); + } + } }