{"record":{"id":"685a762ba2ee7cc7","repo":"jwtk/jjwt","slug":"map-must-not-be-null","errorCode":null,"errorMessage":"Map must not be null","messagePattern":"Map must not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/io/jsonwebtoken/lang/Collections.java","lineNumber":305,"sourceCode":"            throw new IllegalArgumentException(\"Collection must not be null\");\n        }\n        Object[] arr = Objects.toObjectArray(array);\n        java.util.Collections.addAll(collection, arr);\n    }\n\n    /**\n     * Merge the given Properties instance into the given Map,\n     * copying all properties (key-value pairs) over.\n     * <p>Uses <code>Properties.propertyNames()</code> to even catch\n     * default properties linked into the original Properties instance.\n     *\n     * @param props the Properties instance to merge (may be <code>null</code>)\n     * @param map   the target Map to merge the properties into\n     */\n    @SuppressWarnings(\"unchecked\")\n    public static void mergePropertiesIntoMap(Properties props, Map map) {\n        if (map == null) {\n            throw new IllegalArgumentException(\"Map must not be null\");\n        }\n        if (props != null) {\n            for (Enumeration en = props.propertyNames(); en.hasMoreElements(); ) {\n                String key = (String) en.nextElement();\n                Object value = props.getProperty(key);\n                if (value == null) {\n                    // Potentially a non-String value...\n                    value = props.get(key);\n                }\n                map.put(key, value);\n            }\n        }\n    }\n\n\n    /**\n     * Check whether the given Iterator contains the given element.\n     *","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/api/src/main/java/io/jsonwebtoken/lang/Collections.java#L287-L323","documentation":"IllegalArgumentException thrown by io.jsonwebtoken.lang.Collections.mergePropertiesIntoMap when the target Map argument is null. The Properties source may be null (that case is skipped), but the destination map must be provided.","triggerScenarios":"Calling Collections.mergePropertiesIntoMap(props, map) with a null map — e.g. an uninitialized Map field or a null returned from a config lookup.","commonSituations":"Forgetting to instantiate the target HashMap before merging; a builder/config accessor returning null; swapped arguments.","solutions":["Pass a non-null, mutable Map (e.g. new HashMap<>()) as the target","Verify argument order: null props is fine, null map is not","Initialize the map field before calling the merge"],"exampleFix":"// before\nCollections.mergePropertiesIntoMap(props, configMap); // configMap is null\n// after\nMap<String, Object> configMap = new HashMap<>();\nCollections.mergePropertiesIntoMap(props, configMap);","handlingStrategy":"validation","validationCode":"if (map == null) {\n    map = new HashMap<>();\n}\nCollections.mergePropertiesIntoMap(props, map);","typeGuard":null,"tryCatchPattern":"try {\n    Collections.mergePropertiesIntoMap(props, map);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Target map must be initialized before merge\", e);\n}","preventionTips":["Initialize the target map (e.g. new HashMap<>()) before merging","Remember null Properties are safely ignored; null Map is not","Guard builder/accessor methods so they never return null maps"],"tags":["null-argument","collections","precondition"],"backgroundTag":"null-argument","analyzedSha":"fb71496164c71442d08adec4571d9616ed5e1b8d","analyzedAt":"2026-09-09T00:33:09.982Z","contentChangedAt":"2026-09-09T00:33:09.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}