didi/DoKit · error · IllegalArgumentException

uri == null

Error message

uri == null

What it means

invalidate(Uri) clears memory-cache entries derived from a URI; unlike the load() methods it performs no work when the argument is absent, so a null Uri is rejected immediately with IllegalArgumentException('uri == null'). Unlike load(null), there is no 'no-op request' semantics for invalidation — the caller must supply a concrete URI.

Source

Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java:345

   * @see #load(String)
   * @see #load(File)
   */
  public RequestCreator load(int resourceId) {
    if (resourceId == 0) {
      throw new IllegalArgumentException("Resource ID must not be zero.");
    }
    return new RequestCreator(this, null, resourceId);
  }

  /**
   * Invalidate all memory cached images for the specified {@code uri}.
   *
   * @see #invalidate(String)
   * @see #invalidate(File)
   */
  public void invalidate(Uri uri) {
    if (uri == null) {
      throw new IllegalArgumentException("uri == null");
    }
    cache.clearKeyUri(uri.toString());
  }

  /**
   * Invalidate all memory cached images for the specified {@code path}. You can also pass a
   * {@linkplain RequestCreator#stableKey stable key}.
   *
   * @see #invalidate(Uri)
   * @see #invalidate(File)
   */
  public void invalidate(String path) {
    if (path == null) {
      throw new IllegalArgumentException("path == null");
    }
    invalidate(Uri.parse(path));
  }

View on GitHub (pinned to 626827cddb)

Solutions

  1. Null-check before invalidating — nothing to clear if the URI is null
  2. If you hold the path/file instead, call invalidate(path) / invalidate(file) which do their own null checks
  3. Reorder logic: persist the URI first, then invalidate

Example fix

// before
DokitPicasso.with(context).invalidate(updatedAvatarUri); // may be null

// after
if (updatedAvatarUri != null) {
  DokitPicasso.with(context).invalidate(updatedAvatarUri);
}
Defensive patterns

Strategy: validation

Validate before calling

if (uri != null) {
  picasso.invalidate(uri);
}

Type guard

java.util.Objects.requireNonNull;

Try / catch

// Not needed with the null guard; for completeness:
try { picasso.invalidate(uri); }
catch (IllegalArgumentException e) { /* uri == null: nothing cached anyway */ }

Prevention

When it happens

Trigger: Calling picasso.invalidate((Uri) null) directly; invalidate(someUriField) where the field was never assigned; Java overload resolution picking invalidate(Uri) for a null literal (invalidate((Uri) null)).

Common situations: Cache-invalidation hooks after avatar upload where the new URI is not yet known; null coming from a database cursor column.

Related errors


AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14). Data as JSON: /api/errors/f8fc167a0686ee17. Report an issue: GitHub.