Community
Participate
Working Groups
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".
My ref 106755
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.