{"record":{"id":"61595604fde8460e","repo":"didi/DoKit","slug":"file-null","errorCode":null,"errorMessage":"file == null","messagePattern":"file == null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java","lineNumber":372,"sourceCode":"   * @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  /**\n   * {@code true} if debug display, logging, and statistics are enabled.\n   * <p>\n   * @deprecated Use {@link #areIndicatorsEnabled()} and {@link #isLoggingEnabled()} instead.\n   */\n  @SuppressWarnings(\"UnusedDeclaration\") @Deprecated public boolean isDebugging() {\n    return areIndicatorsEnabled() && isLoggingEnabled();\n  }\n\n  /**\n   * Toggle whether debug display, logging, and statistics are enabled.\n   * <p>\n   * @deprecated Use {@link #setIndicatorsEnabled(boolean)} and {@link #setLoggingEnabled(boolean)}\n   * instead.","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java#L354-L390","documentation":"invalidate(File file) converts the file to Uri.fromFile(file) and rejects null with IllegalArgumentException('file == null'). Same contract as the Uri/String overloads: cache invalidation is never a no-op API, the caller must pass the concrete cache key source. Uri.fromFile(null) would itself throw, so Picasso surfaces the argument error at its own boundary.","triggerScenarios":"picasso.invalidate((File) null); invalidate(new File(path)) where path is null producing null via a helper; cache-busting after deleting a cached image file that was never created.","commonSituations":"Photo-edit flows where the edited File reference is null after a failed save; cleanup routines that iterate possibly-null file references.","solutions":["Null-check the File before invalidating","If the file may not exist yet, skip both invalidation and any dependent load","Prefer invalidating by the exact key form used at load time (load(File) uses Uri.fromFile too, so the keys match)"],"exampleFix":"// before\nDokitPicasso.with(context).invalidate(editedImageFile);\n\n// after\nif (editedImageFile != null && editedImageFile.exists()) {\n  DokitPicasso.with(context).invalidate(editedImageFile);\n}","handlingStrategy":"validation","validationCode":"if (file != null && file.exists()) {\n  picasso.invalidate(file);\n}","typeGuard":null,"tryCatchPattern":"try { picasso.invalidate(file); }\ncatch (IllegalArgumentException e) { /* file == null */ }","preventionTips":["Null- and existence-check Files before invalidation","Use the overload matching how the image was loaded (load(File) <-> invalidate(File)) so cache keys align","Skip invalidation in cleanup paths where the file was never created"],"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"}