Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DepotHeadService查询BUG #82

Open
nameof opened this issue Mar 11, 2023 · 2 comments
Open

DepotHeadService查询BUG #82

nameof opened this issue Mar 11, 2023 · 2 comments

Comments

@nameof
Copy link

nameof commented Mar 11, 2023

DepotHeadService中的方法

public DepotHead getDepotHead(String number)throws Exception {
        DepotHead depotHead = new DepotHead();
        try{
            DepotHeadExample example = new DepotHeadExample();
            example.createCriteria().andNumberEqualTo(number).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
            List<DepotHead> list = depotHeadMapper.selectByExample(example);
            if(null!=list && list.size()>0) {
                depotHead = list.get(0);
            }
        }catch(Exception e){
            JshException.readFail(logger, e);
        }
        return depotHead;
}

DepotHead depotHead = new DepotHead();意味着这个方法永远不会返回空,我观察到有几处调用应该都产生了潜在的BUG:在没有查询到数据时,也走了正常的处理流程。

@nameof
Copy link
Author

nameof commented Mar 11, 2023

我提交了一个PR,在没有查询到数据时返回null,如果这是一个确实存在的BUG,可以进行修复:通过NPE暴露异常,或调用方可以进行判空做逻辑处理。

如果这个逻辑是刻意为之则可以适当进行其它优化。

@nameof
Copy link
Author

nameof commented Mar 11, 2023

我提交了一个PR,在没有查询到数据时返回null,如果这是一个确实存在的BUG,可以进行修复:通过NPE暴露异常,或调用方可以进行判空做逻辑处理。

如果这个逻辑是刻意为之则可以适当进行其它优化。

#83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant