{"record":{"id":"34f2080546f81044","repo":"koral--/android-gif-drawable","slug":"source-is-not-set","errorCode":null,"errorMessage":"Source is not set","messagePattern":"Source is not set","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDrawableInit.java","lineNumber":65,"sourceCode":"     * Note that this call will overwrite sample size set previously by {@link #options(GifOptions)}\n     *\n     * @param sampleSize the sample size\n     * @return this builder instance, to chain calls\n     */\n    public T sampleSize(@IntRange(from = 1, to = Character.MAX_VALUE) final int sampleSize) {\n        mOptions.setInSampleSize(sampleSize);\n        return self();\n    }\n\n    /**\n     * Appropriate constructor wrapper. Must be preceded by on of {@code from()} calls.\n     *\n     * @return new drawable instance\n     * @throws IOException when creation fails\n     */\n    public GifDrawable build() throws IOException {\n        if (mInputSource == null) {\n            throw new NullPointerException(\"Source is not set\");\n        }\n        return mInputSource.createGifDrawable(mOldDrawable, mExecutor, mIsRenderingTriggeredOnDraw, mOptions);\n    }\n\n    /**\n     * Sets drawable to be reused when creating new one.\n     *\n     * @param drawable drawable to be reused\n     * @return this builder instance, to chain calls\n     */\n    public T with(GifDrawable drawable) {\n        mOldDrawable = drawable;\n        return self();\n    }\n\n    /**\n     * Sets thread pool size for rendering tasks.\n     * Warning: custom executor set by {@link #taskExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/koral--/android-gif-drawable/blob/26ff795f78b7fe8bbaf375a947b2bda95fc58e3d/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDrawableInit.java#L47-L83","documentation":"GifDrawableInit.build() requires that an input source was configured via one of the from*() methods. If no source was set, mInputSource is null and build() throws a NullPointerException with the message 'Source is not set'. This is the builder-pattern misuse guard of the library.","triggerScenarios":"Calling GifDrawableBuilder().build() (or another GifDrawableInit subclass) without ever calling from(file/stream/resource/asset/byteBuffer/uri/etc.).","commonSituations":"Building the source conditionally (e.g. inside an if branch that never ran); forgetting the from() call when refactoring; constructing the builder in one place and passing it on without configuring it.","solutions":["Call one of the from*() methods on the builder before build(), e.g. new GifDrawableBuilder().from(gifFile).build().","Ensure the from() call is not skipped by conditional logic; restructure so a source is always provided.","Wrap build() in try-catch for NullPointerException as a defensive last resort."],"exampleFix":"// before\nGifDrawable drawable = new GifDrawableBuilder().build();\n// after\nGifDrawable drawable = new GifDrawableBuilder().from(new File(\"anim.gif\")).build();","handlingStrategy":"validation","validationCode":"GifDrawableBuilder builder = new GifDrawableBuilder(); // ... ensure from() called\nif (builderSourceSet) { GifDrawable d = builder.build(); }","typeGuard":null,"tryCatchPattern":"try { GifDrawable d = builder.build(); } catch (NullPointerException e) { /* source not set — configure from() */ }","preventionTips":["Always chain from() immediately when creating the builder","Never branch around the from() call","Prefer constructing builder+source in one expression"],"tags":["android","builder","null"],"backgroundTag":"missing-required-argument","analyzedSha":"26ff795f78b7fe8bbaf375a947b2bda95fc58e3d","analyzedAt":"2026-09-10T14:37:11.595Z","contentChangedAt":"2026-09-10T14:37:11.595Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}