Correct Frontend{Client,History}Metadata deserialization
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardRecoveryCoordinator.java
index aeaad4880614445d4d708353c8644c1233a4e83d..87d70da1ab3a9c41b0898b7a8551242655b297ee 100644 (file)
@@ -105,7 +105,7 @@ abstract class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
         open = false;
     }
 
-    private File writeRoot(final String kind, final NormalizedNode<?, ?> node) {
+    private File writeRoot(final String kind, final NormalizedNode node) {
         final File file = new File(System.getProperty("karaf.data", "."),
             "failed-recovery-" + kind + "-" + shardName + ".xml");
         NormalizedNodeXMLOutput.toFile(file, node);
@@ -122,14 +122,15 @@ abstract class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
     public void applyRecoverySnapshot(final Snapshot.State snapshotState) {
         if (!(snapshotState instanceof ShardSnapshotState)) {
             log.debug("{}: applyRecoverySnapshot ignoring snapshot: {}", shardName, snapshotState);
+            return;
         }
 
         log.debug("{}: Applying recovered snapshot", shardName);
-
-        ShardDataTreeSnapshot shardSnapshot = ((ShardSnapshotState)snapshotState).getSnapshot();
+        final ShardSnapshotState shardSnapshotState = (ShardSnapshotState)snapshotState;
         try {
-            store.applyRecoverySnapshot(shardSnapshot);
+            store.applyRecoverySnapshot(shardSnapshotState);
         } catch (Exception e) {
+            final ShardDataTreeSnapshot shardSnapshot = shardSnapshotState.getSnapshot();
             final File f = writeRoot("snapshot", shardSnapshot.getRootNode().orElse(null));
             throw new IllegalStateException(String.format(
                     "%s: Failed to apply recovery snapshot %s. Node data was written to file %s",