A connection to XXXX was leaked.への対応
概要
JavaでAndroidの開発中、Http(s)URLConnection使用時に発生した下記エラーへの対処方法
A connection to XXXX was leaked. Did you forget to close a response body?
解決策
あまり大きな話ではなく、getInputStream()側とgetErrorStream()側でそれぞれcloseが必要みたい。
HttpsURLConnection URLconnection = null;
<略>
if (URLconnection.getErrorStream() != null){
try {
URLconnection.getErrorStream().close();
}catch (IOException e){
e.printStackTrace();
}
}
参考URL
Author And Source
この問題について(A connection to XXXX was leaked.への対応), 我々は、より多くの情報をここで見つけました https://qiita.com/komugiko/items/e964388ad78c70cb24ec著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .