Write yacy.conf with alphabetically sorted keys

FileUtils.saveMap iterated a HashMap snapshot, so DATA/SETTINGS/yacy.conf
was written in hash order and its key order changed between saves. Take the
snapshot as a TreeMap so the file is written sorted by key, matching the
order shown in ConfigProperties_p.html.

Fixes #618
This commit is contained in:
Vladimir Babin committed 2026-09-23 03:15:56 +03:00
1 parent de973ca444
commit a4e0126f1e
2 files changed
+35 -1

No files matched your search

+2 -1
View File
@@ -56,6 +56,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.GZIPInputStream;
@@ -539,7 +540,7 @@ public final class FileUtils {
final Object lock = SAVE_MAP_LOCKS.computeIfAbsent(lockKey, k -> new Object());
synchronized (lock) {
/* Take the snapshot in write order so delayed callers cannot persist stale state. */
final Map<String, String> propsCopy = new HashMap<>(props);
final Map<String, String> propsCopy = new TreeMap<>(props);
File tf = null;
PrintWriter pw = null;
try {