{"record":{"id":"f4d76d4039112422","repo":"didi/DoKit","slug":"listener-must-not-be-null","errorCode":null,"errorMessage":"Listener must not be null.","messagePattern":"Listener 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":762,"sourceCode":"      return this;\n    }\n\n    /** Specify the memory cache used for the most recent images. */\n    public Builder memoryCache(Cache memoryCache) {\n      if (memoryCache == null) {\n        throw new IllegalArgumentException(\"Memory cache must not be null.\");\n      }\n      if (this.cache != null) {\n        throw new IllegalStateException(\"Memory cache already set.\");\n      }\n      this.cache = memoryCache;\n      return this;\n    }\n\n    /** Specify a listener for interesting events. */\n    public Builder listener(Listener listener) {\n      if (listener == null) {\n        throw new IllegalArgumentException(\"Listener must not be null.\");\n      }\n      if (this.listener != null) {\n        throw new IllegalStateException(\"Listener already set.\");\n      }\n      this.listener = listener;\n      return this;\n    }\n\n    /**\n     * Specify a transformer for all incoming requests.\n     * <p>\n     * <b>NOTE:</b> This is a beta feature. The API is subject to change in a backwards incompatible\n     * way at any time.\n     */\n    public Builder requestTransformer(RequestTransformer transformer) {\n      if (transformer == null) {\n        throw new IllegalArgumentException(\"Transformer must not be null.\");\n      }","sourceCodeStart":744,"sourceCodeEnd":780,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java#L744-L780","documentation":"DokitPicasso.Builder.listener() throws IllegalArgumentException when passed a null Listener. The listener receives callbacks for failed image loads, so it must be a real object. This is a fail-fast null guard.","triggerScenarios":"Calling builder.listener(null), commonly from an optional debug listener that was left unset in release builds.","commonSituations":"Debug-only listener wrapped in an if (BuildConfig.DEBUG) block whose variable is null in release; a listener reference from an uninitialized field.","solutions":["Pass a non-null Listener implementation","Guard the call: only invoke listener() when you have a real listener to install","If no callbacks are needed, omit listener() entirely"],"exampleFix":"// before\nListener l = buildConfigDebug ? new DebugListener() : null;\nbuilder.listener(l); // IllegalArgumentException in release\n\n// after\nif (buildConfigDebug) {\n  builder.listener(new DebugListener());\n}","handlingStrategy":"validation","validationCode":"if (listener != null) { builder.listener(listener); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard optional components (debug listeners) with null checks before registering","Build release-safe defaults instead of nullable listener references"],"tags":["android","picasso","builder","null-check"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}