File tree 1 file changed +14
-0
lines changed
google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 17
17
import com .google .api .client .http .LowLevelHttpResponse ;
18
18
import java .io .IOException ;
19
19
import java .io .InputStream ;
20
+ import java .util .logging .Level ;
21
+ import java .util .logging .Logger ;
20
22
import org .apache .hc .client5 .http .classic .methods .HttpUriRequestBase ;
21
23
import org .apache .hc .core5 .http .ClassicHttpResponse ;
22
24
import org .apache .hc .core5 .http .Header ;
25
27
26
28
final class Apache5HttpResponse extends LowLevelHttpResponse {
27
29
30
+ private static final Logger LOGGER = Logger .getLogger (Apache5HttpResponse .class .getName ());
28
31
private final HttpUriRequestBase request ;
29
32
private final ClassicHttpResponse response ;
30
33
private final Header [] allHeaders ;
@@ -99,6 +102,17 @@ public String getHeaderValue(int index) {
99
102
/** Aborts execution of the request. */
100
103
@ Override
101
104
public void disconnect () {
105
+ close ();
106
+ }
107
+
108
+ public void close () {
102
109
request .abort ();
110
+ try {
111
+ response .close ();
112
+ } catch (IOException e ) {
113
+ // the close() method contract won't allow us to declare a thrown exception. Here we just log
114
+ // the error
115
+ LOGGER .log (Level .SEVERE , "Error occurred when closing the response" , e );
116
+ }
103
117
}
104
118
}
You can’t perform that action at this time.
0 commit comments