Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(138)

Unified Diff: google-http-client/src/main/java/com/google/api/client/http/json/JsonHttpRequest.java

Issue 6225045: Closing input stream in HttpResponse.disconnect and fixing NPE (Closed) Base URL: https://google-http-java-client.googlecode.com/hg/
Patch Set: Addressing code review comment Created 12 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: google-http-client/src/main/java/com/google/api/client/http/json/JsonHttpRequest.java
===================================================================
--- a/google-http-client/src/main/java/com/google/api/client/http/json/JsonHttpRequest.java
+++ b/google-http-client/src/main/java/com/google/api/client/http/json/JsonHttpRequest.java
@@ -158,10 +158,19 @@
* override if specific behavior is required.
*
* <p>
- * Callers are responsible for closing the response's content input stream by calling
- * {@link HttpResponse#ignore}.
+ * Callers are responsible for disconnecting the HTTP response by calling
+ * {@link HttpResponse#disconnect}. Example usage:
* </p>
*
+ * <pre>
+ HttpResponse response = jsonHttpRequest.executeUnparsed();
+ try {
+ // process response..
+ } finally {
+ response.disconnect();
+ }
+ * </pre>
+ *
* @return the {@link HttpResponse}
* @throws IOException if the request fails
*/
@@ -177,9 +186,18 @@
* Subclasses may override if specific behavior is required.
*
* <p>
- * Callers are responsible for closing the input stream.
+ * Callers are responsible for closing the input stream after it is processed. Example sample:
* </p>
*
+ * <pre>
+ InputStream is = request.executeAsInputStream();
+ try {
+ // Process input stream..
+ } finally {
+ is.close();
+ }
+ * </pre>
+ *
* @return input stream of the response content
* @throws IOException if the request fails
* @since 1.8

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b