[英]How to fix sonar Serializable issue?
I have a code snippet where I getting critical code smell from sonar because exception implements serializable.我有一个代码片段,因为异常实现了可序列化,所以我从声纳中获得了关键的代码气味。 This code work fine in production for a long time and I can't see any issues from Sonar doc: "For instance, under load, most J2EE application frameworks flush objects to disk, and an allegedly Serializable object with non-transient, non-serializable data members could cause program crashes".
这段代码在生产环境中工作了很长时间,我从 Sonar 文档中看不到任何问题:“例如,在负载下,大多数 J2EE 应用程序框架将对象刷新到磁盘,并且据称可序列化 object可序列化的数据成员可能会导致程序崩溃”。 Do you face with code crashes in your application with this sonar issue?
您是否因此声纳问题而在应用程序中遇到代码崩溃?
If you don't plan to de/serialize the entries
field use the transient
keyword:如果您不打算对
entries
字段进行反序列化/序列化,请使用transient
关键字:
private final transient List<Objects> entries = new ArrayList<>();
Otherwise, you have to implement a custom de/serialization , however, I am not sure it would resolve the Sonar issue.否则,您必须实现自定义反序列化,但是,我不确定它是否能解决声纳问题。 The keyword
transient
does resolve the Sonar issue.关键字
transient
确实解决了声纳问题。
J2EE application frameworks flush objects to disk
J2EE 应用程序框架将对象刷新到磁盘
It depends whether the object OuterException
itself is actually de/serialized.这取决于 object
OuterException
本身是否实际被反序列化。 I doubt J2EE serializes custom objects made by yourself without being told to do so.我怀疑 J2EE 会在没有被告知的情况下序列化您自己制作的自定义对象。 Actually, feel free to close the issue with the " Won't Fix " resolution and an appropriate comment, which is no wrong.
实际上,请随意使用“ Won't Fix ”解决方案和适当的评论来关闭问题,这没有错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.