Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Ptaszkiewicz2013-10-14 05:20:36 -0400
committerGerrit Code Review @ Eclipse.org2013-10-24 05:06:13 -0400
commitc99a811c4451455489e2df82bc9dd41be74a6eba (patch)
tree6f4aefe7acf02aa4491db26dc185f93b21707eab
parentc9b101ad6019999bbc60789881427939c6977da2 (diff)
downloadeclipse.platform.team-c99a811c4451455489e2df82bc9dd41be74a6eba.tar.gz
eclipse.platform.team-c99a811c4451455489e2df82bc9dd41be74a6eba.tar.xz
eclipse.platform.team-c99a811c4451455489e2df82bc9dd41be74a6eba.zip
Bug 419337 - [JSch] PreferenceModifyListener pollutes exported preferences
Change-Id: Ia91987e32fd0be2bbe59cd25ec18c24be5cf1533 Signed-off-by: Szymon Ptaszkiewicz <szymon.ptaszkiewicz@pl.ibm.com>
-rw-r--r--bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceModifyListener.java17
-rw-r--r--bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java29
2 files changed, 34 insertions, 12 deletions
diff --git a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceModifyListener.java b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceModifyListener.java
index 174b866ef..f230e28a2 100644
--- a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceModifyListener.java
+++ b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/PreferenceModifyListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 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
@@ -11,6 +11,9 @@
package org.eclipse.jsch.internal.core;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
public class PreferenceModifyListener extends
org.eclipse.core.runtime.preferences.PreferenceModifyListener{
@@ -20,7 +23,17 @@ public class PreferenceModifyListener extends
}
public IEclipsePreferences preApply(IEclipsePreferences node){
- Utils.migrateSSH2Preferences(node.node("instance")); //$NON-NLS-1$
+ // the node does not need to be the root of the hierarchy
+ Preferences root=node.node("/"); //$NON-NLS-1$
+ try{
+ // we must not create empty preference nodes, so first check if the node exists
+ if(root.nodeExists(InstanceScope.SCOPE)){
+ Utils.migrateSSH2Preferences(root.node(InstanceScope.SCOPE));
+ }
+ }
+ catch(BackingStoreException e){
+ // do nothing
+ }
return super.preApply(node);
}
diff --git a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java
index 08b547e8e..44a714399 100644
--- a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java
+++ b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.BackingStoreException;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
@@ -226,17 +227,25 @@ public class Utils{
}
public static void migrateSSH2Preferences(org.osgi.service.prefs.Preferences node) {
- org.osgi.service.prefs.Preferences jschPrefs=node.node(JSchCorePlugin.ID);
- org.osgi.service.prefs.Preferences ssh2Prefs=node.node("org.eclipse.team.cvs.ssh2"); //$NON-NLS-1$
- String oldHome = ssh2Prefs.get(IConstants.KEY_OLD_SSH2HOME, null);
- String oldKey = ssh2Prefs.get(IConstants.KEY_OLD_PRIVATEKEY, null);
- if (oldHome != null) {
- jschPrefs.put(IConstants.KEY_SSH2HOME, oldHome);
- ssh2Prefs.remove(IConstants.KEY_OLD_SSH2HOME);
+ try{
+ if(node.nodeExists("org.eclipse.team.cvs.ssh2")){ //$NON-NLS-1$
+ org.osgi.service.prefs.Preferences ssh2Prefs=node.node("org.eclipse.team.cvs.ssh2"); //$NON-NLS-1$
+ String oldHome=ssh2Prefs.get(IConstants.KEY_OLD_SSH2HOME, null);
+ String oldKey=ssh2Prefs.get(IConstants.KEY_OLD_PRIVATEKEY, null);
+ if(oldHome!=null){
+ org.osgi.service.prefs.Preferences jschPrefs=node.node(JSchCorePlugin.ID);
+ jschPrefs.put(IConstants.KEY_SSH2HOME, oldHome);
+ ssh2Prefs.remove(IConstants.KEY_OLD_SSH2HOME);
+ }
+ if(oldKey!=null){
+ org.osgi.service.prefs.Preferences jschPrefs=node.node(JSchCorePlugin.ID);
+ jschPrefs.put(IConstants.KEY_PRIVATEKEY, oldKey);
+ ssh2Prefs.remove(IConstants.KEY_OLD_PRIVATEKEY);
+ }
+ }
}
- if (oldKey != null) {
- jschPrefs.put(IConstants.KEY_PRIVATEKEY, oldKey);
- ssh2Prefs.remove(IConstants.KEY_OLD_PRIVATEKEY);
+ catch(BackingStoreException e){
+ // do nothing
}
}

Back to the top