javafx - JSoup randomly throws java.io.IOException: stream is closed when running from browser -
i'm having weird jsoup problem when running javafx application browser (or web-start).
when run inside ide (eclipse or netbeans) or standalone app, runs normally. when try run web-start or browser (chrome), jsoup randomly throws "java.io.ioexception: stream closed".
the site i'm trying parse thepiratebay.sx. when first run application (from browser), error. application running, if try parse again, works... sometimes.
the jsoup code:
try { //todo: change httpfetcher. method reporting "stream closed" when running on browser connection con = jsoup.connect(url) .timeout(http_timeout) .useragent(useragentgenerator.getuseragent()) .followredirects(false); doc = con.get(); system.out.println("fetching... " + url); } catch (ioexception e) { e.printstacktrace(); system.out.println("parser connect must have timed out, no results. " + url); fetchfailed[i] = true; continue; } { i++; if (commontfutils.isalltrue(fetchfailed)) { throw new httpexception("fetcher failed on every url of " + response.getsite_name()); } }
and exception thrown:
cacheentry[http://thepiratebay.sx/browse/207/0/7]: updateavailable=true,lastmodified=tue may 14 14:28:16 brt 2013,length=-1 java.io.ioexception: stream closed @ sun.net.www.http.chunkedinputstream.ensureopen(unknown source) @ sun.net.www.http.chunkedinputstream.read(unknown source) @ java.io.filterinputstream.read(unknown source) @ sun.net.www.protocol.http.httpurlconnection$httpinputstream.read(unknown source) @ sun.net.www.protocol.http.httpurlconnection$httpinputstream.read(unknown source) @ sun.net.www.protocol.http.httpurlconnection$httpinputstream.read(unknown source) @ sun.net.www.protocol.http.httpurlconnection$httpinputstream.close(unknown source) @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:468) @ org.jsoup.helper.httpconnection$response.execute(httpconnection.java:410) @ org.jsoup.helper.httpconnection.execute(httpconnection.java:164) @ org.jsoup.helper.httpconnection.get(httpconnection.java:153) @ com.package.torrent.parser.genericparser.search(genericparser.java:147) @ com.package.torrent.parser.genericparser.browse(genericparser.java:82) @ com.package.search.trackersearch.searchtracker(trackersearch.java:69) @ com.package.search.trackersearch.searchalltrackers(trackersearch.java:40) @ com.package.search.trackersearch.searchalltrackers(trackersearch.java:23) @ com.package.search.moviebrowser.browsetrackers(moviebrowser.java:49) @ com.package.ui.browse.browsecontroller$moviebrowsertask.call(browsecontroller.java:237) @ com.package.ui.browse.browsecontroller$moviebrowsertask.call(browsecontroller.java:213) @ javafx.concurrent.task$taskcallable.call(task.java:1259) @ java.util.concurrent.futuretask$sync.innerrun(unknown source) @ java.util.concurrent.futuretask.run(unknown source) @ java.lang.thread.run(unknown source)
does have idea of might causing this?
thanks in advance.
i think found solution. place code before ever call jsoup. apparently, applets , web start set value true. now, wonder why sun forces access static variable non-statically.
new url("jar:file://dummy.jar!/").openconnection().setdefaultusecaches(false);
jsoup doesn't handle when url cached , treats exception.
Comments
Post a Comment