{"record":{"id":"be2be48cab62625b","repo":"apache/dubbo","slug":"url-null-be2be4","errorCode":null,"errorMessage":"url == null","messagePattern":"url == null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java","lineNumber":610,"sourceCode":"            arr[2] = serviceKey.substring(j + 1);\n            serviceKey = serviceKey.substring(0, j);\n        }\n        arr[1] = serviceKey;\n        return arr;\n    }\n\n    /**\n     * NOTICE: This method allocate too much objects, we can use {@link URLStrParser#parseDecodedStr(String)} instead.\n     * <p>\n     * Parse url string\n     *\n     * @param url URL string\n     * @return URL instance\n     * @see URL\n     */\n    public static URL valueOf(String url) {\n        if (url == null || (url = url.trim()).length() == 0) {\n            throw new IllegalArgumentException(\"url == null\");\n        }\n        String protocol = null;\n        String username = null;\n        String password = null;\n        String host = null;\n        int port = 0;\n        String path = null;\n        Map<String, String> parameters = null;\n        int i = url.indexOf('?'); // separator between body and parameters\n        if (i >= 0) {\n            String[] parts = url.substring(i + 1).split(\"&\");\n            parameters = new HashMap<>();\n            for (String part : parts) {\n                part = part.trim();\n                if (part.length() > 0) {\n                    int j = part.indexOf('=');\n                    if (j >= 0) {\n                        String key = part.substring(0, j);","sourceCodeStart":592,"sourceCodeEnd":628,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java#L592-L628","documentation":"Thrown by UrlUtils.valueOf(String url) when the url argument is null or empty after trimming. This method parses a raw Dubbo URL string (protocol://user:password@host:port/path?params) into a URL instance. A null/blank URL means the caller has no valid endpoint string.","triggerScenarios":"Calling UrlUtils.valueOf(null) or UrlUtils.valueOf(\"\"); the URL string was loaded from a deserialized object, cache, or config that returned null/empty; URL passed from a query parameter that was absent.","commonSituations":"Deserialization of a cached URL string that expired or was never set; URL read from a URLStrParser result that returned null; configuration property for a provider/consumer URL not set.","solutions":["Null/empty-check before calling: if (url != null && !url.trim().isEmpty()) { UrlUtils.valueOf(url); }.","Trace the source of the URL string — check cache, config, or deserialization logic.","Prefer URLStrParser.parseDecodedStr as the method's Javadoc suggests for efficiency."],"exampleFix":"// before\nURL u = UrlUtils.valueOf(cachedUrlStr);\n\n// after\nif (cachedUrlStr == null || cachedUrlStr.trim().isEmpty()) {\n    throw new IllegalStateException(\"URL string is missing\");\n}\nURL u = UrlUtils.valueOf(cachedUrlStr);","handlingStrategy":"validation","validationCode":"if (url == null || url.trim().isEmpty()) {\n    throw new IllegalStateException(\"URL string is missing or blank\");\n}\nURL parsed = UrlUtils.valueOf(url);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check URL strings loaded from cache, config, or deserialization before parsing.","Consider using URLStrParser.parseDecodedStr for better performance as the Javadoc suggests."],"tags":["url-parsing","null-check","dubbo-common"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}