Fix log return disposed obj (#705)

* generator not to dispose stream

* new generated code

* test to cover log stream
This commit is contained in:
Boshi Lian
2021-09-17 08:21:00 -07:00
committed by GitHub
parent 4e29dff8d2
commit 07ab21bb98
5 changed files with 308 additions and 221 deletions

View File

@@ -466,7 +466,7 @@ namespace k8s
}
throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
}
{{/IfReturnType operation "stream"}}
{{/IfReturnType operation "obj"}}
}
{{/IfReturnType operation "any"}}
if (_shouldTrace)

View File

@@ -64,6 +64,17 @@ namespace k8s
{{/operation.parameters}}
CancellationToken cancellationToken = default(CancellationToken))
{
{{#IfReturnType operation "stream"}}
var _result = await operations.{{GetMethodName operation "WithHttpMessagesAsync"}}(
{{#operation.parameters}}
{{GetDotNetName .}},
{{/operation.parameters}}
null,
cancellationToken);
_result.Request.Dispose();
{{GetReturnType operation "_result.Body"}};
{{/IfReturnType operation "stream"}}
{{#IfReturnType operation "obj"}}
using (var _result = await operations.{{GetMethodName operation "WithHttpMessagesAsync"}}(
{{#operation.parameters}}
{{GetDotNetName .}},
@@ -73,6 +84,17 @@ namespace k8s
{
{{GetReturnType operation "_result.Body"}};
}
{{/IfReturnType operation "obj"}}
{{#IfReturnType operation "void"}}
using (var _result = await operations.{{GetMethodName operation "WithHttpMessagesAsync"}}(
{{#operation.parameters}}
{{GetDotNetName .}},
{{/operation.parameters}}
null,
cancellationToken).ConfigureAwait(false))
{
}
{{/IfReturnType operation "void"}}
}
{{/.}}

View File

@@ -956,7 +956,7 @@ namespace KubernetesWatchGenerator
{
fn(null);
}
else if (type == "stream" && rt == "Stream")
else if (type.ToLower() == rt.ToLower())
{
fn(null);
}