{"record":{"id":"195d0de7400e2c74","repo":"jeecgboot/JeecgBoot","slug":"method","errorCode":null,"errorMessage":"method 不能为空","messagePattern":"method 不能为空","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":209,"sourceCode":"\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 参数\n        if (variables != null && !variables.isEmpty()) {\n            url += (\"?\" + asUrlVariables(variables));\n        }","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/RestUtil.java#L191-L227","documentation":"Thrown by RestUtil.request(String,HttpMethod,...) — the overload without a timeout parameter — when the method (HttpMethod) argument is null. A null HTTP method is rejected before the request is built.","triggerScenarios":"Calling RestUtil.request(url, method, ...) with method == null; method was derived from user/config input that was not mapped to an HttpMethod enum value.","commonSituations":"Caller passes a String method that failed to convert to HttpMethod; a switch/map mapping request method names returned null; default case missing when deriving HttpMethod.","solutions":["Pass a non-null HttpMethod (GET, POST, PUT, DELETE, etc.).","Map the incoming method string with a default of HttpMethod.GET or HttpMethod.POST when it is absent/unknown.","Validate method is non-null before the call."],"exampleFix":"// before\nHttpMethod method = mapMethod(request.getMethod()); // may be null\nRestUtil.request(url, method, headers, null, body, String.class);\n\n// after\nHttpMethod method = mapMethod(request.getMethod());\nif (method == null) {\n    method = HttpMethod.GET;\n}\nRestUtil.request(url, method, headers, null, body, String.class);","handlingStrategy":"validation","validationCode":"if (method == null) {\n    throw new IllegalArgumentException(\"method 不能为空\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    RestUtil.request(url, method, headers, variables, params, responseType);\n} catch (RuntimeException e) {\n    log.error(\"HTTP method 校验失败: {}\", e.getMessage());\n    return ResponseEntity.badRequest().build();\n}","preventionTips":["Always supply a non-null HttpMethod enum.","Provide a default method when mapping from strings.","Validate method before building the request."],"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"}