{"record":{"id":"8eb6179ba904d8ea","repo":"jeecgboot/JeecgBoot","slug":"url","errorCode":null,"errorMessage":"url 不能为空","messagePattern":"url 不能为空","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/RestUtil.java","lineNumber":206,"sourceCode":"    public static ResponseEntity<JSONObject> request(String url, HttpMethod method, JSONObject variables, JSONObject params) {\n        return request(url, method, getHeaderApplicationJson(), variables, params, JSONObject.class);\n    }\n\n    /**\n     * 发送请求\n     *\n     * @param url          请求地址\n     * @param method       请求方式\n     * @param headers      请求头  可空\n     * @param variables    请求url参数 可空\n     * @param params       请求body参数 可空\n     * @param responseType 返回类型\n     * @return ResponseEntity<responseType>\n     */\n    public static <T> ResponseEntity<T> request(String url, HttpMethod method, HttpHeaders headers, JSONObject variables, Object params, Class<T> responseType) {\n        log.debug(\" RestUtil  --- request ---  url = \"+ url);\n        if (StringUtils.isEmpty(url)) {\n            throw new RuntimeException(\"url 不能为空\");\n        }\n        if (method == null) {\n            throw new RuntimeException(\"method 不能为空\");\n        }\n        if (headers == null) {\n            headers = new HttpHeaders();\n        }\n        // 请求体\n        String body = \"\";\n        if (params != null) {\n            if (params instanceof JSONObject) {\n                body = ((JSONObject) params).toJSONString();\n\n            } else {\n                body = params.toString();\n            }\n        }\n        // 拼接 url 参数","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/RestUtil.java#L188-L224","documentation":"Thrown by RestUtil.request(String,HttpMethod,...) — the overload without a timeout parameter — when the url argument is null or empty (StringUtils.isEmpty). This is a precondition guard before constructing the HTTP request.","triggerScenarios":"Calling RestUtil.request(url, method, ...) where url is null, empty string, or blank; url was read from config that resolved to empty; url built from a template whose variable was unset.","commonSituations":"Configuration property for a downstream service URL missing in application yml; URL field left blank in an admin form that triggers an HTTP call; NPE upstream produced a null URL.","solutions":["Pass a non-empty, valid URL string; verify the source of the url value.","Read and validate the configured endpoint before calling RestUtil.request.","Default the URL to a known service address if it is optional.","Catch RuntimeException at the caller and return a clear error to the user."],"exampleFix":"// before\nRestUtil.request(serviceUrl, HttpMethod.POST, headers, null, body, String.class);\n\n// after\nif (StringUtils.isBlank(serviceUrl)) {\n    throw new IllegalArgumentException(\"serviceUrl 未配置\");\n}\nRestUtil.request(serviceUrl, HttpMethod.POST, headers, null, body, String.class);","handlingStrategy":"validation","validationCode":"if (StringUtils.isEmpty(url)) {\n    throw new IllegalArgumentException(\"url 不能为空\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    RestUtil.request(url, method, headers, variables, params, responseType);\n} catch (RuntimeException e) {\n    log.error(\"HTTP 请求参数校验失败: {}\", e.getMessage());\n    return ResponseEntity.badRequest().build();\n}","preventionTips":["Validate URL configuration at startup.","Default to a known service address when the URL is optional.","Never derive URLs from unchecked user input."],"tags":["http","rest","validation","precondition"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}