public static <V>void makeMapSerializable(Map<String,V> map){
  Set<String> keysToRemove=new LinkedHashSet<String>();
  for (  Map.Entry<String,V> mapEntry : map.entrySet()) {
    Object entryValue=mapEntry.getValue();
    if (entryValue != null && !(entryValue instanceof Serializable)) {
      keysToRemove.add(mapEntry.getKey());
    }
  }
  for (  String keyToRemove : keysToRemove) {
    map.remove(keyToRemove);
  }
}

public static < V > void makeMapSerializable ( Map < String , V > map ) { Set < String > keysToRemove = new LinkedHashSet < String > ( ) ; for ( Map . Entry < String , V > mapEntry : map . entrySet ( ) ) { Object entryValue = mapEntry . getValue ( ) ; if ( entryValue != null && ! ( entryValue instanceof Serializable ) ) { keysToRemove . add ( mapEntry . getKey ( ) ) ; } } for ( String keyToRemove : keysToRemove ) { map . remove ( keyToRemove ) ; } }
this change a map to be serializable by removing all entries with values that are not serializable .
