Java NullPointerException: The One Tiny Thing That’s Killing Your Chances of Solving
1.分解复杂的代码行
把多个对象放在不同行,在出现NullPointerException时,log就会准确的指出在哪一行哪一个对象为NULL
from
if ((user.isCustomer() != false) && (account.equals(id))) {
...
}
to
if ((user.isCustomer() != false) &&
(account.equals(id))) {
...
}