Bug 137613 - [data models] NPE in DataModelSynchHelper
Summary: [data models] NPE in DataModelSynchHelper
Status: CLOSED FIXED
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.common (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 1.5 RC1   Edit
Assignee: Jason Sholl CLA
QA Contact:
URL:
Whiteboard:
Keywords: greatbug
Depends on:
Blocks:
 
Reported: 2006-04-19 17:30 EDT by Daniel Berg CLA
Modified: 2006-09-26 13:08 EDT (History)
0 users

See Also:


Attachments
Patch to DataModelSynchHelper (1.52 KB, patch)
2006-04-19 17:33 EDT, Daniel Berg CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Berg CLA 2006-04-19 17:30:46 EDT
The problem with the DataModelSynchHelper#synchUIWithModel(String, int) method is that the currentWidget instance variable is set by looking up from the cache but when the widget value is set this triggers an event which causes this method to be called again.  When the method completes from the notification (from setting the widget value) it will set the currentWidget value back to null.  Then the initial call to the method will call setEnablement(...) and throw the NPE because the currentWidget was set to null from the triggered event (tricky...:)).

The fix is actually quite simple.  Create a temp variable for the currentWidget and use the temp variable when doing the enablement setting.  This way the currentWidget instance variable can be set to null and not affect the temp variable which was the widget when the code block was entered.

I've attached a patch to this problem as well.
Comment 1 Daniel Berg CLA 2006-04-19 17:33:36 EDT
Created attachment 38987 [details]
Patch to DataModelSynchHelper
Comment 2 Jason Sholl CLA 2006-04-20 11:27:31 EDT
I would like to nominate this bug a Great Bug.  Dan found and fixed an obscure
thread race condition in core DataModel framework code.  Looking at where the
fix is, this is clearly a difficut bug to reproduce, and likely would have been
returned as "works for me" if Dan had simply included the stack trace.  Thanks
Dan!
Comment 3 John Lanuti CLA 2006-09-26 13:08:30 EDT
Verified WTP 1.5.1 RC driver.