Crash on DrawableTransformation if the custom transform returns null
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
When implementing a custom `DrawableTransformation`, if for any reason, the custom `transform()` method returns `null`, then a check [here](https://github.com/bumptech/glide/blob/5e158121a6cac01503f1e0f6c312aa241f045552/library/src/main/java/com/bumptech/glide/load/resource/bitmap/DrawableTransformation.java#L63) fails with a null object exception because it tests if `transformed.equals(original)`.
On the other hand, on `BitmapTransformation`, the check is the opposite [here](https://github.com/bumptech/glide/blob/5e158121a6cac01503f1e0f6c312aa241f045552/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapTransformation.java#L86) : it tests if `original.equals(transformed)` which lets the code handle null correctly.
As a result, if the transformation can't be done, this forces to throw an Exception that won't be caught. Inverting the test as done on the BitmapTransformation seems like an easy fix (and even though the custom transform() should probably avoid returning null, this would at least provide better consistency).
Contributor guide
Research direction
Start in library/src/main/java/com/bumptech/glide/load/resource/bitmap/DrawableTransformation.java at the null-sensitive comparison, then compare the corresponding check in BitmapTransformation.java. Exercise a custom transform that returns null and verify that the DrawableTransformation path no longer crashes and handles the result consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100