简体   繁体   English

如何解决声纳可序列化问题?

[英]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.

相关问题 如何解决声纳问题 squid:ForLoopCounterChangedCheck? - How to fix sonar issue squid:ForLoopCounterChangedCheck? 如何修复Private构造函数的Sonar问题? - How to fix Sonar issue for Private constructor? 如何解决Sonar问题“将此呼叫删除为“ wait”或将其移至“ while”循环”? - How to fix Sonar issue “Remove this call to ”wait“ or move it into a ”while“ loop”? 如何解决“物业价值应该有效”的声纳问题: - How to fix sonar issue for “Property value should be valid”: 如何解决 java 8 中的“Lambdas 应替换为方法引用”声纳问题? - How to fix this 'Lambdas should be replaced with method references' sonar issue in java 8? 如何在声纳中解决此“可能的 null 指针取消引用”关键问题? - How to fix this "possible null pointer dereference" critical issue in Sonar? 恶意代码漏洞-字段应受程序包保护。 如何解决这个声纳问题? - Malicious code vulnerability - Field should be package protected. How to fix this sonar issue? 如何解决用Java API中的类替换Sun类用法的声纳问题? - How to fix sonar issue for Replace this usage of Sun classes by ones from the Java API? 如何修复 Pattern.compile(regex, Pattern.CASE_INSENSITIVE) 上的声纳关键问题; - How to fix the Sonar critical issue on Pattern.compile(regex, Pattern.CASE_INSENSITIVE); 声纳“Make transient or serializable”错误 - Sonar "Make transient or serializable" error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM