OSDN Git Service

Dispose漏れを修正 (IDE0069)
authorKimura Youichi <kim.upsilon@bucyou.net>
Wed, 28 Aug 2019 17:12:07 +0000 (02:12 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Wed, 28 Aug 2019 19:26:32 +0000 (04:26 +0900)
OpenTween/Connection/TwitterApiConnection.cs

index 051f7ca..86cf6b1 100644 (file)
@@ -340,9 +340,10 @@ namespace OpenTween.Connection
             {
                 request.Content = postContent;
 
+                HttpResponseMessage response = null;
                 try
                 {
-                    var response = await this.http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead)
+                    response = await this.http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead)
                         .ConfigureAwait(false);
 
                     await this.CheckStatusCode(response)
@@ -361,6 +362,10 @@ namespace OpenTween.Connection
                 {
                     throw TwitterApiException.CreateFromException(ex);
                 }
+                finally
+                {
+                    response?.Dispose();
+                }
             }
         }
 
@@ -460,6 +465,7 @@ namespace OpenTween.Connection
             {
                 Networking.WebProxyChanged -= this.Networking_WebProxyChanged;
                 this.http.Dispose();
+                this.httpUpload.Dispose();
                 this.httpStreaming.Dispose();
             }
         }