Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-12-03 13:26:17 +0000
committerMarkus Keller2015-12-03 13:26:17 +0000
commitab0e0669078b8ad4fd1c931bfd3a6a519c081ca5 (patch)
tree49e3f75d10bfecf7d5a890fa27257f547dcfc3c7 /bundles
parenta01ceaa587221fcce5c33460d98140d401809a6d (diff)
downloadrt.equinox.bundles-ab0e0669078b8ad4fd1c931bfd3a6a519c081ca5.tar.gz
rt.equinox.bundles-ab0e0669078b8ad4fd1c931bfd3a6a519c081ca5.tar.xz
rt.equinox.bundles-ab0e0669078b8ad4fd1c931bfd3a6a519c081ca5.zip
Bug 474359: [preferences] Exported preferences should be in alphabetical order
documented restrictions of SortedProperties
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java4
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java24
2 files changed, 18 insertions, 10 deletions
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java
index 4a27537c..94cf4414 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java
@@ -285,7 +285,7 @@ public class PreferencesService implements IPreferencesService {
/*
* excludesList is guaranteed not to be null
*/
- private Properties convertToProperties(IEclipsePreferences preferences, final String[] excludesList) throws BackingStoreException {
+ private SortedProperties convertToProperties(IEclipsePreferences preferences, final String[] excludesList) throws BackingStoreException {
final SortedProperties result = new SortedProperties();
final int baseLength = preferences.absolutePath().length();
@@ -409,7 +409,7 @@ public class PreferencesService implements IPreferencesService {
// TODO investigate refactoring to merge with new #export(IEclipsePreferences, IPreferenceFilter[]) APIs
if (node == null || output == null)
throw new IllegalArgumentException();
- Properties properties = null;
+ SortedProperties properties = null;
if (excludesList == null)
excludesList = new String[0];
try {
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
index 88fd878b..c7f5324d 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
@@ -14,24 +14,31 @@ package org.eclipse.core.internal.preferences;
import java.util.*;
import java.util.Map.Entry;
+/**
+ * A {@link Properties} class whose entries are sorted by key; can <strong>only</strong> be used in limited scenarios
+ * like storing properties to a file.
+ * <p>
+ * <b>Implementation note</b>: The implementations of the {@link #keys()} and {@link #entrySet()} methods
+ * violate the contracts of {@link Properties#keySet()} and {@link Properties#entrySet()}, because the returned sets
+ * are <em>not</em> backed by this map.
+ * Overriding both methods is necessary to support Oracle and IBM VMS, see
+ * <a href="https://bugs.eclipse.org/325000">bug 325000</a>.
+ * </p>
+ */
public class SortedProperties extends Properties {
+ // Warning: This class is referenced by our friend org.eclipse.core.internal.resources.ProjectPreferences
private static final long serialVersionUID = 1L;
- public SortedProperties() {
- super();
- }
-
-
@Override
public synchronized Enumeration<Object> keys() {
TreeSet<Object> set = new TreeSet<>();
- for (Enumeration<?> e = super.keys(); e.hasMoreElements();)
+ for (Enumeration<?> e = super.keys(); e.hasMoreElements();) {
set.add(e.nextElement());
+ }
return Collections.enumeration(set);
}
-
@Override
public Set<Entry<Object, Object>> entrySet() {
TreeSet<Entry<Object, Object>> set = new TreeSet<>(new Comparator<Entry<Object, Object>>() {
@@ -42,8 +49,9 @@ public class SortedProperties extends Properties {
return s1.compareTo(s2);
}
});
- for (Iterator<Entry<Object, Object>> i = super.entrySet().iterator(); i.hasNext();)
+ for (Iterator<Entry<Object, Object>> i = super.entrySet().iterator(); i.hasNext();) {
set.add(i.next());
+ }
return set;
}
} \ No newline at end of file

Back to the top