{"record":{"id":"abc9cc7fa15d1af1","repo":"didi/DoKit","slug":"bitmap-may-not-be-null","errorCode":null,"errorMessage":"Bitmap may not be null.","messagePattern":"Bitmap may not be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Downloader.java","lineNumber":73,"sourceCode":"\n  /** Response stream or bitmap and info. */\n  class Response {\n    final InputStream stream;\n    final Bitmap bitmap;\n    final boolean cached;\n    final long contentLength;\n\n    /**\n     * Response image and info.\n     *\n     * @param bitmap Image.\n     * @param loadedFromCache {@code true} if the source of the image is from a local disk cache.\n     * @deprecated Use {@link com.didichuxing.doraemonkit.picasso.RequestHandler} for directly loading {@link Bitmap} instances.\n     */\n    @Deprecated\n    public Response(Bitmap bitmap, boolean loadedFromCache) {\n      if (bitmap == null) {\n        throw new IllegalArgumentException(\"Bitmap may not be null.\");\n      }\n      this.stream = null;\n      this.bitmap = bitmap;\n      this.cached = loadedFromCache;\n      this.contentLength = -1;\n    }\n\n    /**\n     * Response stream and info.\n     *\n     * @param stream Image data stream.\n     * @param loadedFromCache {@code true} if the source of the stream is from a local disk cache.\n     * @deprecated Use {@link Response#Response(java.io.InputStream, boolean, long)} instead.\n     */\n    @Deprecated @SuppressWarnings(\"UnusedDeclaration\")\n    public Response(InputStream stream, boolean loadedFromCache) {\n      this(stream, loadedFromCache, -1);\n    }","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Downloader.java#L55-L91","documentation":"Downloader.Response's deprecated bitmap constructor throws IllegalArgumentException when bitmap is null. A Response built in bitmap mode must carry the decoded Bitmap; callers implementing a custom Downloader must pass a real bitmap. Fail-fast null guard.","triggerScenarios":"Implementing a custom Downloader and returning new Response((Bitmap) null, false) when the decode step fails or is skipped.","commonSituations":"Custom downloaders wrapping other caching layers where a cache miss yields null; code ported from newer Picasso where the Response API changed to RequestHandler.Result.","solutions":["Only build the bitmap Response when you actually have a decoded Bitmap; otherwise build the stream Response or return null per the Downloader contract","Migrate to the RequestHandler API, which the deprecation notice recommends for direct Bitmap loading","Fix the decode path so failure returns an error instead of a null bitmap"],"exampleFix":"// before\nBitmap b = decodeFromCache(url);\nreturn new Response(b, true); // IllegalArgumentException when b == null\n\n// after\nBitmap b = decodeFromCache(url);\nif (b != null) return new Response(b, true);\nreturn new Response(openStream(url), false, contentLength);","handlingStrategy":"validation","validationCode":"@Override public Response load(Uri uri, int policy) throws IOException {\n  Bitmap b = decodeFromCache(uri);\n  if (b != null) return new Response(b, true);\n  return new Response(openStream(uri), false, contentLengthOf(uri));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In custom Downloaders, only construct the bitmap Response after a successful decode","Prefer the non-deprecated RequestHandler API for bitmap-backed results"],"tags":["android","picasso","downloader","null-check","deprecated"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}