{"record":{"id":"043d74a28dfa09f7","repo":"lingochamp/FileDownloader","slug":"name-null","errorCode":null,"errorMessage":"name == null","messagePattern":"name == null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/model/FileDownloadHeader.java","lineNumber":41,"sourceCode":"import java.util.HashMap;\nimport java.util.List;\n\n/**\n * We have already handled Etag internal for guaranteeing tasks resuming from the breakpoint, in\n * other words, if the task has downloaded and got Etag, we will add the 'If-Match' and the 'Range'\n * K-V to its request header automatically.\n */\npublic class FileDownloadHeader implements Parcelable {\n\n    private HashMap<String, List<String>> mHeaderMap;\n\n    /**\n     * We have already handled etag, and will add 'If-Match' & 'Range' value if it works.\n     *\n     * @see com.liulishuo.filedownloader.download.ConnectTask#addUserRequiredHeader\n     */\n    public void add(String name, String value) {\n        if (name == null) throw new NullPointerException(\"name == null\");\n        if (name.isEmpty()) throw new IllegalArgumentException(\"name is empty\");\n        if (value == null) throw new NullPointerException(\"value == null\");\n\n        if (mHeaderMap == null) {\n            mHeaderMap = new HashMap<>();\n        }\n\n        List<String> values = mHeaderMap.get(name);\n        if (values == null) {\n            values = new ArrayList<>();\n            mHeaderMap.put(name, values);\n        }\n\n        if (!values.contains(value)) {\n            values.add(value);\n        }\n    }\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/model/FileDownloadHeader.java#L23-L59","documentation":"A precondition check inside FileDownloadHeader.add: a request header cannot be registered without a name, so passing a null header name is rejected (typically IllegalArgumentException). The faulty input is the 'name' argument of add(name, value).","triggerScenarios":"Thrown at library/src/main/java/com/liulishuo/filedownloader/model/FileDownloadHeader.java:41 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-null header name, e.g. header.add(\"User-Agent\", value)","Null-check the header name before calling add when it comes from dynamic/user input","Build headers only from known constants rather than external unvalidated strings"],"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"}