false positive resource of type `javax.net.ssl.HttpsURLConnection`
- Dominant language
- OCaml
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 19h 36m
- Merged PRs (30d)
- 13
Description
Please make sure your issue is not addressed in the [FAQ](https://fbinfer.com/docs/support#troubleshooting).
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](https://gist.github.com/).
**Please attention**, ;the javax.net.ssl.HttpsURLConnection extends java.net.HttpURLConnection extends [java.net.URLConnection](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/net/URLConnection.html), 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).
```java
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();
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.