{"record":{"id":"f8fc167a0686ee17","repo":"didi/DoKit","slug":"uri-null","errorCode":null,"errorMessage":"uri == null","messagePattern":"uri == null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java","lineNumber":345,"sourceCode":"   * @see #load(String)\n   * @see #load(File)\n   */\n  public RequestCreator load(int resourceId) {\n    if (resourceId == 0) {\n      throw new IllegalArgumentException(\"Resource ID must not be zero.\");\n    }\n    return new RequestCreator(this, null, resourceId);\n  }\n\n  /**\n   * Invalidate all memory cached images for the specified {@code uri}.\n   *\n   * @see #invalidate(String)\n   * @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","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java#L327-L363","documentation":"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.","triggerScenarios":"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)).","commonSituations":"Cache-invalidation hooks after avatar upload where the new URI is not yet known; null coming from a database cursor column.","solutions":["Null-check before invalidating — nothing to clear if the URI is null","If you hold the path/file instead, call invalidate(path) / invalidate(file) which do their own null checks","Reorder logic: persist the URI first, then invalidate"],"exampleFix":"// before\nDokitPicasso.with(context).invalidate(updatedAvatarUri); // may be null\n\n// after\nif (updatedAvatarUri != null) {\n  DokitPicasso.with(context).invalidate(updatedAvatarUri);\n}","handlingStrategy":"validation","validationCode":"if (uri != null) {\n  picasso.invalidate(uri);\n}","typeGuard":"java.util.Objects.requireNonNull;","tryCatchPattern":"// Not needed with the null guard; for completeness:\ntry { picasso.invalidate(uri); }\ncatch (IllegalArgumentException e) { /* uri == null: nothing cached anyway */ }","preventionTips":["Treat null URI as 'nothing to invalidate' and skip","Kotlin: if (uri != null) picasso.invalidate(uri) via platform-type awareness","Prefer invalidating from the same object that produced the URI at load time"],"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"}