![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔记
mumuzsl
程序猿。
展开
-
通过Objects.equals避免NPE
参考:《新版Java开发手册》提到的三目运算符的空指针问题到底是个怎么回事? Integer a = null; boolean b1 = a == 1;// 报NPE, 原因:a要拆箱,即调用a.intValue()与1比较,这时a为null报NPE boolean b2 = a == (Object) 1;// false, 把1装箱,即从int变成Integer,a==(Object)1 ==> null==(Integer)1,不会报NPE boolean b3 = (Object) a =原创 2021-11-17 11:04:15 · 633 阅读 · 0 评论 -
Spring Security小记
两个configure方法在哪被调用 我们在编写Spring Security时配置类时,继承WebSecurityConfigurerAdapter,重写下面两个方法。 重写的两个方法在哪被调用了? 我觉得init(final WebSecurity web)一定会被调用,我没有深入。 以init方法调用下去,最终调用到了下面两个重写的方法。 @Override protected void configure(AuthenticationManagerBuilder auth) thro原创 2021-04-21 14:24:32 · 81 阅读 · 0 评论