1
1
bug
bug
类型
类型
1.1
1.1
".equals()"
".equals()"
should
should
not
not
be
be
used
used
to
to
test
test
the
the
values
values
of
of
"Atomic"
"Atomic"
classes.
classes.
bug 主要
AtomicInteger 和 AtomicLong 扩展 Number,但它们与 Integer 和 Long 不同,因此应以
不同的方式处理。 AtomicInteger 和 AtomicLong 旨在支持对单个变量进行无锁的线程安全
编程。 这样,AtomicInteger 将永远只与自身“相等”。 相反,您应该.get()值并对其进
行比较。
1.2
1.2
"=+"
"=+"
should
should
not
not
be
be
used
used
instead
instead
of
of
"+="
"+="
bug 主要
使用运算符对(= +,=-或=!)会编译并运行,但不会产生预期的结果,而这意味着使
用反向的单个运算符(+ =,-=或!=)。
当= +,=-或=!时,此规则会引起问题。 在两个运算符之间没有空格且之后至少有一个空
格字符时使用。
1.3
1.3
"@Controller"
"@Controller"
classes
classes
that
that
use
use
"@SessionAttributes"
"@SessionAttributes"
must
must
call
call
"setComplete"
"setComplete"
on
on
their
their
"SessionStatus"
"SessionStatus"
objects
objects
bug 阻断
使用@SessionAttributes 的 Spring @Controller 旨在处理有状态/多帖子形式。 这样的
@Controller 使用指定的@SessionAttributes 在两次请求之间将数据存储在服务器上。 会
话结束时,应该清除该数据,但是除非从@RequestMapping 方法在 SessionStatus 对象上
调用 setComplete(),否则 Spring 和 JVM 都不知道是时候这样做了。 请注意,必须将
SessionStatus 对象作为参数传递给该方法。
1.4
1.4
"@NonNull"
"@NonNull"
values
values
should
should
not
not
be
be
set
set
to
to
null
null
bug 次要
标记为@ NotNull,@ NonNull 或@Nonnull 的字段,参数和返回值假定为具有非 null 值,
并且在使用前通常不进行 null 检查。 因此,将这些值之一设置为 null 或未能在构造函数中
设置此类类字段,可能会在运行时导致 NullPointerExceptions。
1.5
1.5
"@SpringBootApplication"
"@SpringBootApplication"
and
and
"@ComponentScan"
"@ComponentScan"
should
should
not
not
be
be
used
used
in
in
the
the
default
default
package
package
bug 阻断