﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
23390	MapWithAI: Error when downloading the second time	schwarting	taylor.smock	"I’m trying to use the MapWithAI plugin with a custom data source: URL `https://hfs.github.io/brandenburg-addresses/missing.pmtiles` with type `PMTILES`.

What works:

1. Start with an empty JOSM session
2. Download OSM data in the area of interest
3. Use Data › MapWithAI › Data source name to download the MapWithAI data into a new, separate layer.

One can now work with the MapWithAI layer as expected.

What doesn’t work:

1. With a MapWithAI layer already in the session, pan the map view.
2. Download OSM data for the new map view.
3. The expected behavior would be that MapWithAI data is downloaded for the new map view and merged with the existing data in the existing MapWithAI layer. Afterwards one should be able to work with the newly downloaded data.
4. Instead, the `ProgressException: Expected states are [INIT] but current state is FINISHED` logged below is thrown.

Bug report information and stacktrace:

{{{
Revision:18907
Is-Local-Build:false
Build-Date:2023-12-07 18:29:01
Debian-Release:0.0.svn18907+dfsg-1
Build-Name:Debian

Identification: JOSM/1.5 (18907 Debian de) Linux Debian GNU/Linux trixie/sid
Memory Usage: 708 MB / 3894 MB (347 MB allocated, but free)
Java version: 17.0.9+9-Debian-2, Debian, OpenJDK 64-Bit Server VM
Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel
Screen: :0.0 3840×2400 (scaling 2.00×2.00)
Maximum Screen Size: 3840×2400
Best cursor sizes: 16×16→16×16, 32×32→32×32
Environment variable LANG: de_DE.utf8
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: de_DE
Numbers with default locale: 1234567890 -> 1234567890
Desktop environment: GNOME
Java package: openjdk-17-jre:amd64-17.0.9+9-2
Java ATK Wrapper package: libatk-wrapper-java:all-0.40.0-3
libcommons-compress-java: libcommons-compress-java:all-1.24.0-1
libcommons-logging-java: libcommons-logging-java:all-1.2-4
fonts-noto: fonts-noto:all-20201225-2
VM arguments: [--module-path=/usr/share/openjfx/lib, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, -Djosm.restart=true, -Djava.net.useSystemProxies=true, --add-exports=java.base/sun.security.action=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED]
Dataset consistency test: No problems found

Plugins:
+ DirectDownload (36178)
+ DirectUpload (36178)
+ FastDraw (36200)
+ ImportImagePlugin (36184)
+ MapRoulette (26)
+ OpeningHoursEditor (36196)
+ PicLayer (1.0.3)
+ PolygonCutOut (v0.7.3)
+ apache-commons (36176)
+ apache-http (36176)
+ buildings_tools (36200)
+ editgpx (36126)
+ ejml (36176)
+ flatlaf (36176)
+ geotools (36176)
+ gson (35924)
+ imagery-xml-bounds (36196)
+ jackson (36176)
+ javafx (36200)
+ jaxb (36118)
+ jna (36176)
+ jts (36004)
+ log4j (36176)
+ mapwithai (822)
+ measurement (36200)
+ opendata (36200)
+ photoadjust (36200)
+ pmtiles (36156)
+ pt_assistant (632)
+ public_transport (36200)
+ reverter (36196)
+ scripting (v0.3.0)
+ terracer (36196)
+ utilsplugin2 (36200)
+ wikipedia (605)

Tagging presets:
+ /usr/share/josm/data/defaultpresets.xml
+ https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/presets/nsi-josm-presets.min.xml

Map paint styles:
- https://josm.openstreetmap.de/josmfile?page=Styles/ParkingLanes&style&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Maxspeed&style&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Modified&style&zip=1
- http://github.com/bastik/mapcss-tools/raw/osm/mapnik2mapcss/osm-results/mapnik.zip
- https://josm.openstreetmap.de/josmfile?page=Styles/ParkingLanes&style&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Cycleways&style&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Lane_and_Road_Attributes&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/PublicTransport&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Building_Levels_Labels&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Coloured_Streets&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1

Last errors/warnings:
- 00021.900 W: java.net.SocketTimeoutException: Connect timed out
- 00022.001 E: Fehler beim Laden des Bildes 'http://openptmap.de/favicon_pt.png'
- 00025.624 E: java.io.IOException: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED. Ursache: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED. Ursache: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED
- 00025.628 E: Handled by bug report queue: java.io.IOException: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED. Ursache: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED. Ursache: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED
- 00037.017 W: java.net.SocketTimeoutException: Connect timed out
- 00037.018 W: Already here java.net.SocketTimeoutException: Connect timed out
- 00037.118 E: Fehler beim Laden des Bildes 'http://openptmap.de/favicon_pt.png'
- 00074.940 E: Handled by bug report queue: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED
- 00135.137 E: java.io.IOException: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED. Ursache: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED. Ursache: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED
- 00135.139 E: Handled by bug report queue: java.io.IOException: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED. Ursache: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED. Ursache: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED



=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (22) of main
java.io.IOException: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED
	at org.openstreetmap.josm.plugins.mapwithai.backend.DownloadMapWithAITask$DownloadTask.realRun(DownloadMapWithAITask.java:183)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.doRealRun(PleaseWaitRunnable.java:94)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.run(PleaseWaitRunnable.java:142)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.util.concurrent.ExecutionException: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED
	at java.base/java.util.concurrent.ForkJoinTask.reportExecutionException(ForkJoinTask.java:605)
	at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:981)
	at org.openstreetmap.josm.plugins.mapwithai.backend.DownloadMapWithAITask$DownloadTask.realRun(DownloadMapWithAITask.java:158)
	... 7 more
Caused by: org.openstreetmap.josm.gui.progress.ProgressException: Expected states are [INIT] but current state is FINISHED
	at org.openstreetmap.josm.gui.progress.AbstractProgressMonitor.checkState(AbstractProgressMonitor.java:84)
	at org.openstreetmap.josm.gui.progress.AbstractProgressMonitor.beginTask(AbstractProgressMonitor.java:99)
	at org.openstreetmap.josm.data.osm.DataSetMerger.merge(DataSetMerger.java:413)
	at org.openstreetmap.josm.data.osm.DataSetMerger.merge(DataSetMerger.java:396)
	at org.openstreetmap.josm.data.osm.DataSet.mergeFrom(DataSet.java:1249)
	at org.openstreetmap.josm.plugins.mapwithai.backend.BoundingBoxMapWithAIDownloader.readMvt(BoundingBoxMapWithAIDownloader.java:340)
	at org.openstreetmap.josm.plugins.mapwithai.backend.BoundingBoxMapWithAIDownloader.parseDataSet(BoundingBoxMapWithAIDownloader.java:257)
	at org.openstreetmap.josm.io.BoundingBoxDownloader.parseOsm(BoundingBoxDownloader.java:215)
	at org.openstreetmap.josm.plugins.mapwithai.backend.BoundingBoxMapWithAIDownloader.parseOsm(BoundingBoxMapWithAIDownloader.java:152)
	at org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils.lambda$download$6(MapWithAIDataUtils.java:177)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1428)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinTask.awaitDone(ForkJoinTask.java:436)
	at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:979)
	... 8 more
}}}"	defect	closed	normal		Plugin mapwithai		fixed	MapWithAI PMTiles ProgressException	
