{"record":{"id":"06768cfb4dd4fb44","repo":"didi/DoKit","slug":"downloader-must-not-be-null","errorCode":null,"errorMessage":"Downloader must not be null.","messagePattern":"Downloader must not be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java","lineNumber":722,"sourceCode":"      this.context = context.getApplicationContext();\n    }\n\n    /**\n     * Specify the default {@link Bitmap.Config} used when decoding images. This can be overridden\n     * on a per-request basis using {@link RequestCreator#config(Bitmap.Config) config(..)}.\n     */\n    public Builder defaultBitmapConfig(Bitmap.Config bitmapConfig) {\n      if (bitmapConfig == null) {\n        throw new IllegalArgumentException(\"Bitmap config must not be null.\");\n      }\n      this.defaultBitmapConfig = bitmapConfig;\n      return this;\n    }\n\n    /** Specify the {@link Downloader} that will be used for downloading images. */\n    public Builder downloader(Downloader downloader) {\n      if (downloader == null) {\n        throw new IllegalArgumentException(\"Downloader must not be null.\");\n      }\n      if (this.downloader != null) {\n        throw new IllegalStateException(\"Downloader already set.\");\n      }\n      this.downloader = downloader;\n      return this;\n    }\n\n    /**\n     * Specify the executor service for loading images in the background.\n     * <p>\n     * Note: Calling {@link DokitPicasso#shutdown() shutdown()} will not shutdown supplied executors.\n     */\n    public Builder executor(ExecutorService executorService) {\n      if (executorService == null) {\n        throw new IllegalArgumentException(\"Executor service must not be null.\");\n      }\n      if (this.service != null) {","sourceCodeStart":704,"sourceCodeEnd":740,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java#L704-L740","documentation":"Builder.downloader(Downloader) sets the network layer; null is rejected with IllegalArgumentException('Downloader must not be null.') (and a second call with IllegalStateException 'Downloader already set.'). Picasso needs a concrete downloader to fetch remote URLs — there is no default-null mode — so the guard fires at build configuration time rather than at first network request.","triggerScenarios":"builder.downloader(null) from an injection field that is not yet populated; passing a Downloader obtained from a lazy provider that returned null; test code stubbing the downloader as null to 'disable' networking (use a mock that throws instead).","commonSituations":"DI module supplying null when a flavor lacks the OkHttp dependency; replacing UrlConnectionDownloader with a custom one whose factory fails silently.","solutions":["Always pass a real Downloader: new OkHttp3Downloader(client) or new UrlConnectionDownloader()","If DI provides it, make the provider non-nullable and fail at graph construction","To block network in tests, supply a Downloader whose load() throws IOException — not null"],"exampleFix":"// before\nnew DokitPicasso.Builder(context)\n    .downloader(injectedDownloader) // null when DI module missed\n    .build();\n\n// after\nnew DokitPicasso.Builder(context)\n    .downloader(injectedDownloader != null\n        ? injectedDownloader\n        : new okhttp3.OkHttp3Downloader(new OkHttpClient()))\n    .build();","handlingStrategy":"validation","validationCode":"Downloader dl = (injectedDownloader != null)\n    ? injectedDownloader\n    : new okhttp3.OkHttp3Downloader(new OkHttpClient());\nDokitPicasso picasso = new DokitPicasso.Builder(context).downloader(dl).build();","typeGuard":null,"tryCatchPattern":"try {\n  builder.downloader(downloader);\n} catch (IllegalArgumentException e) {\n  if (\"Downloader must not be null.\".equals(e.getMessage())) {\n    builder.downloader(new okhttp3.OkHttp3Downloader(new OkHttpClient()));\n  } else throw e;\n}","preventionTips":["Pass a concrete Downloader (OkHttp3Downloader or UrlConnectionDownloader) every time","Make DI providers non-nullable so misconfiguration fails at build time in the graph","To disable networking in tests, use a Downloader that throws IOException — never null"],"tags":["android","picasso","network","configuration","null-safety"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}