didi/DoKit · error · IllegalArgumentException
RequestHandler must not be null.
Error message
RequestHandler must not be null.
What it means
DokitPicasso.Builder.addRequestHandler() throws IllegalArgumentException when passed a null RequestHandler. Request handlers resolve custom URI schemes (contacts, video thumbnails, etc.), so null is never valid. Fail-fast null guard.
Source
Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java:791
* <p>
* <b>NOTE:</b> This is a beta feature. The API is subject to change in a backwards incompatible
* way at any time.
*/
public Builder requestTransformer(RequestTransformer transformer) {
if (transformer == null) {
throw new IllegalArgumentException("Transformer must not be null.");
}
if (this.transformer != null) {
throw new IllegalStateException("Transformer already set.");
}
this.transformer = transformer;
return this;
}
/** Register a {@link RequestHandler}. */
public Builder addRequestHandler(RequestHandler requestHandler) {
if (requestHandler == null) {
throw new IllegalArgumentException("RequestHandler must not be null.");
}
if (requestHandlers == null) {
requestHandlers = new ArrayList<RequestHandler>();
}
if (requestHandlers.contains(requestHandler)) {
throw new IllegalStateException("RequestHandler already registered.");
}
requestHandlers.add(requestHandler);
return this;
}
/**
* @deprecated Use {@link #indicatorsEnabled(boolean)} instead.
* Whether debugging is enabled or not.
*/
@Deprecated public Builder debugging(boolean debugging) {
return indicatorsEnabled(debugging);
}View on GitHub (pinned to 626827cddb)
Solutions
- Pass a non-null RequestHandler instance
- Filter nulls out of the handler list before registering: handlers.removeAll(Collections.singleton(null))
- Fix the factory/DI provider so it returns a real handler
Example fix
// before
for (RequestHandler h : handlers) {
builder.addRequestHandler(h); // IllegalArgumentException if h == null
}
// after
for (RequestHandler h : handlers) {
if (h != null) builder.addRequestHandler(h);
} Defensive patterns
Strategy: type-guard
Validate before calling
for (RequestHandler h : handlers) { if (h != null) builder.addRequestHandler(h); } Type guard
boolean isRegistrableHandler(RequestHandler h) { return h != null; } Prevention
- Filter nulls from handler collections before registration
- Fail DI providers loudly instead of returning null handlers
When it happens
Trigger: Calling builder.addRequestHandler(null), typically from a list of handlers that contains a null entry or an uninitialized handler field.
Common situations: Iterating a handler list built conditionally where one branch added null; handler instances created by reflection or DI that failed silently.
Related errors
- Executor service must not be null.
- Memory cache must not be null.
- Listener must not be null.
- Transformer must not be null.
- Downloader already set.
AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14).
Data as JSON: /api/errors/ea31de55f3daf221.
Report an issue: GitHub.