qiurunze123/miaosha · error · GlobleException
10001
10001
Error message
系统错误
What it means
Thrown by MiaoShaUserService.login() (miaosha-v1) when the LoginVo argument is null. Maps to ResultStatus.SYSTEM_ERROR (code 10001, '系统错误' — 'System error'). This is a defensive null-check at the top of login(): a null LoginVo means the caller (typically a controller) failed to bind the request body, which is a programming or request-parsing error, not a user credential problem.
Source
Thrown at miaosha-v1/src/main/java/com/geekq/miaosha/service/MiaoShaUserService.java:114
try {
miaoShaUserDao.insertMiaoShaUser(miaoShaUser);
MiaoshaUser user = miaoShaUserDao.getByNickname(miaoShaUser.getNickname());
if (user == null) {
return false;
}
//生成cookie 将session返回游览器 分布式session
String token = UUIDUtil.uuid();
addCookie(response, token, user);
} catch (Exception e) {
logger.error("注册失败", e);
return false;
}
return true;
}
public boolean login(HttpServletResponse response, LoginVo loginVo) {
if (loginVo == null) {
throw new GlobleException(SYSTEM_ERROR);
}
String mobile = loginVo.getMobile();
String password = loginVo.getPassword();
MiaoshaUser user = getByNickName(mobile);
if (user == null) {
throw new GlobleException(MOBILE_NOT_EXIST);
}
String dbPass = user.getPassword();
String saltDb = user.getSalt();
String calcPass = MD5Utils.formPassToDBPass(password, saltDb);
if (!calcPass.equals(dbPass)) {
throw new GlobleException(PASSWORD_ERROR);
}
//生成cookie 将session返回游览器 分布式session
String token = UUIDUtil.uuid();
addCookie(response, token, user);View on GitHub (pinned to e58017658e)
Solutions
- Add @Valid on the LoginVo parameter in the controller so Spring rejects null/malformed bodies before reaching the service.
- Return a 400 Bad Request from the controller when loginVo is null instead of calling the service.
- In tests, always construct a LoginVo with setMobile() and setPassword() before calling login().
Example fix
// before
public boolean login(HttpServletResponse response, LoginVo loginVo) {
if (loginVo == null) {
throw new GlobleException(SYSTEM_ERROR);
}
...
}
// after — controller validates, service trusts input
@PostMapping("/do_login")
public ResultGeekQ<Boolean> doLogin(@RequestBody @Valid LoginVo loginVo,
HttpServletResponse response) {
return ResultGeekQ.build().setData(userService.login(response, loginVo));
} Defensive patterns
Strategy: validation
Validate before calling
// Controller-layer null check before calling login()
if (loginVo == null) {
return ResultGeekQ.error(ResultStatus.PARAM_ERROR);
}
return userService.login(response, loginVo); Type guard
// Ensure LoginVo is properly constructed before passing to login()
LoginVo vo = new LoginVo();
vo.setMobile(mobile);
vo.setPassword(password);
// type guard: both fields non-null and non-empty
if (vo.getMobile() == null || vo.getPassword() == null) {
throw new IllegalArgumentException("LoginVo fields must not be null");
} Try / catch
try {
userService.login(response, loginVo);
} catch (GlobleException e) {
if (e.getStatus() == ResultStatus.SYSTEM_ERROR) {
return ResultGeekQ.error(ResultStatus.PARAM_ERROR);
}
throw e;
} Prevention
- Add @Valid on the LoginVo controller parameter so Spring rejects null bodies with a 400.
- Always populate both mobile and password fields in test code.
- Use @NotNull JSR-303 annotations on LoginVo fields to catch binding failures early.
When it happens
Trigger: Calling login(response, null) directly, or a controller endpoint that passes an unbound/null LoginVo because the @ModelAttribute or @RequestBody mapping failed silently. Also occurs in unit tests that call login() without constructing a LoginVo.
Common situations: The login JSON body is malformed so Spring fails to deserialize LoginVo and the controller still invokes the service with null; a missing @Valid annotation lets an empty body through; integration test forgetting to populate the LoginVo.
Related errors
AI-assisted analysis of qiurunze123/miaosha@e58017658e (2026-08-14).
Data as JSON: /api/errors/a3a45f58898340b6.
Report an issue: GitHub.