infer icon indicating copy to clipboard operation
infer copied to clipboard

false positive resource of type `javax.net.ssl.HttpsURLConnection`

Open SolomonSun2010 opened this issue 1 year ago • 2 comments

Please make sure your issue is not addressed in the FAQ.

Please include the following information:

  • [x] The version of infer from infer --version. Infer v1.1.0
  • [x] Your operating system and version, for example "Debian 9", "MacOS High Sierra", whether you are using Docker, etc. Ubuntu 20.04
  • [x] Which command you ran, for example infer -- make. infer -- javac javacheck/HttpURLConnectionTest.java
  • [x] The full output in a paste, for instance a gist. Please attention, ;the javax.net.ssl.HttpsURLConnection extends java.net.HttpURLConnection extends java.net.URLConnection, all they itself have no close() method.

javacheck/HttpURLConnectionTest.java:18: error: Resource Leak resource of type javax.net.ssl.HttpsURLConnection acquired by call to openConnection() at line 13 is not released after line 18. 16. return conn; 17. } else { 18. > System.out.println("url open connection is not HttpURLConnection"); 19. // Logger.error(TAG, "url open connection is not HttpURLConnection"); 20. throw new IOException();

Found 1 issue Issue Type(ISSUED_TYPE_ID): # Resource Leak(RESOURCE_LEAK): 1

  • [x] If possible, a minimal example to reproduce your problem (for instance, some code where infer reports incorrectly, together with the way you run infer to reproduce the incorrect report).
package javacheck;

// import androidx.annotation.NonNull;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

class HttpURLConnectionTest {

    protected HttpURLConnection connect_FP(URL url) throws IOException {
        URLConnection urlConn = url.openConnection();
        if (urlConn instanceof HttpURLConnection) {
            HttpURLConnection conn = (HttpURLConnection) urlConn;
            return conn;
        } else {
            System.out.println("url open connection is not HttpURLConnection");
            // Logger.error(TAG, "url open connection is not HttpURLConnection");
            throw new IOException();
        }
    }
}

SolomonSun2010 avatar May 08 '23 11:05 SolomonSun2010

I also encountered the same problem

yunshouhu avatar May 15 '23 07:05 yunshouhu

I also encountered the same problem

okay, nice to meet you here.

SolomonSun2010 avatar May 23 '23 03:05 SolomonSun2010