Skip to content

BitmapHunter.forRequest throws IllegalStateException #668

@jacobtabak

Description

@jacobtabak

Following up from our brief in-person conversation @dnkoutso I wanted to log this issue here for discussion.

BitmapHunter.forRequest iterates through the registered request handlers and throws an IllegalStateException if no request handlers can handle the request which can't really be caught, forcing a crash.

This is problematic for two reasons:

  1. Many apps show images from third party sources with no guarantee they can be handled (e.g. typos in scheme, see example below).
  2. There's no way for client code to determine whether or not a request can be handled at runtime without digging through Picasso source to determine which request handlers can handle which URIs.

For example, if you try to load a URI with a scheme of 'htp' rather than 'http', your app will crash with this exception:

E/AndroidRuntime﹕ FATAL EXCEPTION: Picasso-Dispatcher
    java.lang.IllegalStateException: Unrecognized type of request: Request{htp://google.com/google.jpg resize(1080,1080) centerCrop}
            at com.squareup.picasso.BitmapHunter.forRequest(BitmapHunter.java:292)
            at com.squareup.picasso.Dispatcher.performSubmit(Dispatcher.java:159)
            at com.squareup.picasso.Dispatcher$DispatcherHandler.handleMessage(Dispatcher.java:345)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.os.HandlerThread.run(HandlerThread.java:61)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions