{"record":{"id":"33fd9a33902ab594","repo":"jeecgboot/JeecgBoot","slug":"error-33fd9a","errorCode":null,"errorMessage":"操作失败，实体为空！","messagePattern":"操作失败，实体为空！","errorType":"exception","errorClass":"JeecgBootException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java","lineNumber":62,"sourceCode":"    @Override\n    public boolean edit(SysTableWhiteList sysTableWhiteList) {\n        this.checkEntity(sysTableWhiteList);\n        if (super.updateById(sysTableWhiteList)) {\n            // 清空缓存\n            whiteListHandler.clear();\n            return true;\n        }\n        return false;\n    }\n\n    /**\n     * 检查需要新增或更新的实体是否符合规范\n     *\n     * @param sysTableWhiteList\n     */\n    private void checkEntity(SysTableWhiteList sysTableWhiteList) {\n        if (sysTableWhiteList == null) {\n            throw new JeecgBootException(\"操作失败，实体为空！\");\n        }\n        if (oConvertUtils.isEmpty(sysTableWhiteList.getTableName())) {\n            throw new JeecgBootException(\"操作失败，表名不能为空！\");\n        }\n        if (oConvertUtils.isEmpty(sysTableWhiteList.getFieldName())) {\n            throw new JeecgBootException(\"操作失败，字段名不能为空！\");\n        }\n        // 将表名和字段名转换成小写\n        sysTableWhiteList.setTableName(sysTableWhiteList.getTableName().toLowerCase());\n        sysTableWhiteList.setFieldName(sysTableWhiteList.getFieldName().toLowerCase());\n        // 如果status为空，则默认启用\n        if (oConvertUtils.isEmpty(sysTableWhiteList.getStatus())) {\n            sysTableWhiteList.setStatus(CommonConstant.STATUS_1);\n        }\n    }\n\n    @Override\n    public boolean deleteByIds(String ids) {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java#L44-L80","documentation":"Thrown by SysTableWhiteListServiceImpl.checkEntity when the sysTableWhiteList parameter is null. This JeecgBootException is the first guard in the entity validation chain, preventing NPEs in subsequent field-access calls. checkEntity is a private method called before any insert or update operation.","triggerScenarios":"Calling the service's save or update method (which internally calls checkEntity) with a null SysTableWhiteList argument. The controller may have accepted a null body or the caller constructed the entity conditionally and passed null.","commonSituations":"API endpoint called with an empty request body; the controller's @RequestBody is not validated with @NotNull; programmatic caller has a null reference due to a conditional construction path.","solutions":["Add @Valid and @NotNull annotations on the controller's @RequestBody parameter to reject null at the API boundary.","Ensure the frontend always sends a valid JSON body, never an empty request.","If calling programmatically, perform a null check before calling the service method.","Add a global exception handler to convert this to a 400 Bad Request with a clear message."],"exampleFix":"// before\nprivate void checkEntity(SysTableWhiteList sysTableWhiteList) {\n    if (sysTableWhiteList == null) {\n        throw new JeecgBootException(\"操作失败，实体为空！\");\n    }\n    // ...\n}\n\n// after — controller validates at the boundary\n@PostMapping(\"/add\")\npublic Result<?> add(@Valid @RequestBody @NotNull SysTableWhiteList entity) {\n    service.save(entity);\n    return Result.OK();\n}","handlingStrategy":"validation","validationCode":"// Validate entity is non-null before calling service\nif (sysTableWhiteList == null) {\n    return Result.error(\"操作失败，请求数据为空\");\n}\nservice.save(sysTableWhiteList);","typeGuard":"public boolean isWhitelistEntityValid(SysTableWhiteList entity) {\n    return entity != null\n        && oConvertUtils.isNotEmpty(entity.getTableName())\n        && oConvertUtils.isNotEmpty(entity.getFieldName());\n}","tryCatchPattern":"try {\n    service.save(sysTableWhiteList);\n} catch (JeecgBootException e) {\n    if (e.getMessage().contains(\"实体为空\")) {\n        return Result.error(\"请求数据为空，请检查提交内容\");\n    }\n    throw e;\n}","preventionTips":["Add @NotNull and @Valid on the controller @RequestBody parameter.","Ensure the frontend always sends a valid JSON body.","Perform a null check before calling the service method."],"tags":["jeecg-boot","whitelist","null-check","validation","entity"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}