diff --git a/src/main/java/com/qingstor/sdk/service/Bucket.java b/src/main/java/com/qingstor/sdk/service/Bucket.java index 405349b..08e0dd7 100644 --- a/src/main/java/com/qingstor/sdk/service/Bucket.java +++ b/src/main/java/com/qingstor/sdk/service/Bucket.java @@ -29,7 +29,9 @@ import com.qingstor.sdk.service.Types.*; import com.qingstor.sdk.utils.QSParamInvokeUtil; import com.qingstor.sdk.utils.QSStringUtil; +import java.io.Closeable; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Map; @@ -7125,7 +7127,7 @@ public String validateParam() { * field ResponseExpires Specified the Expires response header
* field VersionID Object version id
*/ - public static class GetObjectOutput extends OutputModel { + public static class GetObjectOutput extends OutputModel implements Closeable { /** The response body */ @@ -7270,6 +7272,13 @@ public void setBodyInputStream(InputStream bodyInputStream) { this.bodyInputStream = bodyInputStream; } + @Override + public void close() throws IOException { + if (bodyInputStream != null) { + bodyInputStream.close(); + } + } + /** * The Cache-Control general-header field is used to specify directives for caching * mechanisms in both requests and responses. @@ -8158,7 +8167,7 @@ public String validateParam() { * field ResponseContentType Specified the Content-Type response header
* field ResponseExpires Specified the Expires response header
*/ - public static class ImageProcessOutput extends OutputModel { + public static class ImageProcessOutput extends OutputModel implements Closeable { /** The response body */ private InputStream bodyInputStream; @@ -8182,6 +8191,13 @@ public void setBodyInputStream(InputStream bodyInputStream) { this.bodyInputStream = bodyInputStream; } + @Override + public void close() throws IOException { + if (bodyInputStream != null) { + bodyInputStream.close(); + } + } + /** Object content length */ private Long contentLength; diff --git a/src/test/java/integration/cucumber/ImageTest.java b/src/test/java/integration/cucumber/ImageTest.java index e79e54c..40bd7bb 100644 --- a/src/test/java/integration/cucumber/ImageTest.java +++ b/src/test/java/integration/cucumber/ImageTest.java @@ -49,5 +49,6 @@ public void image_process_status_code_is(int statusCode) throws Throwable { // Write code here that turns the phrase above into concrete actions System.out.println("image_process_message:" + imageProcessOutput.getMessage()); TestUtil.assertEqual(imageProcessOutput.getStatueCode(), statusCode); + imageProcessOutput.close(); } } diff --git a/template/shared.tmpl b/template/shared.tmpl index 39c43c1..017380c 100644 --- a/template/shared.tmpl +++ b/template/shared.tmpl @@ -804,7 +804,7 @@ * field {{$property.Name| camelCase}} {{replace $property.Description "/" "'bucket-name'/'object-key'" -1}}
{{- end}} */ - public static class {{$opID}}Output extends OutputModel{ + public static class {{$opID}}Output extends OutputModel {{if eq $opID "GetObject" "ImageProcess"}} implements Closeable {{- end}} { {{range $_, $response := $operation.Responses}} {{if eq $response.Body.Type "string"}} {{if $response.Body.Description -}} @@ -961,6 +961,14 @@ public void setBodyInputStream(InputStream bodyInputStream) { this.bodyInputStream=bodyInputStream; } + + @Override + public void close() throws IOException { + if (bodyInputStream != null) { + bodyInputStream.close(); + } + } + {{end}} {{if $response.Elements.Properties | len}} diff --git a/template/sub_services.tmpl b/template/sub_services.tmpl index f5786b2..6f087fd 100644 --- a/template/sub_services.tmpl +++ b/template/sub_services.tmpl @@ -3,8 +3,10 @@ package com.qingstor.sdk.service; +import java.io.Closeable; import java.io.File; import java.io.InputStream; +import java.io.IOException; import java.util.Date; import java.util.HashMap; import java.util.List;