-
CSR
-
Resolution: Approved
-
P3
-
None
-
behavioral
-
low
-
This fix leads to a behavioural change that could potentially impact any applications that currently call the usingProxy method. However, since the results are more accurate than before the compatibility risk should be low.
-
Java API
-
SE
Summary
The method description of HttpURLConnection::usingProxy is modified to make it clearer that false
will also be returned if the use of a proxy cannot be determined. The implementation of the method is also altered to widen the window in which it can return meaningful results.
Problem
The method is specified to return true if the connection is going through a proxy. However, the current implementation only returns true once the connection is established (once the underlying socket is connected) and switches back to false once the input stream has been fully read. Thus, the method specification does not fully reflect its implementation, which might lead to confusion.
Solution
An extended method description is added to the specification of HttpURLConnection::usingProxy to make it clear that the method may not be able to determine whether a proxy is used until the connection is established. The implementation is also changed to widen the window in which it returns meaningful results. For instance, it will now always return true if an explicit proxy was provided. If no explicit proxy was provided, but a proxy is dynamically selected by the default proxy selector during connect, that information will be preserved: the value will no longer revert to false after the connection becomes inactive.
Specification
net/HttpURLConnection::usingProxy
@@ -618,6 +618,10 @@
/**
* Indicates if the connection is going through a proxy.
+ *
+ * This method returns {@code true} if the connection is known
+ * to be going or has gone through proxies, and returns {@code false}
+ * if the connection will never go through a proxy or if
+ * the use of a proxy cannot be determined.
+ *
+ * @return a boolean indicating if the connection is using a proxy.
*/
Changes can also be seen in the webrev: http://cr.openjdk.java.net/~jboes/webrevs/8231632/webrev.03/index.html
- csr of
-
JDK-8231632 HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact
-
- Resolved
-