From 9344fa358a5f03b294c6d136218efa19cf193276 Mon Sep 17 00:00:00 2001 From: Dave McKnight Date: Tue, 7 Jan 2014 10:25:49 -0500 Subject: [PATCH] [425014] profile commit job don't always complete during shutdown --- .../core/model/SystemProfileManager.java | 16 ++++++++++++++-- .../persistence/RSEPersistenceManager.java | 8 +++++--- .../shells/ui/view/CommandsViewWorkbook.java | 7 +++++-- .../eclipse/rse/core/subsystems/SubSystem.java | 16 +++++++++++++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfileManager.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfileManager.java index af392371eaa..9253bd6b3ce 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfileManager.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemProfileManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ * 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 + * David McKnight (IBM) -[425014] profile commit job don't always complete during shutdown *******************************************************************************/ package org.eclipse.rse.internal.core.model; @@ -30,6 +31,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.eclipse.core.internal.resources.Workspace; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.rse.core.RSECorePlugin; @@ -110,11 +113,20 @@ public class SystemProfileManager implements ISystemProfileManager { } public IStatus commitSystemProfile(ISystemProfile profile) { + return commitSystemProfile(profile, false); + } + + public IStatus commitSystemProfile(ISystemProfile profile, boolean immediate) { IStatus status = Status.OK_STATUS; boolean scheduled = false; if (active) { if (!RSECorePlugin.getThePersistenceManager().isBusy()) { - scheduled = RSECorePlugin.getThePersistenceManager().commitProfile(profile, 5000); + if (immediate){ + scheduled = RSECorePlugin.getThePersistenceManager().commitProfile(profile, 0); + } + else { + scheduled = RSECorePlugin.getThePersistenceManager().commitProfile(profile, 5000); + } } } else { scheduled = true; diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java index 9da776b92b9..1ecbee3edb5 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2009 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2014 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -24,6 +24,7 @@ * Kevin Doyle (IBM) - [243821] Save occurring on Main Thread * David Dykstal (IBM) - [243128] Problem during migration - NPE if provider does save without using a job. * Martin Oberhuber (Wind River) - [261503][cleanup] Get rid of deprecated getPluginPreferences() + * David McKnight (IBM) -[425014] profile commit job don't always complete during shutdown ********************************************************************************/ package org.eclipse.rse.internal.persistence; @@ -556,8 +557,9 @@ public class RSEPersistenceManager implements IRSEPersistenceManager { cleanTree(profile); if (dom.needsSave()) { Job job = provider.getSaveJob(dom); - if (job != null && canScheduleSave) { - job.addJobChangeListener(jobChangeListener); + if (job != null && canScheduleSave + && timeout > 0) { // timeout of zero indicates shutdown - no time for job scheduling + job.addJobChangeListener(jobChangeListener); job.schedule(2000); // two second delay } else { provider.saveRSEDOM(dom, new NullProgressMonitor()); diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/view/CommandsViewWorkbook.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/view/CommandsViewWorkbook.java index 6150010a64c..6bc565a5ef7 100644 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/view/CommandsViewWorkbook.java +++ b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/view/CommandsViewWorkbook.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2011 IBM Corporation and others. + * Copyright (c) 2002, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * David McKnight (IBM) - [165680] "Show in Remote Shell View" does not work * David McKnight (IBM) - [338031] Remote Shell view tabs should have close (x) icon + * David McKnight (IBM) -[425014] profile commit job don't always complete during shutdown *******************************************************************************/ package org.eclipse.rse.internal.shells.ui.view; @@ -245,7 +246,9 @@ public class CommandsViewWorkbook extends Composite try { IRemoteCmdSubSystem cmdSubSystem = command.getCommandSubSystem(); if (cmdSubSystem != null && cmdSubSystem.isConnected()){ - cmdSubSystem.removeShell(command); + if (!_viewPart.getSite().getWorkbenchWindow().getWorkbench().isClosing()){ + cmdSubSystem.removeShell(command); + } } } catch (Exception ex){ diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java index dc49950f537..d81023f3b44 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2011 IBM Corporation and others. All rights reserved. + * Copyright (c) 2002, 2014 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -50,6 +50,7 @@ * David McKnight (IBM) - [284018] concurrent SubSystem.connect() calls can result in double login-prompt * David McKnight (IBM) - [318836] Period in filter name causes wrong message on drag and drop * David McKnight (IBM) - [326555] Dead lock when debug session starts + * David McKnight (IBM) -[425014] profile commit job don't always complete during shutdown * ********************************************************************************/ package org.eclipse.rse.core.subsystems; @@ -117,6 +118,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.progress.WorkbenchJob; @@ -3296,8 +3298,16 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider public boolean commit() { ISystemProfile profile = getSystemProfile(); - boolean result = profile.commit(); - return result; + if (PlatformUI.getWorkbench().isClosing()){ + // commit job may fail due to shutdown + // force this by directly calling with true + IStatus status = SystemProfileManager.getDefault().commitSystemProfile(profile, true); + return status.isOK(); + } + else { + boolean result = profile.commit(); + return result; + } } public IRSEPersistableContainer getPersistableParent() {