How to deal with the following error that occurred when using Http (s) URLConnection during Android development with Java
A connection to XXXX was leaked. Did you forget to close a response body?
It's not a big story, and it seems that getInputStream () side and getErrorStream () side need close respectively.
HttpsURLConnection URLconnection = null;
<Abbreviation>
if (URLconnection.getErrorStream() != null){
try {
URLconnection.getErrorStream().close();
}catch (IOException e){
e.printStackTrace();
}
}
https://docs.oracle.com/javase/jp/8/docs/api/javax/net/ssl/HttpsURLConnection.html