OkHttp: Drop leak warning message that may not be the app's fault.
When a HttpURLConnection is disconnect()ed but its response body
isn't closed, OkHttp logs a warning because it delays garbage
collection of associated state. One way this can happen is if an
app only accesses the response header fields; this is not an
app problem so we shouldn't warn about it.
Bug: 64789755
Test: Treehugger
Change-Id: If809b498d5567b68968eee6bf1be5e759eca677c
diff --git a/okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java b/okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java
index 6f8efc4..4819ba6 100644
--- a/okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java
+++ b/okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java
@@ -301,9 +301,13 @@
continue;
}
- // We've discovered a leaked allocation. This is an application bug.
- Internal.logger.warning("A connection to " + connection.getRoute().getAddress().url()
- + " was leaked. Did you forget to close a response body?");
+ // Android-removed: Drop warning about a leak that may not be the app's fault.
+ // We can't tell here whether the app accessed the response body (InputStream) or
+ // only the header fields; at least in the latter case, the app has done nothing
+ // wrong so we shouldn't warn. http://b/64789755
+ // // We've discovered a leaked allocation. This is an application bug.
+ // Internal.logger.warning("A connection to " + connection.getRoute().getAddress().url()
+ // + " was leaked. Did you forget to close a response body?");
references.remove(i);
connection.noNewStreams = true;