{"record":{"id":"8a219a655d060c89","repo":"didi/DoKit","slug":"path-null","errorCode":null,"errorMessage":"path == null","messagePattern":"path == null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java","lineNumber":359,"sourceCode":"   * @see #invalidate(File)\n   */\n  public void invalidate(Uri uri) {\n    if (uri == null) {\n      throw new IllegalArgumentException(\"uri == null\");\n    }\n    cache.clearKeyUri(uri.toString());\n  }\n\n  /**\n   * Invalidate all memory cached images for the specified {@code path}. You can also pass a\n   * {@linkplain RequestCreator#stableKey stable key}.\n   *\n   * @see #invalidate(Uri)\n   * @see #invalidate(File)\n   */\n  public void invalidate(String path) {\n    if (path == null) {\n      throw new IllegalArgumentException(\"path == null\");\n    }\n    invalidate(Uri.parse(path));\n  }\n\n  /**\n   * Invalidate all memory cached images for the specified {@code file}.\n   *\n   * @see #invalidate(Uri)\n   * @see #invalidate(String)\n   */\n  public void invalidate(File file) {\n    if (file == null) {\n      throw new IllegalArgumentException(\"file == null\");\n    }\n    invalidate(Uri.fromFile(file));\n  }\n\n  /**","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java#L341-L377","documentation":"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.","triggerScenarios":"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.","commonSituations":"Refresh-after-upload flows where the URL field is still null; list adapters invalidating on data sets that mix image and imageless items.","solutions":["Skip invalidation when the path is null — there is nothing cached under a null key","Use the String overload only when you actually have a path; prefer invalidate(uri) if you hold the Uri","Ensure the URL is committed to your model before triggering cache invalidation"],"exampleFix":"// before\nDokitPicasso.with(context).invalidate(user.getAvatarUrl()); // null before upload\n\n// after\nString url = user.getAvatarUrl();\nif (url != null) DokitPicasso.with(context).invalidate(url);","handlingStrategy":"validation","validationCode":"if (path != null && !path.trim().isEmpty()) {\n  picasso.invalidate(path);\n}","typeGuard":null,"tryCatchPattern":"// Unnecessary once guarded; catching for defensive code:\ntry { picasso.invalidate(path); }\ncatch (IllegalArgumentException e) { /* path == null */ }","preventionTips":["Guard null AND blank strings — blank parses to an empty URI and silently clears nothing","Invalidate only after the model actually holds the URL","Centralize 'refresh image' logic in one helper that does the null/blank check"],"tags":["android","picasso","cache","validation","null-safety"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}