do not explicit serialVersionUID anymore 82/92582/2
authorguillaume.lambert <guillaume.lambert@orange.com>
Tue, 22 Sep 2020 08:11:12 +0000 (10:11 +0200)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Fri, 2 Oct 2020 09:59:26 +0000 (09:59 +0000)
A new SpotBug rule has been introduced in odlparent Aluminium and
suggests to explicit the serialVersionUID in serializable classes to
avoid compilers interoperability problems due to a Java implementation
design flaw.

If this is useful in a few situations (rare today), this also means that
theorically developers must maintain this field and increment it across
classes incompatible versions.
Practically, this step is often forgotten, paving the way to more
serious problems.
Since the situation here does not require it, it is healthier to simply
ignore this (soon obsolete?) recommendation.

For more details:
git log pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java
https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID
https://moi.vonos.net/java/serialization-synthetic/
https://rules.sonarsource.com/java/RSPEC-4926
https://www.vojtechruzicka.com/explicitly-declare-serialversionuid/
https://www.infoworld.com/article/3275924/oracle-plans-to-dump-risky-java-serialization.html

JIRA: TRNSPRTPCE-292
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I4e36134061104d912a75f3a578d43ca0bc17ab1f

common/src/main/java/org/opendaylight/transportpce/common/mapping/SortPort121ByName.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/SortPort221ByName.java
lighty/src/main/java/io/lighty/controllers/tpce/exception/TechnicalException.java
pce/src/main/java/org/opendaylight/transportpce/pce/SortPortsByName.java
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraphEdge.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java

index 484053b2ccf1edf6e3dacbf0e7904cf87210d188..1ac0c32878e423986be11fa5a5bb372b0aafb1a7 100644 (file)
@@ -18,10 +18,11 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.Port;
  * @author Martial Coulibaly (martial.coulibaly@gfi.com) on behalf of Orange
  *
  */
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+    value = "SE_NO_SERIALVERSIONID",
+    justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
 public class SortPort121ByName implements Comparator<Port>, Serializable {
 
-    private static final long serialVersionUID = 1L;
-
     @Override
     public int compare(Port port1, Port port2) {
         return extractInt(port1) - extractInt(port2);
index 6c31cec940e237442b4769255738d1e7bb092f6b..48de1f3c715e7996a6cb8fed16b20afb77e5aff0 100644 (file)
@@ -18,10 +18,11 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.Port;
  * @author Martial Coulibaly (martial.coulibaly@gfi.com) on behalf of Orange
  *
  */
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+    value = "SE_NO_SERIALVERSIONID",
+    justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
 public class SortPort221ByName implements Comparator<Port>, Serializable {
 
-    private static final long serialVersionUID = 1L;
-
     @Override
     public int compare(Port port1, Port port2) {
         return extractInt(port1) - extractInt(port2);
index 4fa2f93e849bdbf0b9d98ab49f9a704e3e42f17e..44aa827ecb468d45c0fc7392521b2e00101d79e8 100644 (file)
@@ -7,13 +7,11 @@
  */
 package io.lighty.controllers.tpce.exception;
 
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+    value = "SE_NO_SERIALVERSIONID",
+    justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
 public class TechnicalException extends RuntimeException {
 
-    /**
-     * serial id.
-     */
-    private static final long serialVersionUID = 1359762809539335449L;
-
     /**
      * Default constructor.
      */
index 642df21a07103f397bf825036de5986a13efcb27..317451b595aa0e2ab779d76587c910844f9c8f43 100644 (file)
@@ -16,10 +16,11 @@ import java.util.Comparator;
  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
  *
  */
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+    value = "SE_NO_SERIALVERSIONID",
+    justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
 public class SortPortsByName implements Comparator<String>, Serializable {
 
-    private static final long serialVersionUID = 1L;
-
     @Override
     public int compare(String port1, String port2) {
         int num = extractInt(port1) - extractInt(port2);
index 78861c5e74a6a9a3b5496deb954bdca330327697..87adfcce44cd35938c387521c183cb6a153d67d6 100644 (file)
@@ -10,9 +10,11 @@ package org.opendaylight.transportpce.pce.graph;
 import org.jgrapht.graph.DefaultWeightedEdge;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
 
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+    value = "SE_NO_SERIALVERSIONID",
+    justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
 public class PceGraphEdge extends DefaultWeightedEdge {
 
-    private static final long serialVersionUID = 1L;
     private PceLink link;
 
     public PceGraphEdge(PceLink link) {
index 720ffcd013e844c19e84cd5574263e59175080d6..cf303055bb2d6e0ebec098a88f9f3154787a51be 100644 (file)
@@ -30,9 +30,11 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.top
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+    value = "SE_NO_SERIALVERSIONID",
+    justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
 public class PceLink implements Serializable {
 
-    private static final long serialVersionUID = 1L;
     /* Logging. */
     private static final Logger LOG = LoggerFactory.getLogger(PceLink.class);
     ///////////////////////// LINKS ////////////////////