﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
23731	Cannot save session with two or more OSM layers	GerdP	team	"==== What steps will reproduce the problem?
1. Have two osm data layers and maybe other layers
2. Save Session 

==== What is the expected result?
Session is saved to given file name
==== What happens instead?
Error Popup ""Stream closed""
==== Please provide any additional information below. Attach a screenshot if possible.
Obviously a regression of r19003 which changed OsmDataSessionExporter so that the stream is closed when one layer is written. The stream should be kept open.
There is a unit test to check that and it fails `SessionWriterTest.testWriteOsmJoz()`


{{{
Revision:19103
Is-Local-Build:true
Build-Date:2024-06-13 06:57:57

Identification: JOSM/1.5 (19103 SVN en) Windows 10 64-Bit
OS Build number: Windows 10 Pro 22H2 (19045)
Memory Usage: 508 MB / 4096 MB (164 MB allocated, but free)
Java version: 17.0.5+8, Eclipse Adoptium, OpenJDK 64-Bit Server VM
Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Screen: \Display0 1920×1080 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1080
Best cursor sizes: 16×16→32×32, 32×32→32×32
System property file.encoding: UTF-8
System property sun.jnu.encoding: Cp1252
Locale info: en_DE
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:62374, --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, --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED, -javaagent:D:\eclipse-java-2020-09\eclipse\configuration\org.eclipse.osgi\3603\0\.cp\lib\javaagent-shaded.jar, -Dfile.encoding=UTF-8, -Dstdout.encoding=UTF-8, -Dstderr.encoding=UTF-8]
Dataset consistency test: No problems found

Plugins:
+ OpeningHoursEditor (36258)
+ RoadSigns (36258)
+ apache-commons (36273)
+ buildings_tools (36226)
+ comfort0 (36256)
+ ejml (36176)
+ geotools (36273)
+ jackson (36273)
+ jaxb (36118)
+ jts (36004)
+ o5m (36126)
+ opendata (36256)
+ pbf (36176)
+ poly (36126)
+ reltoolbox (36280)
+ reverter (36256)
+ undelete (36226)
+ utilsplugin2 (36241)

Tagging presets:
+ c:\josm\core\resources\data\defaultpresets.xml

Validator rules:
+ d:\java_tools\JOSM\mygeometry.mapcss
+ https://josm.openstreetmap.de/josmfile?page=Rules/GermanySpecific&zip=1
+ c:\josm\core\resources\data\validator\combinations.mapcss
+ c:\josm\core\resources\data\validator\geometry.mapcss

Last errors/warnings:
- 00000.598 W: extended font config - overriding 'filename.Myanmar_Text=mmrtext.ttf' with 'MMRTEXT.TTF'
- 00000.601 W: extended font config - overriding 'filename.Mongolian_Baiti=monbaiti.ttf' with 'MONBAITI.TTF'
- 00083.462 E: java.io.IOException: Stream closed
- 00083.480 E: IO Error - <html>Could not save session file 'test19003.joz'.<br>Error is:<br>Stream closed</html>
}}}

console log with traceback:
{{{
2024-06-13 07:07:39.608 SEVERE: java.io.IOException: Stream closed
java.io.IOException: Stream closed
	at java.base/java.util.zip.ZipOutputStream.ensureOpen(ZipOutputStream.java:96)
	at java.base/java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:199)
	at org.openstreetmap.josm.io.session.SessionWriter$ExportSupport.getOutputStreamZip(SessionWriter.java:233)
	at org.openstreetmap.josm.io.session.GenericSessionExporter.export(GenericSessionExporter.java:194)
	at org.openstreetmap.josm.io.session.SessionWriter.createJosDocument(SessionWriter.java:282)
	at org.openstreetmap.josm.io.session.SessionWriter.write(SessionWriter.java:395)
	at org.openstreetmap.josm.io.session.SessionWriter.write(SessionWriter.java:382)
	at org.openstreetmap.josm.actions.SessionSaveAction.saveSessionImpl(SessionSaveAction.java:266)
	at org.openstreetmap.josm.actions.SessionSaveAction.saveSession(SessionSaveAction.java:159)
	at org.openstreetmap.josm.actions.SessionSaveAsAction.actionPerformed(SessionSaveAsAction.java:47)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
	at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:374)
	at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1028)
	at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1072)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6626)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3389)
	at java.desktop/java.awt.Component.processEvent(Component.java:6391)
	at java.desktop/java.awt.Container.processEvent(Container.java:2266)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5001)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

2024-06-13 07:07:39.627 SEVERE: IO Error - <html>Could not save session file 'test19003.joz'.<br>Error is:<br>Stream closed</html>
2024-06-13 07:08:21.610 INFO: POST https://josm.openstreetmap.de/josmticket (2,99 kB) ...
2024-06-13 07:08:21.861 INFO: POST https://josm.openstreetmap.de/josmticket -> HTTP/1.1 200 (132 ms)
}}}
"	defect	closed	normal	24.06	Core		fixed	template_report	taylor.smock
