bndtools/bndtools — pull request #557 by ateirney (2012-11-20 03:39:56+00:00)
Title: Prevent partially initialized Bnd Workspace(s)

It is possible during the creation of a Bnd Workspace to have an exception thrown, resulting in a partially initialized Bnd Workspace.

This change ensures that a Bnd Workspace will only be retained if it was fully initialized, in the failure case it will ensure that the workspace is closed.

This partially initialized case manifested itself by the user not being able to resolve runbundles against the workspace r5 repository.

Recreating the partially initialized case is easy.

1. Create a new workspace
2. Create a Bnd OSGi bundle along with the 'cnf' project outside of the eclipse workspace
3. Switch to Bnd perspective
4. Restart Eclipse
5. Try to resolve bundles for running against the workspace repository (its not in the list of repositories you can resolve from).

Further investigation into this indicated that the "Repositories" view was being instantiated, during this an Exception was being thrown (getWorkspaceR5Repository threw an Exception) that was being caught (and swallowed). The result was that the workspace stored in the "workspace" field (which would be subsequently returned for all getWorkspace() calls) did not have the Workspace Repository plugin, also the getBuildOrder() on the workspace also would not be called.

I should add that I am running this in Eclipse 4.2 (Juno)