在 RuntimeExceptions 上使用 List 的最佳方法是什么?

What are the best way to use a List on RuntimeExceptions?

我有一个扩展 RuntimeException 的异常,并且我有一个属性 List

public class ExperterBadRequestException extends RuntimeException {

private final List<String> errors;

像 Sonar 这样的自动评估工具会抛出严重错误:问题是 RuntimeExceptionsSerializable,而 List 是一个接口,而不是。

那我该怎么办?从 List 更改为 ArrayList(不相信),在这种情况下不应该使用 Lists 吗?为它制作 writeObjectreadObject?或者这个警告可能没有意义?

The problem is that RuntimeExceptions are Serializable, and List is an interface don't.

不,这不是问题。只要它被初始化为 List, 的可序列化实现,例如 JDK 中的任何一个,这就完全没有问题。

So what should I do?

没有。

Change from List to an ArrayList (don't believe that)

不需要。

should not use Lists in this case?

没有,为什么?

make an writeObject and readObject for it?

不需要。

如果您遇到了问题,则说明您没有说明实际情况。