1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 07:35:24 +02:00

[226728] NPE during intialization with a clean self-host

https://bugs.eclipse.org/bugs/show_bug.cgi?id=226728
This commit is contained in:
David Dykstal 2008-04-17 13:50:24 +00:00
parent 6da37b7de7
commit cebd655bad
4 changed files with 31 additions and 31 deletions

View file

@ -6,6 +6,7 @@
*
* Contributors:
* David Dykstal (IBM) - [197167] adding notification and waiting for RSE model
* David Dykstal (IBM) - [226728] NPE during init with clean workspace
********************************************************************************/
package org.eclipse.rse.internal.core;
@ -29,6 +30,11 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.core.IRSEInitListener;
import org.eclipse.rse.core.IRSEModelInitializer;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemModelChangeEvent;
import org.eclipse.rse.core.events.ISystemModelChangeEvents;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.core.model.SystemModelChangeEvent;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.logging.Logger;
/**
@ -170,8 +176,11 @@ public final class RSEInitJob extends Job {
*/
public IStatus run(IProgressMonitor monitor) {
IStatus result = Status.OK_STATUS;
// get and initialize the profile manager
RSECorePlugin.getTheSystemProfileManager();
// restore profiles
RSECorePlugin.getThePersistenceManager().restoreProfiles(5000);
ISystemProfile defaultProfile = SystemProfileManager.getDefault().getDefaultPrivateSystemProfile();
ISystemModelChangeEvent event = new SystemModelChangeEvent(ISystemModelChangeEvents.SYSTEM_RESOURCE_ALL_RELOADED, ISystemModelChangeEvents.SYSTEM_RESOURCETYPE_PROFILE, defaultProfile);
RSECorePlugin.getTheSystemRegistry().fireEvent(event);
modelPhase.done();
// instantiate and run initializers
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.rse.core.modelInitializers"); //$NON-NLS-1$
@ -282,7 +291,7 @@ public final class RSEInitJob extends Job {
waitForCompletion(RSECorePlugin.INIT_ALL);
return getResult();
}
/**
* Wait for the completion of a particular phase
* @param phase the phase to wait for

View file

@ -21,6 +21,7 @@
* David Dykstal (IBM) - [222376] NPE if starting on a workspace with an old mark and a renamed default profile
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent
* David Dykstal (IBM) - [200735][Persistence] Delete a profile that contains a connection and restart, profile is back without connections
* David Dykstal (IBM) - [226728] NPE during init with clean workspace
*******************************************************************************/
package org.eclipse.rse.internal.core.model;
@ -35,6 +36,7 @@ import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemProfileManager;
import org.eclipse.rse.internal.core.RSEInitJob;
import org.eclipse.rse.logging.Logger;
import org.eclipse.rse.persistence.IRSEPersistenceProvider;
@ -45,8 +47,7 @@ import org.eclipse.rse.persistence.IRSEPersistenceProvider;
public class SystemProfileManager implements ISystemProfileManager {
private List _profiles = new ArrayList(10);
private static SystemProfileManager singleton = null;
private boolean restoring = false;
private static SystemProfileManager singleton = new SystemProfileManager();
private boolean active = true;
private ISystemProfile defaultProfile = null;
@ -62,24 +63,14 @@ public class SystemProfileManager implements ISystemProfileManager {
* @return (and create if necessary) the singleton instance of this class.
*/
public static SystemProfileManager getDefault() {
if (singleton == null) {
singleton = new SystemProfileManager();
RSECorePlugin.getThePersistenceManager().restoreProfiles(5000);
singleton.ensureDefaultPrivateProfile();
singleton.ensureDefaultTeamProfile();
}
return singleton;
}
/**
* Clear the default after a team synchronization say
*/
public static void clearDefault() {
singleton = null;
}
public void setRestoring(boolean flag) {
restoring = flag;
singleton.forgetProfiles();
}
/**
@ -171,6 +162,7 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
*/
public ISystemProfile[] getSystemProfiles() {
boolean restoring = !RSEInitJob.getInstance().isComplete(RSECorePlugin.INIT_ALL);
return getSystemProfiles(restoring);
}
@ -409,6 +401,7 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
*/
public ISystemProfile getDefaultPrivateSystemProfile() {
ensureDefaultPrivateProfile();
return defaultProfile;
}
@ -416,7 +409,9 @@ public class SystemProfileManager implements ISystemProfileManager {
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultTeamSystemProfile()
*/
public ISystemProfile getDefaultTeamSystemProfile() {
return getSystemProfile(RSEPreferencesManager.getDefaultTeamProfileName());
ensureDefaultTeamProfile();
ISystemProfile teamProfile = getSystemProfile(RSEPreferencesManager.getDefaultTeamProfileName());
return teamProfile;
}
/* (non-Javadoc)
@ -496,6 +491,10 @@ public class SystemProfileManager implements ISystemProfileManager {
defaultProfile.setActive(true); // ensure that the default profile is active
}
private void forgetProfiles() {
_profiles.clear();
}
private void ensureDefaultTeamProfile() {
String name = RSEPreferencesManager.getDefaultTeamProfileName();
ISystemProfile teamProfile = getSystemProfile(name);

View file

@ -19,6 +19,7 @@
* Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
* David Dykstal (IBM) - [189274] provide import and export operations for profiles
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
* David Dykstal (IBM) - [226728] NPE during init with clean workspace
********************************************************************************/
package org.eclipse.rse.internal.persistence;
@ -48,7 +49,6 @@ import org.eclipse.rse.core.model.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.internal.core.RSECoreMessages;
import org.eclipse.rse.internal.core.model.SystemProfileManager;
import org.eclipse.rse.internal.persistence.dom.RSEDOMExporter;
import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter;
import org.eclipse.rse.logging.Logger;
@ -413,13 +413,11 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
try {
RSEDOM dom = provider.loadRSEDOM(profileName, new NullProgressMonitor());
if (dom != null) {
SystemProfileManager.getDefault().setRestoring(true);
profile = _importer.restoreProfile(dom);
if (profile!=null) {
profile.setPersistenceProvider(provider);
cleanTree(profile);
}
SystemProfileManager.getDefault().setRestoring(false);
}
} finally {
mutex.release();

View file

@ -28,6 +28,7 @@
* Martin Oberhuber (Wind River) - [197025][197167] Improved wait for model complete
* David McKnight (IBM) - [199424] restoring memento state asynchronously
* David McKnight (IBM) - [187711] Link with Editor handled by extension
* David Dykstal (IBM) - [226728] NPE during init with clean workspace
*******************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -79,6 +80,7 @@ import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.ISystemViewInputProvider;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.core.RSEInitJob;
import org.eclipse.rse.internal.ui.actions.SystemCascadingPreferencesAction;
import org.eclipse.rse.internal.ui.actions.SystemCollapseAllAction;
import org.eclipse.rse.internal.ui.actions.SystemPreferenceQualifyConnectionNamesAction;
@ -404,14 +406,7 @@ public class SystemViewPart
// ----------------------
// Restore previous state
// ----------------------
Job initRSEJob = null;
Job[] jobs = Job.getJobManager().find(null);
for(int i=0; i<jobs.length; i++) {
if ("Initialize RSE".equals(jobs[i].getName())) { //$NON-NLS-1$
initRSEJob = jobs[i];
break;
}
}
final RSEInitJob initRSEJob = RSEInitJob.getInstance();
if (initRSEJob == null) {
//Already initialized - Profiles are loaded, we can restore state right away without blocking
restoreInitialState();
@ -419,12 +414,11 @@ public class SystemViewPart
//Wait until model fully restored, then fire a callback to restore state.
//Remember current display, since we're definitely on the display thread here
final Display display = Display.getCurrent();
final Job fInitRSEJob = initRSEJob;
Job waitForRestoreCompleteJob = new Job("WaitForRestoreComplete") { //$NON-NLS-1$
protected IStatus run(IProgressMonitor monitor) {
try {
//Wait for initRSEJob.
fInitRSEJob.join();
initRSEJob.waitForCompletion();
//callback
display.asyncExec(new Runnable() {
public void run() {