Skip to content

startGetConnAddressTimer会空指针异常 #37

@harry-ndroid

Description

@harry-ndroid

Attempt to invoke virtual method 'int java.util.Timer.purge()' on a null object reference
com.xinbida.wukongim.message.WKConnection$3 位置 run 行 572
checkNetWorkTimer.purge();这句代码报空指针异常了。
下面是ai建议的改法,供你们参考
// 先判断非空,再先 purge 后 cancel
if (checkNetWorkTimer != null) {
checkNetWorkTimer.purge(); // 先清除已取消的任务
checkNetWorkTimer.cancel(); // 再终止计时器
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions