Check for a behavior change for URLConnection, HttpURLConnection getInputStream method

This rule flags the method java.net.URLConnection getInputStream() or java.net.HttpURLConnection getInputStream()

According to Java SE 7 and JDK 7 Compatibility documentation, the getInputStream method now throws a java.io.IOException if it is called on an HTTP connection and the connection returned a response code of -1. Previously the connection at the client would hang. The new corrected behavior throws an IOException.

According to the documentation, work around this problem by checking the return value from the getResponseCode method and handle a -1 return value by either opening a new connection or by invoking getErrorStream on the stream.

For additional information, see the Java 7 APIs: