2 Replies Latest reply on Jun 11, 2009 11:53 AM by Aaron Riekenberg

    FUSE 4.1: features/uninstall is unreliable

    Aaron Riekenberg Newbie

      I've created a feature file containing several bundles.  I've listed the bundles in order - some of the later bundles in the feature depend on earlier bundles in the features.  The feature installs fine.  When I uninstall the feature (using the gshell features/uninstall command), the bundles in the feature seem to be uninstalled in no particular order - some of the earlier bundles are uninstalled before later bundles that depend on them.  This causes lots of problems, the uninstall command usually hangs and I get lots of exceptions as bundles have their dependencies pulled out from under them.


      I went looking at the code to try to figure out why this is.  It appears feature installation/uninstallation is done in FeaturesServiceImpl.java.  The "installed" map keeps track of installed features - it's a map of Feature object to a Set of bundle IDs installed by that feature.


      The installFeature(String name, String version) method puts bundleIDs into the installed map.  Notice it creates a HashSet containing bundleIDs (Long objects).  Values in this set will be in some chaotic order based on hashValue's of the Long objects - this is not sequential.


      Later when I uninstall a feature, uninstallFeature(String name, String version) gets called.  It removes the HashSet of bundleIDs from the installed map, and iterates over the set to uninstall all the bundles in the feature.  I think this is were the problem lies - since this is a HashSet, the bundles are not uninstalled in any particular order.


      I would suggest changing the Set created by installFeature to a TreeSet so that it is ordered.  Then I think uninstallFeature should iterate over it in reverse order to uninstall features in the opposite order they were installed.


      Edited by: ariekenb on Jun 11, 2009 2:26 PM


      Edited by: ariekenb on Jun 11, 2009 2:27 PM