mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-14 12:35:22 +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:
parent
6da37b7de7
commit
cebd655bad
4 changed files with 31 additions and 31 deletions
|
@ -6,6 +6,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David Dykstal (IBM) - [197167] adding notification and waiting for RSE model
|
* 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;
|
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.IRSEInitListener;
|
||||||
import org.eclipse.rse.core.IRSEModelInitializer;
|
import org.eclipse.rse.core.IRSEModelInitializer;
|
||||||
import org.eclipse.rse.core.RSECorePlugin;
|
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;
|
import org.eclipse.rse.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,8 +176,11 @@ public final class RSEInitJob extends Job {
|
||||||
*/
|
*/
|
||||||
public IStatus run(IProgressMonitor monitor) {
|
public IStatus run(IProgressMonitor monitor) {
|
||||||
IStatus result = Status.OK_STATUS;
|
IStatus result = Status.OK_STATUS;
|
||||||
// get and initialize the profile manager
|
// restore profiles
|
||||||
RSECorePlugin.getTheSystemProfileManager();
|
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();
|
modelPhase.done();
|
||||||
// instantiate and run initializers
|
// instantiate and run initializers
|
||||||
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.rse.core.modelInitializers"); //$NON-NLS-1$
|
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);
|
waitForCompletion(RSECorePlugin.INIT_ALL);
|
||||||
return getResult();
|
return getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for the completion of a particular phase
|
* Wait for the completion of a particular phase
|
||||||
* @param phase the phase to wait for
|
* @param phase the phase to wait for
|
||||||
|
|
|
@ -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) - [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) - [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) - [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;
|
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.RSEPreferencesManager;
|
||||||
import org.eclipse.rse.core.model.ISystemProfile;
|
import org.eclipse.rse.core.model.ISystemProfile;
|
||||||
import org.eclipse.rse.core.model.ISystemProfileManager;
|
import org.eclipse.rse.core.model.ISystemProfileManager;
|
||||||
|
import org.eclipse.rse.internal.core.RSEInitJob;
|
||||||
import org.eclipse.rse.logging.Logger;
|
import org.eclipse.rse.logging.Logger;
|
||||||
import org.eclipse.rse.persistence.IRSEPersistenceProvider;
|
import org.eclipse.rse.persistence.IRSEPersistenceProvider;
|
||||||
|
|
||||||
|
@ -45,8 +47,7 @@ import org.eclipse.rse.persistence.IRSEPersistenceProvider;
|
||||||
public class SystemProfileManager implements ISystemProfileManager {
|
public class SystemProfileManager implements ISystemProfileManager {
|
||||||
|
|
||||||
private List _profiles = new ArrayList(10);
|
private List _profiles = new ArrayList(10);
|
||||||
private static SystemProfileManager singleton = null;
|
private static SystemProfileManager singleton = new SystemProfileManager();
|
||||||
private boolean restoring = false;
|
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
private ISystemProfile defaultProfile = null;
|
private ISystemProfile defaultProfile = null;
|
||||||
|
|
||||||
|
@ -62,24 +63,14 @@ public class SystemProfileManager implements ISystemProfileManager {
|
||||||
* @return (and create if necessary) the singleton instance of this class.
|
* @return (and create if necessary) the singleton instance of this class.
|
||||||
*/
|
*/
|
||||||
public static SystemProfileManager getDefault() {
|
public static SystemProfileManager getDefault() {
|
||||||
if (singleton == null) {
|
|
||||||
singleton = new SystemProfileManager();
|
|
||||||
RSECorePlugin.getThePersistenceManager().restoreProfiles(5000);
|
|
||||||
singleton.ensureDefaultPrivateProfile();
|
|
||||||
singleton.ensureDefaultTeamProfile();
|
|
||||||
}
|
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the default after a team synchronization say
|
* Clear the default after a team synchronization say
|
||||||
*/
|
*/
|
||||||
public static void clearDefault() {
|
public static void clearDefault() {
|
||||||
singleton = null;
|
singleton.forgetProfiles();
|
||||||
}
|
|
||||||
|
|
||||||
public void setRestoring(boolean flag) {
|
|
||||||
restoring = flag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,6 +162,7 @@ public class SystemProfileManager implements ISystemProfileManager {
|
||||||
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
|
* @see org.eclipse.rse.core.model.ISystemProfileManager#getSystemProfiles()
|
||||||
*/
|
*/
|
||||||
public ISystemProfile[] getSystemProfiles() {
|
public ISystemProfile[] getSystemProfiles() {
|
||||||
|
boolean restoring = !RSEInitJob.getInstance().isComplete(RSECorePlugin.INIT_ALL);
|
||||||
return getSystemProfiles(restoring);
|
return getSystemProfiles(restoring);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,6 +401,7 @@ public class SystemProfileManager implements ISystemProfileManager {
|
||||||
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
|
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultPrivateSystemProfile()
|
||||||
*/
|
*/
|
||||||
public ISystemProfile getDefaultPrivateSystemProfile() {
|
public ISystemProfile getDefaultPrivateSystemProfile() {
|
||||||
|
ensureDefaultPrivateProfile();
|
||||||
return defaultProfile;
|
return defaultProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +409,9 @@ public class SystemProfileManager implements ISystemProfileManager {
|
||||||
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultTeamSystemProfile()
|
* @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultTeamSystemProfile()
|
||||||
*/
|
*/
|
||||||
public ISystemProfile getDefaultTeamSystemProfile() {
|
public ISystemProfile getDefaultTeamSystemProfile() {
|
||||||
return getSystemProfile(RSEPreferencesManager.getDefaultTeamProfileName());
|
ensureDefaultTeamProfile();
|
||||||
|
ISystemProfile teamProfile = getSystemProfile(RSEPreferencesManager.getDefaultTeamProfileName());
|
||||||
|
return teamProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -496,6 +491,10 @@ public class SystemProfileManager implements ISystemProfileManager {
|
||||||
defaultProfile.setActive(true); // ensure that the default profile is active
|
defaultProfile.setActive(true); // ensure that the default profile is active
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void forgetProfiles() {
|
||||||
|
_profiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void ensureDefaultTeamProfile() {
|
private void ensureDefaultTeamProfile() {
|
||||||
String name = RSEPreferencesManager.getDefaultTeamProfileName();
|
String name = RSEPreferencesManager.getDefaultTeamProfileName();
|
||||||
ISystemProfile teamProfile = getSystemProfile(name);
|
ISystemProfile teamProfile = getSystemProfile(name);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
|
* 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) - [189274] provide import and export operations for profiles
|
||||||
* David Dykstal (IBM) - [225988] need API to mark persisted profiles as migrated
|
* 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;
|
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.ISystemProfile;
|
||||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
import org.eclipse.rse.internal.core.RSECoreMessages;
|
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.RSEDOMExporter;
|
||||||
import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter;
|
import org.eclipse.rse.internal.persistence.dom.RSEDOMImporter;
|
||||||
import org.eclipse.rse.logging.Logger;
|
import org.eclipse.rse.logging.Logger;
|
||||||
|
@ -413,13 +413,11 @@ public class RSEPersistenceManager implements IRSEPersistenceManager {
|
||||||
try {
|
try {
|
||||||
RSEDOM dom = provider.loadRSEDOM(profileName, new NullProgressMonitor());
|
RSEDOM dom = provider.loadRSEDOM(profileName, new NullProgressMonitor());
|
||||||
if (dom != null) {
|
if (dom != null) {
|
||||||
SystemProfileManager.getDefault().setRestoring(true);
|
|
||||||
profile = _importer.restoreProfile(dom);
|
profile = _importer.restoreProfile(dom);
|
||||||
if (profile!=null) {
|
if (profile!=null) {
|
||||||
profile.setPersistenceProvider(provider);
|
profile.setPersistenceProvider(provider);
|
||||||
cleanTree(profile);
|
cleanTree(profile);
|
||||||
}
|
}
|
||||||
SystemProfileManager.getDefault().setRestoring(false);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
mutex.release();
|
mutex.release();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [197025][197167] Improved wait for model complete
|
* Martin Oberhuber (Wind River) - [197025][197167] Improved wait for model complete
|
||||||
* David McKnight (IBM) - [199424] restoring memento state asynchronously
|
* David McKnight (IBM) - [199424] restoring memento state asynchronously
|
||||||
* David McKnight (IBM) - [187711] Link with Editor handled by extension
|
* 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;
|
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.model.ISystemViewInputProvider;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
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.SystemCascadingPreferencesAction;
|
||||||
import org.eclipse.rse.internal.ui.actions.SystemCollapseAllAction;
|
import org.eclipse.rse.internal.ui.actions.SystemCollapseAllAction;
|
||||||
import org.eclipse.rse.internal.ui.actions.SystemPreferenceQualifyConnectionNamesAction;
|
import org.eclipse.rse.internal.ui.actions.SystemPreferenceQualifyConnectionNamesAction;
|
||||||
|
@ -404,14 +406,7 @@ public class SystemViewPart
|
||||||
// ----------------------
|
// ----------------------
|
||||||
// Restore previous state
|
// Restore previous state
|
||||||
// ----------------------
|
// ----------------------
|
||||||
Job initRSEJob = null;
|
final RSEInitJob initRSEJob = RSEInitJob.getInstance();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (initRSEJob == null) {
|
if (initRSEJob == null) {
|
||||||
//Already initialized - Profiles are loaded, we can restore state right away without blocking
|
//Already initialized - Profiles are loaded, we can restore state right away without blocking
|
||||||
restoreInitialState();
|
restoreInitialState();
|
||||||
|
@ -419,12 +414,11 @@ public class SystemViewPart
|
||||||
//Wait until model fully restored, then fire a callback to restore state.
|
//Wait until model fully restored, then fire a callback to restore state.
|
||||||
//Remember current display, since we're definitely on the display thread here
|
//Remember current display, since we're definitely on the display thread here
|
||||||
final Display display = Display.getCurrent();
|
final Display display = Display.getCurrent();
|
||||||
final Job fInitRSEJob = initRSEJob;
|
|
||||||
Job waitForRestoreCompleteJob = new Job("WaitForRestoreComplete") { //$NON-NLS-1$
|
Job waitForRestoreCompleteJob = new Job("WaitForRestoreComplete") { //$NON-NLS-1$
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
//Wait for initRSEJob.
|
//Wait for initRSEJob.
|
||||||
fInitRSEJob.join();
|
initRSEJob.waitForCompletion();
|
||||||
//callback
|
//callback
|
||||||
display.asyncExec(new Runnable() {
|
display.asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue