I have a custom exception class that extends a parent exception class. I also use generics in my constructor, but not on my exceptions, because exceptions cannot be generic. Ever since I did the inheritance/generics part, I have tried to generate new serialVersionUID numbers, but it keeps generating the same values in said classes, both parent and child. SpotBugs/Sonar keeps complaining that my class "defines a computed serialUID that doesn't equate to the calculated value". Has anyone ever faced a similar problem and is there a fix for it?
Asked
Active
Viewed 30 times
0
-
1These linter tools are wrong. You should not add `svUid` just because your type implements Serializable. Just generating it does only bad things: It makes it _look_ like your code supports compatibility between serializing/deserializing between different versions of your code, but unless you have tests for this, you clearly aren't really doing the work to guarantee that sort of thing. Just edit your linter settings and turn this check off, it's dumb. – rzwitserloot Feb 23 '22 at 15:25
-
Please add a sample code snippet. – Bimalesh Jha Feb 23 '22 at 17:27