diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileStore.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileStore.java index 55fa9766ba2..4dd36a03a08 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileStore.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileStore.java @@ -26,9 +26,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -291,11 +292,11 @@ private static Element createProfileElement(Profile profile, Document document, element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion())); element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind()); - final Iterator keyIter= profile.getSettings().keySet().iterator(); + Map sorted = new TreeMap<>(profile.getSettings()); - while (keyIter.hasNext()) { - final String key= keyIter.next(); - final String value= profile.getSettings().get(key); + for (Entry entry : sorted.entrySet()) { + final String key= entry.getKey(); + final String value= entry.getValue(); if (value != null) { final Element setting= document.createElement(XML_NODE_SETTING); setting.setAttribute(XML_ATTRIBUTE_ID, key); @@ -305,6 +306,7 @@ private static Element createProfileElement(Profile profile, Document document, JavaPlugin.logErrorMessage("ProfileStore: Profile does not contain value for key " + key); //$NON-NLS-1$ } } + return element; }