{"record":{"id":"773c4e5ee32d450d","repo":"lingochamp/FileDownloader","slug":"create-filedownloadqueueset-must-with-valid-target","errorCode":null,"errorMessage":"create FileDownloadQueueSet must with valid target!","messagePattern":"create FileDownloadQueueSet must with valid target!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/FileDownloadQueueSet.java","lineNumber":51,"sourceCode":"\n    private List<BaseDownloadTask.FinishListener> taskFinishListenerList;\n    private Integer autoRetryTimes;\n    private Boolean syncCallback;\n    private Boolean isForceReDownload;\n    private Boolean isWifiRequired;\n    private Integer callbackProgressTimes;\n    private Integer callbackProgressMinIntervalMillis;\n    private Object tag;\n    private String directory;\n\n    private BaseDownloadTask[] tasks;\n\n    /**\n     * @param target The download listener will be set to all tasks in this queue set.\n     */\n    public FileDownloadQueueSet(FileDownloadListener target) {\n        if (target == null) {\n            throw new IllegalArgumentException(\n                    \"create FileDownloadQueueSet must with valid target!\");\n        }\n        this.target = target;\n    }\n\n    /**\n     * Form a queue with same {@link #target} and will {@link #start()} in parallel.\n     */\n    public FileDownloadQueueSet downloadTogether(BaseDownloadTask... tasks) {\n        this.isSerial = false;\n        this.tasks = tasks;\n\n        return this;\n\n    }\n\n    /**\n     * Form a queue with same {@link #target} and will {@link #start()} in parallel.","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/FileDownloadQueueSet.java#L33-L69","documentation":"FileDownloadQueueSet's constructor throws IllegalArgumentException when the target FileDownloadListener is null, since the queue set applies this single listener to every task in the set; a null listener would make the queue unusable.","triggerScenarios":"new FileDownloadQueueSet(null).","commonSituations":"Dynamically resolving the listener variable that ends up null; refactoring that removed the anonymous listener.","solutions":["Pass a non-null FileDownloadListener instance (often an anonymous subclass) to the constructor.","If you don't need callbacks, pass a no-op listener instead of null."],"exampleFix":"// before\nFileDownloadQueueSet set = new FileDownloadQueueSet(null);\n\n// after\nFileDownloadQueueSet set = new FileDownloadQueueSet(new FileDownloadListener() {\n    @Override protected void pending(BaseDownloadTask task, int soFarBytes, int totalBytes) {}\n    @Override protected void progress(BaseDownloadTask task, int soFarBytes, int totalBytes) {}\n    @Override protected void completed(BaseDownloadTask task) {}\n    @Override protected void paused(BaseDownloadTask task, int soFarBytes, int totalBytes) {}\n    @Override protected void error(BaseDownloadTask task, Throwable e) {}\n    @Override protected void warn(BaseDownloadTask task) {}\n});","handlingStrategy":"validation","validationCode":"if (listener == null) throw new IllegalArgumentException(\"queue set target required\");\nFileDownloadQueueSet set = new FileDownloadQueueSet(listener);","typeGuard":"boolean validTarget(FileDownloadListener l) { return l != null; }","tryCatchPattern":null,"preventionTips":["Assert listener non-null before constructing queue sets.","Use a shared no-op listener when callbacks are unneeded.","Initialize listener fields eagerly, not lazily."],"tags":["android","null-argument","queue-set"],"backgroundTag":"null-argument","analyzedSha":"6237a8cac174bcc916e4342b14ab1ab72a5768d4","analyzedAt":"2026-09-08T23:50:48.168Z","contentChangedAt":"2026-09-08T23:50:48.168Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}