417938 - Startup / Sort properties presented in --list-config alphabetically

This commit is contained in:
Joakim Erdfelt 2013-09-24 09:00:30 -07:00
parent a20b39e9ab
commit 937a91a0db
2 changed files with 19 additions and 17 deletions

View File

@ -67,18 +67,8 @@ import java.util.regex.Pattern;
* </li>
* <li>Module Resolution</li>
* <li>Properties Resolution</li>
* <li>Execution
* <ul>
* <li>--list-modules</li>
* <li>--list-classpath</li>
* <li>--list-config</li>
* <li>--version</li>
* <li>--help</li>
* <li>--dry-run</li>
* <li>--exec</li>
* <li>--stop</li>
* <li>(or normal startup)</li>
* </ul>
* <li>Present Optional Informational Options</li>
* <li>Normal Startup</li>
* </li>
* </ol>
*/

View File

@ -26,6 +26,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
@ -206,14 +207,21 @@ public class StartArgs
System.out.println(" (no properties specified)");
return;
}
List<String> sortedKeys = new ArrayList<>();
@SuppressWarnings("unchecked")
Enumeration<String> keyEnum = (Enumeration<String>)properties.propertyNames();
while (keyEnum.hasMoreElements())
{
String name = keyEnum.nextElement();
String value = properties.getProperty(name);
System.out.printf(" %s = %s%n",name,value);
sortedKeys.add(keyEnum.nextElement());
}
Collections.sort(sortedKeys);
for(String key: sortedKeys)
{
String value = properties.getProperty(key);
System.out.printf(" %s = %s%n",key,value);
}
}
@ -228,8 +236,12 @@ public class StartArgs
System.out.println(" (no system properties specified)");
return;
}
List<String> sortedKeys = new ArrayList<>();
sortedKeys.addAll(systemPropertyKeys);
Collections.sort(sortedKeys);
for (String key : systemPropertyKeys)
for (String key : sortedKeys)
{
String value = System.getProperty(key);
System.out.printf(" %s = %s%n",key,value);