Subject: [PATCH] #22898
---
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java b/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java
a
|
b
|
|
430 | 430 | final IPreferences pref = Config.getPref(); |
431 | 431 | if (pref instanceof MemoryPreferences) { |
432 | 432 | final MemoryPreferences memoryPreferences = (MemoryPreferences) pref; |
433 | | tempPreferences.getAllSettings().entrySet().stream().filter(entry -> entry.getValue().isNew()) |
434 | | .forEach(entry -> memoryPreferences.putSetting(entry.getKey(), entry.getValue())); |
| 433 | tempPreferences.getAllSettings().forEach(memoryPreferences::putSetting); |
435 | 434 | } else { |
436 | 435 | throw new JosmRuntimeException(tr("Preferences are not the expected type")); |
437 | 436 | } |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java b/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java
a
|
b
|
|
9 | 9 | import java.io.ByteArrayInputStream; |
10 | 10 | import java.io.File; |
11 | 11 | import java.io.IOException; |
| 12 | import java.io.OutputStream; |
12 | 13 | import java.io.PrintWriter; |
13 | 14 | import java.lang.reflect.InvocationTargetException; |
14 | 15 | import java.nio.charset.StandardCharsets; |
… |
… |
|
45 | 46 | import org.openstreetmap.josm.io.OsmWriter; |
46 | 47 | import org.openstreetmap.josm.io.OsmWriterFactory; |
47 | 48 | import org.openstreetmap.josm.spi.lifecycle.Lifecycle; |
| 49 | import org.openstreetmap.josm.spi.preferences.Config; |
48 | 50 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences; |
49 | 51 | import org.openstreetmap.josm.tools.Logging; |
50 | 52 | import org.openstreetmap.josm.tools.Utils; |
… |
… |
|
175 | 177 | Files.deleteIfExists(Paths.get(errorPath)); |
176 | 178 | } |
177 | 179 | |
| 180 | /** |
| 181 | * A non-regression test for #22898: Validator CLI errors out when is run with --load-preferences argument |
| 182 | */ |
| 183 | @Test |
| 184 | void testNonRegression22898(final @TempDir Path preferencesLocation) throws IOException { |
| 185 | final ValidatorCLI validatorCLI = new ValidatorCLI(); |
| 186 | final Path preferences = preferencesLocation.resolve("preferences.xml"); |
| 187 | try (OutputStream fos = Files.newOutputStream(preferences)) { |
| 188 | final String pref = "<config>\n" + |
| 189 | " <preferences operation=\"replace\">\n" + |
| 190 | " <list key='plugins'>\n" + |
| 191 | " <entry value='baz'/>\n" + |
| 192 | " </list>\n" + |
| 193 | " </preferences>\n" + |
| 194 | "</config>"; |
| 195 | fos.write(pref.getBytes(StandardCharsets.UTF_8)); |
| 196 | } |
| 197 | validatorCLI.processArguments(new String[]{"--load-preferences=" + preferences, |
| 198 | "--input", "resources/styles/standard/elemstyles.mapcss"}); |
| 199 | assertEquals(Collections.singletonList("baz"), Config.getPref().getList("plugins")); |
| 200 | } |
| 201 | |
178 | 202 | /** |
179 | 203 | * Read json objects from a file |
180 | 204 | * @param path The file to read |