{"record":{"id":"46ca73fd06192a41","repo":"nostra13/Android-Universal-Image-Loader","slug":"displayer-can-t-be-null","errorCode":null,"errorMessage":"displayer can't be null","messagePattern":"displayer can't be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/nostra13/universalimageloader/core/DisplayImageOptions.java","lineNumber":439,"sourceCode":"\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Sets bitmap processor which will be process bitmaps before they will be displayed in\n\t\t * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware image aware view} but\n\t\t * after they'll have been saved in memory cache.\n\t\t */\n\t\tpublic Builder postProcessor(BitmapProcessor postProcessor) {\n\t\t\tthis.postProcessor = postProcessor;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Sets custom {@link BitmapDisplayer displayer} for image loading task. Default value -\n\t\t * {@link DefaultConfigurationFactory#createBitmapDisplayer()}\n\t\t */\n\t\tpublic Builder displayer(BitmapDisplayer displayer) {\n\t\t\tif (displayer == null) throw new IllegalArgumentException(\"displayer can't be null\");\n\t\t\tthis.displayer = displayer;\n\t\t\treturn this;\n\t\t}\n\n\t\tBuilder syncLoading(boolean isSyncLoading) {\n\t\t\tthis.isSyncLoading = isSyncLoading;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Sets custom {@linkplain Handler handler} for displaying images and firing {@linkplain ImageLoadingListener\n\t\t * listener} events.\n\t\t */\n\t\tpublic Builder handler(Handler handler) {\n\t\t\tthis.handler = handler;\n\t\t\treturn this;\n\t\t}\n","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/nostra13/Android-Universal-Image-Loader/blob/ba33ec64d0daaa881d35852460e78c58d086bc18/library/src/main/java/com/nostra13/universalimageloader/core/DisplayImageOptions.java#L421-L457","documentation":"DisplayImageOptions.Builder.displayer(BitmapDisplayer) rejects a null displayer because every load task ends by handing its bitmap to the displayer on the UI thread (DefaultConfigurationFactory.createBitmapDisplayer() supplies SimpleBitmapDisplayer by default). A null displayer would make images silently never appear; failing fast in the builder surfaces the mistake where it is made.","triggerScenarios":"Calling .displayer(null) when wiring a custom animation/display strategy; conditional code like animate ? new FadeInBitmapDisplayer(300) : null; a DI framework injecting an unset optional displayer.","commonSituations":"Feature-flagged animations ('animate or no displayer'); Dagger/Spring-injected fields defaulting to null; refactoring where a custom displayer class was deleted but the wiring left the call.","solutions":["Use SimpleBitmapDisplayer.INSTANCE (or new SimpleBitmapDisplayer()) for the no-op branch","For simple fade-in use new FadeInBitmapDisplayer(300) instead of null","Make injected displayer fields non-optional with a default provider"],"exampleFix":"// before\nbuilder.displayer(animate ? new FadeInBitmapDisplayer(300) : null); // throws when !animate\n\n// after\nbuilder.displayer(animate\n        ? new FadeInBitmapDisplayer(300)\n        : new SimpleBitmapDisplayer());","handlingStrategy":"validation","validationCode":"BitmapDisplayer d = (displayer != null)\n        ? displayer : new SimpleBitmapDisplayer();\noptions.displayer(d);","typeGuard":"static boolean isUsableDisplayer(BitmapDisplayer d) {\n    return d != null;\n}","tryCatchPattern":null,"preventionTips":["Always provide a concrete displayer branch (FadeInBitmapDisplayer or SimpleBitmapDisplayer)","Give injected displayers a non-null default provider","Build options in one factory method to avoid divergent builder chains"],"tags":["options","builder","null-safety","displayer"],"backgroundTag":null,"analyzedSha":"ba33ec64d0daaa881d35852460e78c58d086bc18","analyzedAt":"2026-08-14T15:41:15.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}