Bug 407589 - The server field in ServerDelegete is not updated when a WorkingCopy of server is saved
Summary: The server field in ServerDelegete is not updated when a WorkingCopy of serve...
Status: NEW
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: wst.server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: wst.server CLA
QA Contact: Elson Yuen CLA
URL:
Whiteboard:
Keywords: plan
Depends on:
Blocks:
 
Reported: 2013-05-08 16:28 EDT by Jason Duan CLA
Modified: 2015-05-14 14:13 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Duan CLA 2013-05-08 16:28:38 EDT
In the org.eclipse.wst.server.core.internal.Server.setInternal(ServerWorkingCopy), The delegate is updated by delegate = wc.delegate.  

There is a server field in the org.eclipse.wst.server.core.model.ServerDelegate.  After the delegate is created, the org.eclipse.wst.server.core.model.ServerDelegate.initialize(Server, IProgressMonitor) is called. If it is the first time we create a server, the server is an IServerWorkingCopy.  Then the server field is set to the WorkingCopy.

So, after the delegate = wc.delegate is called in the setInternal(.), we should update the server field in the ServerDelegate to "this".
Comment 1 Jason Duan CLA 2013-05-08 16:41:02 EDT
My ref 106755
Comment 2 Dobromir Zahariev CLA 2013-05-20 06:15:59 EDT
This is correct - there have the way to get in inconsistent state here.
1. Create Server 
2. Create Working Copy
3. Initialize the delegate of Working copy (so it is not null) - just call:

public ServerDelegate getWorkingCopyDelegate(IProgressMonitor monitor) 

As working copy delegate is null for now it create an instance and initialize it:
...
workingCopyDelegate = ((ServerType) serverType).createServerDelegate();
InternalInitializer.initializeServerDelegate(workingCopyDelegate, this, monitor);
...

During initialization the delegate server field is initialized to point to server working copy instance. 

4. Call save on working copy.
As result we have server with delegate that has a Server field still pointing to server working copy instance.


Unfortunately the Server field inside delegate cannot be modified at this time. The only way to do this is to initialize new delegate at this time and to leave this instance to be released.