0
을 나는 다음과 같은 원격 URL에서 파일을 구문 분석 Jsoup를 사용 : 웹 사이트가 제한 시간 내에 응답하지 않으면Jsoup - 닫기가 호출되지 않습니다 - 안드로이드 StrictMode
Document doc = Jsoup.connect(urlString)
.timeout(5000)
.get();
예상 등의 SocketTimeoutException
가 발생합니다 . 또한 StrictMode를 설정해 닫지 않은 리소스에 대해 경고합니다. 타임 아웃에서 StrictMode는 자원이 폐쇄되지 않았 음을 알려줍니다 :
A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:184)
at java.io.FileInputStream.<init>(FileInputStream.java:80)
at libcore.io.DiskLruCache.get(DiskLruCache.java:391)
at libcore.net.http.HttpResponseCache.get(HttpResponseCache.java:98)
at android.net.http.HttpResponseCache.get(HttpResponseCache.java:204)
at libcore.net.http.HttpEngine.initResponseSource(HttpEngine.java:257)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:218)
at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
at org.jsoup.helper.HttpConnection$Response.a(SourceFile:439)
at org.jsoup.helper.HttpConnection$Response.a(SourceFile:465)
at org.jsoup.helper.HttpConnection$Response.a(SourceFile:424)
at org.jsoup.helper.HttpConnection.execute(SourceFile:178)
at org.jsoup.helper.HttpConnection.get(SourceFile:167)
at com.example.$3.call(SourceFile:163)
at a.e.run(SourceFile:198)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
내가 Jsoup가 생성하는 자원을 닫는 방법을 볼 수 없습니다. 내가 어떻게 그럴 수 있니?
정보 주셔서 감사합니다. 나는 그것이 StrictMode로부터 거짓 긍정 (false positive)이 틀림 없다고 생각한다. –