Skip to content

Commit 7d1341d

Browse files
authored
dispose cts after call finish (#1128)
1 parent 5d98bcc commit 7d1341d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/LibKubernetesGenerator/templates/Operations.cs.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace k8s;
88

99
public partial class AbstractKubernetes : I{{name}}Operations
10-
{
10+
{
1111
{{#apis}}
1212
/// <inheritdoc/>
1313
async Task<HttpOperationResponse{{GetReturnType operation "<>"}}> I{{name}}Operations.{{GetMethodName operation "WithHttpMessagesAsync"}}(
@@ -17,7 +17,7 @@ public partial class AbstractKubernetes : I{{name}}Operations
1717
IReadOnlyDictionary<string, IReadOnlyList<string>> customHeaders,
1818
CancellationToken cancellationToken)
1919
{
20-
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
20+
using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
2121
cts.CancelAfter(HttpClientTimeout);
2222
{{#IfParamContains operation "watch"}}
2323
if (watch == true)
@@ -58,13 +58,13 @@ public partial class AbstractKubernetes : I{{name}}Operations
5858
{{#IfParamDoesNotContain operation "body"}}
5959
var httpResponse = await SendRequest<object>(url, HttpMethods.{{Method}}, customHeaders, null, cancellationToken);
6060
{{/IfParamDoesNotContain operation "body"}}
61-
// Create Result
61+
// Create Result
6262
var httpRequest = httpResponse.RequestMessage;
6363
{{#IfReturnType operation "void"}}
6464
HttpOperationResponse result = new HttpOperationResponse() { Request = httpRequest, Response = httpResponse };
6565
{{/IfReturnType operation "void"}}
6666
{{#IfReturnType operation "obj"}}
67-
var result = await CreateResultAsync{{GetReturnType operation "<>"}}(
67+
var result = await CreateResultAsync{{GetReturnType operation "<>"}}(
6868
httpRequest,
6969
httpResponse,
7070
{{#IfParamContains operation "watch"}}

0 commit comments

Comments
 (0)