Make fields of UpdateFailedException transient 26/9526/1
authorMarek Gradzki <mgradzki@cisco.com>
Wed, 22 Nov 2017 14:38:23 +0000 (15:38 +0100)
committerMarek Gradzki <mgradzki@cisco.com>
Wed, 22 Nov 2017 14:38:26 +0000 (15:38 +0100)
Exceptions are Serializable.
Fields of Serializable class must be either Serializable or transient.

But DataObjects are not serializable, and there is really no reason to
serialize UpdateFailedException.

This patch excludes fields of the UpdateFailedException
from serialization process to fix Sonar warnings.

Change-Id: I1eb9408289241bb4fe6f712ed9208f8460eef317
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/UpdateFailedException.java

index efb8dd5..c5848f2 100644 (file)
@@ -23,12 +23,15 @@ import javax.annotation.Nonnull;
 
 /**
  * Thrown when CRUD operation fails.
+ *
+ * Serialization/deserialization of this exception would cause
+ * {@link #getProcessed()} and {@link #getFailed()} to return null.
  */
 public class UpdateFailedException extends TranslationException {
 
     private static final long serialVersionUID = 896331856485410043L;
-    private final List<DataObjectUpdate> processed;
-    private final DataObjectUpdate failed;
+    private transient final List<DataObjectUpdate> processed;
+    private transient final DataObjectUpdate failed;
 
     /**
      * @param cause     original cause of failure