Titanium JIRA Archive
Appcelerator Community (AC)

[AC-795] TiDownloadManager crashes with links returning redirects (302)

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2015-06-29T17:12:36.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsTCSupportTriage
ReporterMatteo Landi
AssigneeRadamantis Torres-Lechuga
Created2014-12-29T15:22:51.000+0000
Updated2016-03-08T07:37:04.000+0000

Description

TiDownloadManager doesn't seem to properly handle redirects on Android Lollipop. This is the exception I get:
ERROR] TiDownloadManager: (pool-4-thread-1) [916,916] Exception downloading https://graph.facebook.com/100008778152788/picture?width=200&height=200
[ERROR] TiDownloadManager: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.StatusLine.<init>(StatusLine.java:24)
[ERROR] TiDownloadManager: 	at com.android.okhttp.Response$Builder.statusLine(Response.java:419)
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.JavaApiConverter.createOkResponse(JavaApiConverter.java:116)
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.ResponseCacheAdapter.get(ResponseCacheAdapter.java:53)
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:190)
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:190)
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
[ERROR] TiDownloadManager: 	at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
[ERROR] TiDownloadManager: 	at java.net.URL.openStream(URL.java:470)
[ERROR] TiDownloadManager: 	at org.appcelerator.titanium.util.TiDownloadManager$DownloadJob.run(TiDownloadManager.java:135)
[ERROR] TiDownloadManager: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
[ERROR] TiDownloadManager: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
[ERROR] TiDownloadManager: 	at java.lang.Thread.run(Thread.java:818)
Attached you can find a single window application in which two image views are used to display remote images. The second of the two uses some facebook redirect to get the actual image url, and TiDownloadManager crashes while fetching the data.

Attachments

FileDateSize
redirect.tgz2014-12-29T15:22:51.000+00004085569

Comments

  1. grebulon 2015-03-16

    To work around this, call setUseCaches(false) on the URL connection before opening the stream, but I don't know why this happens.
  2. grebulon 2015-03-31

    This is caused by a bug in TiCacheResponse. I reported this in a separate issue - TC-5388 Also see: http://stackoverflow.com/a/29147399/2603965
  3. Arnaud Besnier 2015-05-21

    Any update for this issue? Or do we have to implement our own image cache?
  4. grebulon 2015-05-21

    This is the same as item TC-5388 which has just been fixed for 4.0.1

JSON Source