Some fixes for the DPOR state-reducer.
[jpf-core.git] / src / main / gov / nasa / jpf / listener / StateReducer.java
index 08b27b1e7b91da07d1e66401b67d745d6b2ca81c..71eaf325f2022190bd8da2d1e3f4aa5ba612107e 100644 (file)
@@ -34,7 +34,17 @@ import java.util.*;
 // TODO: Fix for Groovy's model-checking
 // TODO: This is a setter to change the values of the ChoiceGenerator to implement POR
 /**
- * simple tool to log state changes
+ * Simple tool to log state changes.
+ *
+ * This DPOR implementation is augmented by the algorithm presented in this SPIN paper:
+ * http://spinroot.com/spin/symposia/ws08/spin2008_submission_33.pdf
+ *
+ * The algorithm is presented on page 11 of the paper. Basically, we create a graph G
+ * (i.e., visible operation dependency graph)
+ * that maps inter-related threads/sub-programs that trigger state changes.
+ * The key to this approach is that we evaluate graph G in every iteration/recursion to
+ * only update the backtrack sets of the threads/sub-programs that are reachable in graph G
+ * from the currently running thread/sub-program.
  */
 public class StateReducer extends ListenerAdapter {
 
@@ -52,20 +62,40 @@ public class StateReducer extends ListenerAdapter {
   private IntChoiceFromSet currCG;
   private int choiceCounter;
   private Integer choiceUpperBound;
+  private Integer maxUpperBound;
   private boolean isInitialized;
   private boolean isResetAfterAnalysis;
   private boolean isBooleanCGFlipped;
-  private HashMap<IntChoiceFromSet,Integer> cgMap;
+  private HashMap<IntChoiceFromSet, Integer> cgMap;
   // Record the mapping between event number and field accesses (Read and Write)
-  private HashMap<Integer,ReadWriteSet> readWriteFieldsMap;
+  private HashMap<Integer, ReadWriteSet> readWriteFieldsMap;
   // The following is the backtrack map (set) that stores all the backtrack information
   // e.g., event number 1 can have two backtrack sequences: {3,1,2,4,...} and {2,1,3,4,...}
-  private HashMap<Integer,LinkedList<Integer[]>> backtrackMap;
-  private HashMap<Integer,HashSet<Integer>> conflictPairMap;
+  private HashMap<Integer, LinkedList<Integer[]>> backtrackMap;
+  // Stores explored backtrack lists in the form of HashSet of Strings
+  private HashSet<String> backtrackSet;
+  private HashMap<Integer, HashSet<Integer>> conflictPairMap;
   // Map choicelist with start index
-  private HashMap<Integer[],Integer> choiceListStartIndexMap;
-
-  public StateReducer (Config config, JPF jpf) {
+  //  private HashMap<Integer[],Integer> choiceListStartIndexMap;
+
+  // Map that represents graph G
+  // (i.e., visible operation dependency graph (VOD Graph)
+  private HashMap<Integer, HashSet<Integer>> vodGraphMap;
+  // Set that represents hash table H
+  // (i.e., hash table that records encountered states)
+  // VOD graph is updated when the state has not yet been seen
+  // Current state
+  private int stateId;
+  // Previous state
+  private int prevStateId;
+  // Previous choice number
+  private int prevChoiceValue;
+  // Counter for a visited state
+  private HashMap<Integer, Integer> visitedStateCounter;
+  // HashSet that stores references to unused CGs
+  private HashSet<IntChoiceFromSet> unusedCG;
+
+  public StateReducer(Config config, JPF jpf) {
     debugMode = config.getBoolean("debug_state_transition", false);
     stateReductionMode = config.getBoolean("activate_state_reduction", true);
     if (debugMode) {
@@ -78,6 +108,17 @@ public class StateReducer extends ListenerAdapter {
     id = 0;
     transition = null;
     isBooleanCGFlipped = false;
+    vodGraphMap = new HashMap<>();
+    stateId = -1;
+    prevStateId = -1;
+    prevChoiceValue = -1;
+    cgMap = new HashMap<>();
+    readWriteFieldsMap = new HashMap<>();
+    backtrackMap = new HashMap<>();
+    backtrackSet = new HashSet<>();
+    conflictPairMap = new HashMap<>();
+    unusedCG = new HashSet<>();
+    visitedStateCounter = new HashMap<>();
     initializeStateReduction();
   }
 
@@ -87,13 +128,14 @@ public class StateReducer extends ListenerAdapter {
       currCG = null;
       choiceCounter = 0;
       choiceUpperBound = 0;
+      maxUpperBound = 0;
       isInitialized = false;
       isResetAfterAnalysis = false;
-      cgMap = new HashMap<>();
-      readWriteFieldsMap = new HashMap<>();
-      backtrackMap = new HashMap<>();
-      conflictPairMap = new HashMap<>();
-      choiceListStartIndexMap = new HashMap<>();
+      cgMap.clear();
+      readWriteFieldsMap.clear();
+      backtrackMap.clear();
+      backtrackSet.clear();
+      conflictPairMap.clear();
     }
   }
 
@@ -118,7 +160,7 @@ public class StateReducer extends ListenerAdapter {
   }
 
   @Override
-  public void choiceGeneratorRegistered (VM vm, ChoiceGenerator<?> nextCG, ThreadInfo currentThread, Instruction executedInstruction) {
+  public void choiceGeneratorRegistered(VM vm, ChoiceGenerator<?> nextCG, ThreadInfo currentThread, Instruction executedInstruction) {
     if (stateReductionMode) {
       // Initialize with necessary information from the CG
       if (nextCG instanceof IntChoiceFromSet) {
@@ -131,24 +173,37 @@ public class StateReducer extends ListenerAdapter {
           isInitialized = true;
         }
         // Record the subsequent Integer CGs only until we hit the upper bound
-        if (!isResetAfterAnalysis && choiceCounter <= choiceUpperBound && !cgMap.containsValue(choiceCounter)) {
-          // Update the choices of the first CG and add '-1'
-          if (choices == null) {
-            // All the choices are always the same so we only need to update it once
-            choices = new Integer[cgChoices.length + 1];
-            System.arraycopy(cgChoices, 0, choices, 0, cgChoices.length);
-            choices[choices.length - 1] = -1;
+        if (!isResetAfterAnalysis) {
+          if (choiceCounter <= choiceUpperBound && !cgMap.containsValue(choiceCounter)) {
+            // Update the choices of the first CG and add '-1'
+            if (choices == null) {
+              // Initialize backtrack set that stores all the explored backtrack lists
+              maxUpperBound = cgChoices.length;
+              // All the choices are always the same so we only need to update it once
+              choices = new Integer[cgChoices.length + 1];
+              System.arraycopy(cgChoices, 0, choices, 0, cgChoices.length);
+              choices[choices.length - 1] = -1;
+              String firstChoiceListString = buildStringFromChoiceList(choices);
+              backtrackSet.add(firstChoiceListString);
+            }
+            icsCG.setNewValues(choices);
+            icsCG.reset();
+            // Advance the current Integer CG
+            // This way we explore all the event numbers in the first pass
+            icsCG.advance(choices[choiceCounter]);
+            cgMap.put(icsCG, choices[choiceCounter]);
+          } else {
+            // We repeat the same trace if a state match is not found yet
+            icsCG.setNewValues(choices);
+            icsCG.reset();
+            // Use a modulo since choiceCounter is going to keep increasing
+            int choiceIndex = choiceCounter % (choices.length - 1);
+            icsCG.advance(choices[choiceIndex]);
+            unusedCG.add(icsCG);
           }
-          icsCG.setNewValues(choices);
-          icsCG.reset();
-          // Advance the current Integer CG
-          // This way we explore all the event numbers in the first pass
-          icsCG.advance(choices[choiceCounter]);
-          cgMap.put(icsCG, choices[choiceCounter]);
           choiceCounter++;
         } else {
-          // Set done the subsequent CGs
-          // We only need n CGs (n is event numbers)
+          // Set new CGs to done so that the search algorithm explores the existing CGs
           icsCG.setDone();
         }
       }
@@ -160,10 +215,14 @@ public class StateReducer extends ListenerAdapter {
     Set<Integer> eventSet = backtrackMap.keySet();
     // Return if there is no conflict at all (highly unlikely)
     if (eventSet.isEmpty()) {
+      // Set every CG to done!
+      for (IntChoiceFromSet cg : cgMap.keySet()) {
+        cg.setDone();
+      }
       return;
     }
     // Reset every CG with the first backtrack lists
-    for(IntChoiceFromSet cg : cgMap.keySet()) {
+    for (IntChoiceFromSet cg : cgMap.keySet()) {
       int event = cgMap.get(cg);
       LinkedList<Integer[]> choiceLists = backtrackMap.get(event);
       if (choiceLists != null && choiceLists.peekFirst() != null) {
@@ -175,12 +234,37 @@ public class StateReducer extends ListenerAdapter {
         cg.setDone();
       }
     }
+    // Set done every CG in the unused CG set
+    for (IntChoiceFromSet cg : unusedCG) {
+      cg.setDone();
+    }
+    unusedCG.clear();
+  }
+
+  private void incrementVisitedStateCounter(int stId) {
+    // Increment counter for this state ID
+    if (visitedStateCounter.containsKey(stId)) {
+      int stateCount = visitedStateCounter.get(stId);
+      visitedStateCounter.put(stId, stateCount + 1);
+    } else {
+      // If we have seen it then the frequency is 2
+      visitedStateCounter.put(stId, 2);
+    }
+  }
+
+  private boolean isVisitedMultipleTimes(int stId) {
+    // Return true if the state has been visited more than once
+    if (visitedStateCounter.containsKey(stId) &&
+            visitedStateCounter.get(stId) > 1) {
+      return true;
+    }
+    return false;
   }
 
   @Override
-  public void choiceGeneratorAdvanced (VM vm, ChoiceGenerator<?> currentCG) {
+  public void choiceGeneratorAdvanced(VM vm, ChoiceGenerator<?> currentCG) {
 
-    if(stateReductionMode) {
+    if (stateReductionMode) {
       // Check the boolean CG and if it is flipped, we are resetting the analysis
       if (currentCG instanceof BooleanChoiceGenerator) {
         if (!isBooleanCGFlipped) {
@@ -195,42 +279,69 @@ public class StateReducer extends ListenerAdapter {
         IntChoiceFromSet icsCG = (IntChoiceFromSet) currentCG;
         // Update the current pointer to the current set of choices
         if (choices == null || choices != icsCG.getAllChoices()) {
-          choiceListStartIndexMap.remove(choices);
           currCG = icsCG;
           choices = icsCG.getAllChoices();
           // Reset a few things for the sub-graph
-          conflictPairMap = new HashMap<>();
-          readWriteFieldsMap = new HashMap<>();
+          conflictPairMap.clear();
+          readWriteFieldsMap.clear();
           choiceCounter = 0;
         }
-        // Traverse the sub-graphs
-        if (isResetAfterAnalysis) {
-          // Advance choice counter for sub-graphs
-          choiceCounter++;
-          // Do this for every CG after finishing each backtrack list
-          if (icsCG.getNextChoice() == -1) {
-            int event = cgMap.get(icsCG);
-            LinkedList<Integer[]> choiceLists = backtrackMap.get(event);
-            if (choiceLists != null && choiceLists.peekFirst() != null) {
-              Integer[] choiceList = choiceLists.removeFirst();
-              // Deploy the new choice list for this CG
-              icsCG.setNewValues(choiceList);
-              icsCG.reset();
-            } else {
-              // Set done if this was the last backtrack list
-              icsCG.setDone();
+        if (!vm.isNewState()) {
+          incrementVisitedStateCounter(stateId);
+        }
+        // Check if we have seen this state and it's not looping back to itself
+        if (prevStateId != -1 && stateId != prevStateId && isVisitedMultipleTimes(stateId)) {
+          // Traverse the sub-graphs
+          if (isResetAfterAnalysis) {
+            // Advance choice counter for sub-graphs
+            choiceCounter++;
+            // Do this for every CG after finishing each backtrack list
+            // We try to update the CG with a backtrack list if the state has been visited multiple times
+            if ((icsCG.getNextChoice() == -1 || choiceCounter > 1) && cgMap.containsKey(icsCG)) {
+              int event = cgMap.get(icsCG);
+              LinkedList<Integer[]> choiceLists = backtrackMap.get(event);
+              if (choiceLists != null && choiceLists.peekFirst() != null) {
+                Integer[] choiceList = choiceLists.removeFirst();
+                // Deploy the new choice list for this CG
+                icsCG.setNewValues(choiceList);
+                icsCG.reset();
+              } else {
+                // Set done if this was the last backtrack list
+                icsCG.setDone();
+              }
             }
+          } else {
+            // Update and reset the CG if needed (do this for the first time after the analysis)
+            // Start backtracking if this is a visited state and it is not a repeating state
+            resetAllCGs();
+            isResetAfterAnalysis = true;
           }
         }
-        // Update and reset the CG if needed (do this for the first time after the analysis)
-        if (!isResetAfterAnalysis && icsCG.getNextChoice() == -1) {
-          resetAllCGs();
-          isResetAfterAnalysis = true;
-        }
       }
     }
   }
 
+  public void updateVODGraph(int prevChoice, int currChoice) {
+
+    HashSet<Integer> choiceSet;
+    if (vodGraphMap.containsKey(prevChoice)) {
+      // If the key already exists, just retrieve it
+      choiceSet = vodGraphMap.get(prevChoice);
+    } else {
+      // Create a new entry
+      choiceSet = new HashSet<>();
+      vodGraphMap.put(prevChoice, choiceSet);
+    }
+    choiceSet.add(currChoice);
+  }
+
+  private void updateStateId(Search search) {
+    // Saving the previous state
+    prevStateId = stateId;
+    // Line 19 in the paper page 11 (see the heading note above)
+    stateId = search.getStateId();
+  }
+
   @Override
   public void stateAdvanced(Search search) {
     if (debugMode) {
@@ -250,6 +361,31 @@ public class StateReducer extends ListenerAdapter {
       out.println("\n==> DEBUG: The state is forwarded to state with id: " + id + " with depth: " + depth +
               " which is " + detail + " Transition: " + transition + "\n");
     }
+    if (stateReductionMode) {
+      // Update vodGraph
+      int currChoice = choiceCounter - 1;
+      // Adjust currChoice with modulo
+      currChoice = currChoice >= 0 ? currChoice % (choices.length -1) : currChoice;
+      if (currChoice < 0 || choices[currChoice] == -1 ||
+              prevChoiceValue == choices[currChoice]) {
+//              || currChoice > choices.length - 1 || choices[currChoice] == -1 ||
+//              prevChoiceValue == choices[currChoice]) {
+//        // When current choice is 0, previous choice could be -1
+//        updateVODGraph(prevChoiceValue, choices[currChoice]);
+//        // Current choice becomes previous choice in the next iteration
+//        prevChoiceValue = choices[currChoice];
+        // Update the state ID variables
+        updateStateId(search);
+        // Handle all corner cases (e.g., out of bound values)
+        return;
+      }
+      // When current choice is 0, previous choice could be -1
+      updateVODGraph(prevChoiceValue, choices[currChoice]);
+      // Current choice becomes previous choice in the next iteration
+      prevChoiceValue = choices[currChoice];
+      // Update the state ID variables
+      updateStateId(search);
+    }
   }
 
   @Override
@@ -260,6 +396,12 @@ public class StateReducer extends ListenerAdapter {
       transition = search.getTransition();
       detail = null;
 
+      // Update the state variables
+      // Saving the previous state
+      prevStateId = stateId;
+      // Line 19 in the paper page 11 (see the heading note above)
+      stateId = search.getStateId();
+
       out.println("\n==> DEBUG: The state is backtracked to state with id: " + id + " -- Transition: " + transition +
               " and depth: " + depth + "\n");
     }
@@ -276,8 +418,8 @@ public class StateReducer extends ListenerAdapter {
   // We store the field name and its object ID
   // Sharing the same field means the same field name and object ID
   private class ReadWriteSet {
-    private HashMap<String,Integer> readSet;
-    private HashMap<String,Integer> writeSet;
+    private HashMap<String, Integer> readSet;
+    private HashMap<String, Integer> writeSet;
 
     public ReadWriteSet() {
       readSet = new HashMap<>();
@@ -323,7 +465,7 @@ public class StateReducer extends ListenerAdapter {
     // Record the field in the map
     if (executedInsn instanceof WriteInstruction) {
       // Exclude certain field writes because of infrastructure needs, e.g., Event class field writes
-      for(String str : EXCLUDED_FIELDS_WRITE_INSTRUCTIONS_STARTS_WITH_LIST) {
+      for (String str : EXCLUDED_FIELDS_WRITE_INSTRUCTIONS_STARTS_WITH_LIST) {
         if (fieldClass.startsWith(str)) {
           return;
         }
@@ -352,6 +494,37 @@ public class StateReducer extends ListenerAdapter {
     return true;
   }
 
+  private String buildStringFromChoiceList(Integer[] newChoiceList) {
+
+    // When we see a choice list shorter than the upper bound, e.g., [3,2] for choices 0,1,2, and 3,
+    //  then we have to pad the beginning before we store it, because [3,2] actually means [0,1,3,2]
+    // First, calculate the difference between this choice list and the upper bound
+    //  The actual list doesn't include '-1' at the end
+    int actualListLength = newChoiceList.length - 1;
+    int diff = maxUpperBound - actualListLength;
+    StringBuilder sb = new StringBuilder();
+    // Pad the beginning if necessary
+    for (int i = 0; i < diff; i++) {
+      sb.append(i);
+    }
+    // Then continue with the actual choice list
+    // We don't include the '-1' at the end
+    for (int i = 0; i < newChoiceList.length - 1; i++) {
+      sb.append(newChoiceList[i]);
+    }
+    return sb.toString();
+  }
+
+  private void checkAndAddBacktrackList(LinkedList<Integer[]> backtrackChoiceLists, Integer[] newChoiceList) {
+
+    String newChoiceListString = buildStringFromChoiceList(newChoiceList);
+    // Add only if we haven't seen this combination before
+    if (!backtrackSet.contains(newChoiceListString)) {
+      backtrackSet.add(newChoiceListString);
+      backtrackChoiceLists.addLast(newChoiceList);
+    }
+  }
+
   private void createBacktrackChoiceList(int currentChoice, int conflictEventNumber) {
 
     LinkedList<Integer[]> backtrackChoiceLists;
@@ -383,33 +556,33 @@ public class StateReducer extends ListenerAdapter {
       }
       // Set the last element to '-1' as the end of the sequence
       newChoiceList[newChoiceList.length - 1] = -1;
-      backtrackChoiceLists.addLast(newChoiceList);
+      checkAndAddBacktrackList(backtrackChoiceLists, newChoiceList);
       // The start index for the recursion is always 1 (from the main branch)
-      choiceListStartIndexMap.put(newChoiceList, 1);
     } else { // This is a sub-graph
-      int backtrackListIndex = cgMap.get(currCG);
-      backtrackChoiceLists = backtrackMap.get(backtrackListIndex);
-      int listLength = choices.length;
-      Integer[] newChoiceList = new Integer[listLength];
-      // Copy everything before the conflict number
-      for(int i = 0; i < conflictEventNumber; i++) {
-        newChoiceList[i] = choices[i];
-      }
-      // Put the conflicting events
-      newChoiceList[conflictEventNumber] = choices[currentChoice];
-      newChoiceList[conflictEventNumber + 1] = choices[conflictEventNumber];
-      // Copy the rest
-      for(int i = conflictEventNumber + 1, j = conflictEventNumber + 2; j < listLength - 1; i++) {
-        if (choices[i] != choices[currentChoice]) {
-          newChoiceList[j] = choices[i];
-          j++;
+      // There is a case/bug that after a re-initialization, currCG is not yet initialized
+      if (currCG != null && cgMap.containsKey(currCG)) {
+        int backtrackListIndex = cgMap.get(currCG);
+        backtrackChoiceLists = backtrackMap.get(backtrackListIndex);
+        int listLength = choices.length;
+        Integer[] newChoiceList = new Integer[listLength];
+        // Copy everything before the conflict number
+        for (int i = 0; i < conflictEventNumber; i++) {
+          newChoiceList[i] = choices[i];
         }
+        // Put the conflicting events
+        newChoiceList[conflictEventNumber] = choices[currentChoice];
+        newChoiceList[conflictEventNumber + 1] = choices[conflictEventNumber];
+        // Copy the rest
+        for (int i = conflictEventNumber + 1, j = conflictEventNumber + 2; j < listLength - 1; i++) {
+          if (choices[i] != choices[currentChoice]) {
+            newChoiceList[j] = choices[i];
+            j++;
+          }
+        }
+        // Set the last element to '-1' as the end of the sequence
+        newChoiceList[newChoiceList.length - 1] = -1;
+        checkAndAddBacktrackList(backtrackChoiceLists, newChoiceList);
       }
-      // Set the last element to '-1' as the end of the sequence
-      newChoiceList[newChoiceList.length - 1] = -1;
-      backtrackChoiceLists.addLast(newChoiceList);
-      // For the sub-graph the start index depends on the conflicting event number
-      choiceListStartIndexMap.put(newChoiceList, conflictEventNumber + 1);
     }
   }
 
@@ -449,11 +622,45 @@ public class StateReducer extends ListenerAdapter {
     return false;
   }
 
+  // This method checks whether a choice is reachable in the VOD graph from a reference choice
+  // This is a BFS search
+  private boolean isReachableInVODGraph(int checkedChoice, int referenceChoice) {
+    // Record visited choices as we search in the graph
+    HashSet<Integer> visitedChoice = new HashSet<>();
+    visitedChoice.add(referenceChoice);
+    LinkedList<Integer> nodesToVisit = new LinkedList<>();
+    // If the state doesn't advance as the threads/sub-programs are executed (basically there is no new state),
+    // there is a chance that the graph doesn't have new nodes---thus this check will return a null.
+    if (vodGraphMap.containsKey(referenceChoice)) {
+      nodesToVisit.addAll(vodGraphMap.get(referenceChoice));
+      while(!nodesToVisit.isEmpty()) {
+        int currChoice = nodesToVisit.getFirst();
+        if (currChoice == checkedChoice) {
+          return true;
+        }
+        if (visitedChoice.contains(currChoice)) {
+          // If there is a loop then we don't find it
+          return false;
+        }
+        // Continue searching
+        visitedChoice.add(currChoice);
+        HashSet<Integer> currChoiceNextNodes = vodGraphMap.get(currChoice);
+        if (currChoiceNextNodes != null) {
+          // Add only if there is a mapping for next nodes
+          for (Integer nextNode : currChoiceNextNodes) {
+            nodesToVisit.addLast(nextNode);
+          }
+        }
+      }
+    }
+    return false;
+  }
+
   @Override
   public void instructionExecuted(VM vm, ThreadInfo ti, Instruction nextInsn, Instruction executedInsn) {
     if (stateReductionMode) {
       if (isInitialized) {
-        if (choiceCounter > choices.length - 1) {
+        if (choiceCounter <= 0 || choiceCounter > choices.length - 1) {
           // We do not compute the conflicts for the choice '-1'
           return;
         }
@@ -476,13 +683,10 @@ public class StateReducer extends ListenerAdapter {
             String fieldClass = ((JVMFieldInstruction) nextInsn).getFieldInfo().getFullName();
             // We don't care about libraries
             if (!isFieldExcluded(fieldClass)) {
-              // For the main graph we go down to 0, but for subgraph, we only go down to 1 since 0 contains
-              // the reversed event
-              int end = !isResetAfterAnalysis ? 0 : choiceListStartIndexMap.get(choices);
               // Check for conflict (go backward from currentChoice and get the first conflict)
               // If the current event has conflicts with multiple events, then these will be detected
               // one by one as this recursively checks backward when backtrack set is revisited and executed.
-              for (int eventNumber = currentChoice - 1; eventNumber >= end; eventNumber--) {
+              for (int eventNumber = currentChoice - 1; eventNumber >= 0; eventNumber--) {
                 // Skip if this event number does not have any Read/Write set
                 if (!readWriteFieldsMap.containsKey(choices[eventNumber])) {
                   continue;
@@ -497,9 +701,13 @@ public class StateReducer extends ListenerAdapter {
                   // We do not record and service the same backtrack pair/point twice!
                   // If it has been serviced before, we just skip this
                   if (recordConflictPair(currentChoice, eventNumber)) {
-                    createBacktrackChoiceList(currentChoice, eventNumber);
-                    // Break if a conflict is found!
-                    break;
+                    // Lines 4-8 of the algorithm in the paper page 11 (see the heading note above)
+                    if (vm.isNewState() ||
+                            (!vm.isNewState() && isReachableInVODGraph(choices[currentChoice], choices[currentChoice-1]))) {
+                      createBacktrackChoiceList(currentChoice, eventNumber);
+                      // Break if a conflict is found!
+                      break;
+                    }
                   }
                 }
               }
@@ -509,4 +717,4 @@ public class StateReducer extends ListenerAdapter {
       }
     }
   }
-}
\ No newline at end of file
+}