boolean record_failure = true;
try{
TorrentUtils.setTLSDescription( "UPnP Device" + ( friendly_name==null?"":( ": " + friendly_name )));
ResourceDownloaderFactory rdf = adapter.getResourceDownloaderFactory();
int retries;
synchronized( failed_urls ){
long[] fails = failed_urls.get( url_str );
if ( fails == null ){
retries = 3;
}else{
long consec_fails = fails[0];
long last_fail = fails[1];
long max_period = 10*60*1000;
long period = 60*1000;
for (int i=0;i<consec_fails;i++){
period <<= 1;
if ( period >= max_period ){
period = max_period;
break;
}
}
if ( SystemTime.getMonotonousTime() - last_fail < period ){
record_failure = false;
throw( new UPnPException( "Download failed too recently, ignoring" ));
}
retries = 1;
}
}
ResourceDownloader rd = rdf.getRetryDownloader( rdf.create( url, true ), retries );
rd.addListener( this );
InputStream data = rd.download();