{"record":{"id":"0e9b88bbf555df52","repo":"lingochamp/FileDownloader","slug":"sub-package-size-must-more-than-0","errorCode":null,"errorMessage":"sub package size must more than 0","messagePattern":"sub package size must more than 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/FileDownloader.java","lineNumber":176,"sourceCode":"\n    /**\n     * For avoiding missing screen frames.\n     * <p/>\n     * This mechanism is used for avoid methods in {@link FileDownloadListener} is invoked too\n     * frequent in result the system missing screen frames in the main thread.\n     * <p>\n     * We wrap the message package which size is {@link FileDownloadMessageStation#SUB_PACKAGE_SIZE}\n     * and post the package to the main thread with the interval:\n     * {@link FileDownloadMessageStation#INTERVAL} milliseconds.\n     * <p>\n     * The default count of message for a message package is 5.\n     *\n     * @param packageSize The count of message for a message package.\n     * @see #setGlobalPost2UIInterval(int)\n     */\n    public static void setGlobalHandleSubPackageSize(final int packageSize) {\n        if (packageSize <= 0) {\n            throw new IllegalArgumentException(\"sub package size must more than 0\");\n        }\n        FileDownloadMessageStation.SUB_PACKAGE_SIZE = packageSize;\n    }\n\n    /**\n     * Avoid missing screen frames, this leads to all callbacks in {@link FileDownloadListener} do\n     * not be invoked at once when it has already achieved to ensure callbacks don't be too frequent\n     *\n     * @see #isEnabledAvoidDropFrame()\n     * @see #setGlobalPost2UIInterval(int)\n     */\n    public static void enableAvoidDropFrame() {\n        setGlobalPost2UIInterval(FileDownloadMessageStation.DEFAULT_INTERVAL);\n    }\n\n    /**\n     * Disable avoiding missing screen frames, let all callbacks in {@link FileDownloadListener}\n     * can be invoked at once when it achieve.","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/FileDownloader.java#L158-L194","documentation":"Sentinel validation error thrown by setGlobalHandleSubPackageSize when the caller passes a sub-package size (the number of FileDownloadListener callbacks batched into one message posted to the main thread, default 5) that is zero or negative. It is a guard against an invalid global configuration: a non-positive batch size would break the message-station throttling mechanism used to avoid missing screen frames.","triggerScenarios":"Thrown at library/src/main/java/com/liulishuo/filedownloader/FileDownloader.java:176 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a positive integer greater than 0 for the sub-package size, e.g. FileDownloader.getImpl().setGlobalHandleSubPackageSize(5).","Validate the configured value before calling it and fall back to the default of 5 when it is not positive.","If you do not need to tune the batching, simply do not call setGlobalHandleSubPackageSize and keep the library default."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}