bumptech / bumptech/glide

IllegalArgumentException when using fallback with FutureTarget

Open
#2,487 3 comments 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

It looks like `fallback()` and `error()` don't work with `submit()` to `FutureTarget`.

Code such as:

`````
Uri uri = null;
Bitmap bitmap = Glide.with(MainActivity.this)
.asBitmap()
.load(uri)
.apply(new RequestOptions().fallback(android.R.drawable.ic_delete))
.submit(500, 500)
.get();
`````

Will always throw:

`````
10-15 16:39:43.627 25771 25826 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at android.os.AsyncTask$3.done(AsyncTask.java:309)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:242)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at java.lang.Thread.run(Thread.java:818)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: Caused by: java.lang.AssertionError: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Load failed
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at org.moxie.glitchycorners.MainActivity$1.doInBackground(MainActivity.java:45)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at org.moxie.glitchycorners.MainActivity$1.doInBackground(MainActivity.java:28)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:295)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: ... 4 more
10-15 16:39:43.627 25771 25826 E AndroidRuntime: Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Load failed
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at com.bumptech.glide.request.RequestFutureTarget.doGet(RequestFutureTarget.java:206)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at com.bumptech.glide.request.RequestFutureTarget.get(RequestFutureTarget.java:108)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: at org.moxie.glitchycorners.MainActivity$1.doInBackground(MainActivity.java:39)
10-15 16:39:43.627 25771 25826 E AndroidRuntime: ... 7 more
10-15 16:39:43.627 25771 25826 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Load failed
10-15 16:39:43.627 25771 25826 E AndroidRuntime: ... 10 more
`````

Same code works fine with `into()` an `ImageView` instead.

I'm not sure whether this is *supposed* to work or not, but I think it'd be nice if it did, since then it'd be possible to reuse the same Glide fallback logic for situations where a controller needs to load a Bitmap (like for notifications) rather than having Glide talk to a view directly.

**Glide Version**: 4.2.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.