Skip to content

Commit

Permalink
fix memory leak bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yndu13 committed Nov 10, 2023
1 parent ad1a154 commit 93e99d9
Show file tree
Hide file tree
Showing 19 changed files with 1,138 additions and 50 deletions.
2 changes: 2 additions & 0 deletions csharp/core/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ public Dictionary<string, object> DoRequest(Params params_, OpenApiRequest reque
}
else
{
AlibabaCloud.TeaUtil.Common.ReadAsString(response_.Body);
return new Dictionary<string, object>
{
{"headers", response_.Headers},
Expand Down Expand Up @@ -1987,6 +1988,7 @@ public async Task<Dictionary<string, object>> DoRequestAsync(Params params_, Ope
}
else
{
AlibabaCloud.TeaUtil.Common.ReadAsString(response_.Body);
return new Dictionary<string, object>
{
{"headers", response_.Headers},
Expand Down
4 changes: 2 additions & 2 deletions csharp/core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly : AssemblyVersion("0.1.6.0")]
[assembly : AssemblyFileVersion("0.1.6.0")]
[assembly : AssemblyVersion("0.1.7.0")]
[assembly : AssemblyFileVersion("0.1.7.0")]
4 changes: 2 additions & 2 deletions csharp/core/client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="AlibabaCloud.TeaUtil" Version="0.1.15"/>
<PackageReference Include="AlibabaCloud.TeaUtil" Version="0.1.17"/>
<PackageReference Include="Aliyun.Credentials" Version="1.3.2"/>
<PackageReference Include="AlibabaCloud.OpenApiUtil" Version="1.1.1"/>
<PackageReference Include="Tea" Version="1.0.11"/>
<PackageReference Include="AlibabaCloud.GatewaySpi" Version="0.0.2"/>
<PackageReference Include="AlibabaCloud.TeaXML" Version="0.0.3"/>
<PackageReference Include="AlibabaCloud.TeaXML" Version="0.0.5"/>
</ItemGroup>
</Project>
7 changes: 5 additions & 2 deletions golang/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
package client

import (
"io"

spi "github.com/alibabacloud-go/alibabacloud-gateway-spi/client"
openapiutil "github.com/alibabacloud-go/openapi-util/service"
util "github.com/alibabacloud-go/tea-utils/v2/service"
xml "github.com/alibabacloud-go/tea-xml/service"
"github.com/alibabacloud-go/tea/tea"
credential "github.com/aliyun/credentials-go/credentials"
"io"
)

type GlobalParameters struct {
Expand Down Expand Up @@ -1476,6 +1475,10 @@ func (client *Client) DoRequest(params *Params, request *OpenApiRequest, runtime
}, &_result)
return _result, _err
} else {
_, _err = util.ReadAsString(response_.Body)
if _err != nil {
return _result, _err
}
_result = make(map[string]interface{})
_err = tea.Convert(map[string]interface{}{
"headers": response_.Headers,
Expand Down
107 changes: 69 additions & 38 deletions java/src/main/java/com/aliyun/teaopenapi/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public class Client {
public String _endpointRule;
public java.util.Map<String, String> _endpointMap;
public String _suffix;
public String _key;
public String _cert;
public String _ca;
public Integer _readTimeout;
public Integer _connectTimeout;
public String _httpProxy;
Expand All @@ -41,6 +38,9 @@ public class Client {
public java.util.Map<String, String> _headers;
public com.aliyun.gateway.spi.Client _spi;
public GlobalParameters _globalParameters;
public String _key;
public String _cert;
public String _ca;
/**
* Init client with Config
* @param config config contains the necessary information to create a client
Expand Down Expand Up @@ -79,9 +79,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
this._method = config.method;
this._regionId = config.regionId;
this._userAgent = config.userAgent;
this._key = config.key;
this._cert = config.cert;
this._ca = config.ca;
this._readTimeout = config.readTimeout;
this._connectTimeout = config.connectTimeout;
this._httpProxy = config.httpProxy;
Expand All @@ -93,8 +90,23 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
this._signatureVersion = config.signatureVersion;
this._signatureAlgorithm = config.signatureAlgorithm;
this._globalParameters = config.globalParameters;
this._key = config.key;
this._cert = config.cert;
this._ca = config.ca;
}

/**
* Encapsulate the request and invoke the network
* @param action api name
* @param version product version
* @param protocol http or https
* @param method e.g. GET
* @param authType authorization type e.g. AK
* @param bodyType response body type e.g. String
* @param request object of OpenApiRequest
* @param runtime which controls some details of call api, such as retry times
* @return the response
*/
public java.util.Map<String, ?> doRPCRequest(String action, String version, String protocol, String method, String authType, String bodyType, OpenApiRequest request, com.aliyun.teautil.models.RuntimeOptions runtime) throws Exception {
TeaModel.validateParams(request, "request");
java.util.Map<String, Object> runtime_ = TeaConverter.buildMap(
Expand Down Expand Up @@ -123,7 +135,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {

TeaRequest _lastRequest = null;
Exception _lastException = null;
TeaResponse _lastResponse = null;
long _now = System.currentTimeMillis();
int _retryTimes = 0;
while (Tea.allowRetry((java.util.Map<String, Object>) runtime_.get("retry"), _retryTimes, _now)) {
Expand Down Expand Up @@ -221,7 +232,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {

_lastRequest = request_;
TeaResponse response_ = Tea.doAction(request_, runtime_, interceptorChain);
_lastResponse = response_;

if (com.aliyun.teautil.Common.is4xx(response_.statusCode) || com.aliyun.teautil.Common.is5xx(response_.statusCode)) {
Object _res = com.aliyun.teautil.Common.readAsJSON(response_.body);
Expand Down Expand Up @@ -286,17 +296,24 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
continue;
}
throw e;
} finally {
if (!com.aliyun.teautil.Common.isUnset(_lastResponse)
&& !com.aliyun.teautil.Common.isUnset(_lastResponse.response)
&& !com.aliyun.teautil.Common.isUnset(_lastResponse.response.body())){
_lastResponse.response.close();
}
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}

/**
* Encapsulate the request and invoke the network
* @param action api name
* @param version product version
* @param protocol http or https
* @param method e.g. GET
* @param authType authorization type e.g. AK
* @param pathname pathname of every api
* @param bodyType response body type e.g. String
* @param request object of OpenApiRequest
* @param runtime which controls some details of call api, such as retry times
* @return the response
*/
public java.util.Map<String, ?> doROARequest(String action, String version, String protocol, String method, String authType, String pathname, String bodyType, OpenApiRequest request, com.aliyun.teautil.models.RuntimeOptions runtime) throws Exception {
TeaModel.validateParams(request, "request");
java.util.Map<String, Object> runtime_ = TeaConverter.buildMap(
Expand Down Expand Up @@ -325,7 +342,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {

TeaRequest _lastRequest = null;
Exception _lastException = null;
TeaResponse _lastResponse = null;
long _now = System.currentTimeMillis();
int _retryTimes = 0;
while (Tea.allowRetry((java.util.Map<String, Object>) runtime_.get("retry"), _retryTimes, _now)) {
Expand Down Expand Up @@ -398,7 +414,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {

_lastRequest = request_;
TeaResponse response_ = Tea.doAction(request_, runtime_, interceptorChain);
_lastResponse = response_;

if (com.aliyun.teautil.Common.equalNumber(response_.statusCode, 204)) {
return TeaConverter.buildMap(
Expand Down Expand Up @@ -470,17 +485,24 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
continue;
}
throw e;
} finally {
if (!com.aliyun.teautil.Common.isUnset(_lastResponse)
&& !com.aliyun.teautil.Common.isUnset(_lastResponse.response)
&& !com.aliyun.teautil.Common.isUnset(_lastResponse.response.body())){
_lastResponse.response.close();
}
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}

/**
* Encapsulate the request and invoke the network with form body
* @param action api name
* @param version product version
* @param protocol http or https
* @param method e.g. GET
* @param authType authorization type e.g. AK
* @param pathname pathname of every api
* @param bodyType response body type e.g. String
* @param request object of OpenApiRequest
* @param runtime which controls some details of call api, such as retry times
* @return the response
*/
public java.util.Map<String, ?> doROARequestWithForm(String action, String version, String protocol, String method, String authType, String pathname, String bodyType, OpenApiRequest request, com.aliyun.teautil.models.RuntimeOptions runtime) throws Exception {
TeaModel.validateParams(request, "request");
java.util.Map<String, Object> runtime_ = TeaConverter.buildMap(
Expand Down Expand Up @@ -509,7 +531,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {

TeaRequest _lastRequest = null;
Exception _lastException = null;
TeaResponse _lastResponse = null;
long _now = System.currentTimeMillis();
int _retryTimes = 0;
while (Tea.allowRetry((java.util.Map<String, Object>) runtime_.get("retry"), _retryTimes, _now)) {
Expand Down Expand Up @@ -583,7 +604,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {

_lastRequest = request_;
TeaResponse response_ = Tea.doAction(request_, runtime_, interceptorChain);
_lastResponse = response_;

if (com.aliyun.teautil.Common.equalNumber(response_.statusCode, 204)) {
return TeaConverter.buildMap(
Expand Down Expand Up @@ -653,17 +673,23 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
continue;
}
throw e;
} finally {
if (!com.aliyun.teautil.Common.isUnset(_lastResponse)
&& !com.aliyun.teautil.Common.isUnset(_lastResponse.response)
&& !com.aliyun.teautil.Common.isUnset(_lastResponse.response.body())){
_lastResponse.response.close();
}
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}

/**
* Encapsulate the request and invoke the network
* @param action api name
* @param version product version
* @param protocol http or https
* @param method e.g. GET
* @param authType authorization type e.g. AK
* @param bodyType response body type e.g. String
* @param request object of OpenApiRequest
* @param runtime which controls some details of call api, such as retry times
* @return the response
*/
public java.util.Map<String, ?> doRequest(Params params, OpenApiRequest request, com.aliyun.teautil.models.RuntimeOptions runtime) throws Exception {
TeaModel.validateParams(params, "params");
TeaModel.validateParams(request, "request");
Expand Down Expand Up @@ -693,7 +719,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {

TeaRequest _lastRequest = null;
Exception _lastException = null;
TeaResponse _lastResponse = null;
long _now = System.currentTimeMillis();
int _retryTimes = 0;
while (Tea.allowRetry((java.util.Map<String, Object>) runtime_.get("retry"), _retryTimes, _now)) {
Expand Down Expand Up @@ -801,7 +826,6 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {

_lastRequest = request_;
TeaResponse response_ = Tea.doAction(request_, runtime_, interceptorChain);
_lastResponse = response_;

if (com.aliyun.teautil.Common.is4xx(response_.statusCode) || com.aliyun.teautil.Common.is5xx(response_.statusCode)) {
java.util.Map<String, Object> err = new java.util.HashMap<>();
Expand Down Expand Up @@ -861,6 +885,7 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
new TeaPair("statusCode", response_.statusCode)
);
} else {
com.aliyun.teautil.Common.readAsString(response_.body);
return TeaConverter.buildMap(
new TeaPair("headers", response_.headers),
new TeaPair("statusCode", response_.statusCode)
Expand All @@ -873,17 +898,23 @@ public Client(com.aliyun.teaopenapi.models.Config config) throws Exception {
continue;
}
throw e;
} finally {
if (!com.aliyun.teautil.Common.isUnset(_lastResponse)
&& !com.aliyun.teautil.Common.isUnset(_lastResponse.response)
&& !com.aliyun.teautil.Common.isUnset(_lastResponse.response.body())){
_lastResponse.response.close();
}
}
}
throw new TeaUnretryableException(_lastRequest, _lastException);
}

/**
* Encapsulate the request and invoke the network
* @param action api name
* @param version product version
* @param protocol http or https
* @param method e.g. GET
* @param authType authorization type e.g. AK
* @param bodyType response body type e.g. String
* @param request object of OpenApiRequest
* @param runtime which controls some details of call api, such as retry times
* @return the response
*/
public java.util.Map<String, ?> execute(Params params, OpenApiRequest request, com.aliyun.teautil.models.RuntimeOptions runtime) throws Exception {
TeaModel.validateParams(params, "params");
TeaModel.validateParams(request, "request");
Expand Down
1 change: 1 addition & 0 deletions main.tea
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ api doRequest(params: Params, request: OpenApiRequest, runtime: Util.RuntimeOpti
statusCode = __response.statusCode
};
} else {
Util.readAsString(__response.body);
return {
headers = __response.headers,
statusCode = __response.statusCode
Expand Down
2 changes: 1 addition & 1 deletion php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">5.5",
"alibabacloud/tea-utils": "^0.2.17",
"alibabacloud/tea-utils": "^0.2.19",
"alibabacloud/credentials": "^1.1",
"alibabacloud/openapi-util": "^0.1.10|^0.2.1",
"alibabacloud/gateway-spi": "^1",
Expand Down
31 changes: 31 additions & 0 deletions php/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false"
convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"
testSuiteLoaderFile="phpunit/src/Runner/StandardTestSuiteLoader.php">

<testsuites>
<testsuite name="All">
<directory>tests</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>integration</group>
</exclude>
</groups>

<logging>
<log type="coverage-html" target="cache/coverage" lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="cache/coverage.clover"/>
</logging>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
1 change: 1 addition & 0 deletions php/src/OpenApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ public function doRequest($params, $request, $runtime)
"statusCode" => $_response->statusCode
];
} else {
Utils::readAsString($_response->body);
return [
"headers" => $_response->headers,
"statusCode" => $_response->statusCode
Expand Down
Loading

0 comments on commit 93e99d9

Please sign in to comment.