From f8723d9db4709d1d7048889ab6a01a0d125c6502 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Wed, 18 May 2022 08:25:40 -0600 Subject: [PATCH] ESRISourceReader: Directly submit ForkJoinTasks to safe ForkJoinPool This fixes JOSM #22077, which was caused by ForkJoinTask#fork submitting the task to ForkJoinPool#commonPool, when not called inside a ForkJoinPool. This is problematic under WebStart. Signed-off-by: Taylor Smock --- .../plugins/mapwithai/io/mapwithai/ESRISourceReader.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/ESRISourceReader.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/ESRISourceReader.java index 7a3b7d5..0170b3f 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/ESRISourceReader.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/ESRISourceReader.java @@ -36,6 +36,7 @@ import org.openstreetmap.josm.data.cache.JCSCacheManager; import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds; import org.openstreetmap.josm.data.preferences.LongProperty; import org.openstreetmap.josm.io.CachedFile; +import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAICategory; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIType; @@ -145,12 +146,13 @@ public class ESRISourceReader { newInfo.setId(feature.getString("id")); ForkJoinTask future; if (feature.getString("type", "").equals("Feature Service")) { - future = ForkJoinTask - .adapt(() -> newInfo.setUrl(featureService(newInfo, feature.getString("url"))), newInfo).fork(); + future = ForkJoinTask.adapt(() -> newInfo.setUrl(featureService(newInfo, feature.getString("url"))), + newInfo); } else { newInfo.setUrl(feature.getString("url")); - future = ForkJoinTask.adapt(() -> newInfo).fork(); + future = ForkJoinTask.adapt(() -> newInfo); } + MapWithAIDataUtils.getForkJoinPool().execute(future); newInfo.setName(feature.getString("title", feature.getString("name"))); String[] extent = feature.getJsonArray("extent").getValuesAs(JsonArray.class).stream() .flatMap(array -> array.getValuesAs(JsonNumber.class).stream()).map(JsonNumber::doubleValue)