didi/DoKit · error · IllegalArgumentException

path == null

Error message

path == null

What it means

invalidate(String path) forwards to invalidate(Uri.parse(path)) after rejecting null with IllegalArgumentException('path == null'). Note it does NOT check for empty strings here — an empty path will parse to an empty URI and clear nothing — so the null check is purely an argument contract: invalidation requires a concrete key.

Source

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

   * @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));
  }

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

  /**

View on GitHub (pinned to 626827cddb)

Solutions

  1. Skip invalidation when the path is null — there is nothing cached under a null key
  2. Use the String overload only when you actually have a path; prefer invalidate(uri) if you hold the Uri
  3. Ensure the URL is committed to your model before triggering cache invalidation

Example fix

// before
DokitPicasso.with(context).invalidate(user.getAvatarUrl()); // null before upload

// after
String url = user.getAvatarUrl();
if (url != null) DokitPicasso.with(context).invalidate(url);
Defensive patterns

Strategy: validation

Validate before calling

if (path != null && !path.trim().isEmpty()) {
  picasso.invalidate(path);
}

Try / catch

// Unnecessary once guarded; catching for defensive code:
try { picasso.invalidate(path); }
catch (IllegalArgumentException e) { /* path == null */ }

Prevention

When it happens

Trigger: picasso.invalidate((String) null); invalidate(model.imageUrl) where imageUrl is null (e.g. record created before image upload); overload ambiguity when passing a null literal.

Common situations: Refresh-after-upload flows where the URL field is still null; list adapters invalidating on data sets that mix image and imageless items.

Related errors


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