Index: trunk/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java	(revision 18717)
+++ trunk/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java	(revision 18718)
@@ -163,4 +163,6 @@
     public void processArguments(final String[] argArray) {
         try {
+            // for right-left-hand traffic cache file, needed for preferences
+            Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance());
             // Ensure that preferences are only in memory
             Config.setPreferencesInstance(new MemoryPreferences());
@@ -348,5 +350,4 @@
         Logging.setLogLevel(this.logLevel);
         HttpClient.setFactory(Http1Client::new);
-        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); // for right-left-hand traffic cache file
         Config.setUrlsProvider(JosmUrls.getInstance());
         ProjectionRegistry.setProjection(Projections.getProjectionByCode("epsg:3857".toUpperCase(Locale.ROOT)));
Index: trunk/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java	(revision 18717)
+++ trunk/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java	(revision 18718)
@@ -5,5 +5,4 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.ByteArrayInputStream;
@@ -12,5 +11,5 @@
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
+import java.io.UncheckedIOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
@@ -29,9 +28,11 @@
 import javax.json.JsonObject;
 import javax.json.JsonReader;
-import javax.swing.SwingUtilities;
-
+
+import mockit.Mock;
+import mockit.MockUp;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.junit.jupiter.api.io.TempDir;
 import org.junit.jupiter.params.ParameterizedTest;
@@ -43,15 +44,13 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.io.OsmWriter;
 import org.openstreetmap.josm.io.OsmWriterFactory;
 import org.openstreetmap.josm.spi.lifecycle.Lifecycle;
 import org.openstreetmap.josm.spi.preferences.Config;
+import org.openstreetmap.josm.testutils.annotations.AnnotationUtils;
 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
+import org.openstreetmap.josm.testutils.annotations.ThreadSync;
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Utils;
-
-import mockit.Mock;
-import mockit.MockUp;
 
 /**
@@ -61,20 +60,11 @@
 @BasicPreferences
 class ValidatorCLITest {
+    @RegisterExtension
+    ThreadSync.ThreadSyncExtension threadSync = new ThreadSync.ThreadSyncExtension();
+
     @TempDir
     static File temporaryDirectory;
 
     TestHandler handler;
-
-    private static void synchronizeThreads() {
-        MainApplication.worker.execute(() -> { /* Sync worker thread */ });
-        try {
-            SwingUtilities.invokeAndWait(() -> { /* Sync EDT thread */ });
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            fail(e);
-        } catch (InvocationTargetException e) {
-            fail(e);
-        }
-    }
 
     @BeforeEach
@@ -87,6 +77,5 @@
 
     @AfterEach
-    void tearDown() throws InterruptedException, InvocationTargetException {
-        synchronizeThreads();
+    void tearDown() {
         Logging.getLogger().removeHandler(this.handler);
         this.handler.close();
@@ -113,7 +102,6 @@
                         return Files.copy(file.toPath(), Paths.get(temporaryDirectory.getPath(), renamedValidator)).getFileName().toString();
                     } catch (IOException e) {
-                        fail(e);
+                        throw new UncheckedIOException(e);
                     }
-                    return null;
                 }).map(Arguments::of);
     }
@@ -138,5 +126,5 @@
         final File outputFile = new File(outputPath);
         assertTrue(outputFile.exists());
-        synchronizeThreads();
+        threadSync.threadSync();
         final List<JsonObject> errors = readJsonObjects(outputFile.toPath());
         assertEquals(3, errors.stream().map(ValidatorCLITest::getMessage).filter("Overlapping Identical Landuses"::equals).count());
@@ -182,5 +170,6 @@
      */
     @Test
-    void testNonRegression22898(final @TempDir Path preferencesLocation) throws IOException {
+    void testNonRegression22898(final @TempDir Path preferencesLocation) throws IOException, ReflectiveOperationException {
+        AnnotationUtils.resetStaticClass(Config.class);
         final ValidatorCLI validatorCLI = new ValidatorCLI();
         final Path preferences = preferencesLocation.resolve("preferences.xml");
