Bug 342907 - [target] IUBundleContainer sync problems
Summary: [target] IUBundleContainer sync problems
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2011-04-14 21:35 EDT by Jeff McAffer CLA
Modified: 2011-04-15 12:47 EDT (History)
1 user (show)

See Also:


Attachments
patch to fix target sync (19.81 KB, patch)
2011-04-14 21:35 EDT, Jeff McAffer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff McAffer CLA 2011-04-14 21:35:08 EDT
Created attachment 193318 [details]
patch to fix target sync

Turns out that in the target management implementation TargetDefinition instances are created and recreated at will.  In the p2 profile synchronization management implementation we assume that the "synchronizer" (P2TargetUtils) can point to one TargetDefinition and one Profile and keep them in sync.  This causes problems if, for example, a target editor is open on a target in the workspace and that target def is updated or a garbage collection happens.  In that case, the editor sees the underlying .target resource change and so reloads.  But the reloaded TargetDefinition is different from the one that was used for synchronizing with the p2 profile.  Confusion ensues...

Ideally I think the target management infrastructure if overly complicated but pragmatically, its what we have so we have to work around.  

To address this problem I've changed the P2TargetUtils instances to NOT retain a pointer to the actual TargetDefinition rather they retain their "memento" (unique identifier).  This is used as the key in a map from memento to synchronizer.  This decouples the two. As a result, a number of methods in P2TargetUtils and IUBundleContainer were changed to take a TargetDefinition as an arg rather than using the old fTarget field.

That's only part of the story.  Because the synchronizer is the focus all the real work (i.e., profile resolution, ...) previously, when the profile was found to be sync with the target we would "notify" the target of changes and the target/containers would recache their bundles and features.  Since there can actually be multiple TargetDefinition object working against the same profile/synchronizer, I modified the synchronize() method to always notify the target.  This will be a little inefficient but in the grand scheme of things should not be too painful.

Please check out the patch and see if you agree with the direction.

Note that without this fix I was getting various "profile out of sync" errors when doing more complicated things with targets so fixing this for 3.7 would be highly desirable.
Comment 1 Curtis Windatt CLA 2011-04-15 11:52:05 EDT
I agree with the direction.  Better solutions would involve changing the architecture and API of target definitions.
Comment 2 Curtis Windatt CLA 2011-04-15 12:47:15 EDT
Fixed in HEAD.

We will have to include some more indepth testing of the p2 targets in either the M7 pass or the 2-day pass in RC1.