Index: src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java
===================================================================
--- src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java	(revision 19103)
+++ src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java	(working copy)
@@ -1,11 +1,9 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.io.session;
 
-import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
-import java.io.UncheckedIOException;
 import java.io.Writer;
 import java.nio.charset.StandardCharsets;
 
@@ -13,7 +11,6 @@
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.io.OsmWriter;
 import org.openstreetmap.josm.io.OsmWriterFactory;
-import org.openstreetmap.josm.tools.JosmRuntimeException;
 
 /**
  * Session exporter for {@link OsmDataLayer}.
@@ -37,19 +34,16 @@
     /**
      * Exports OSM data to the given output stream.
      * @param data data set
-     * @param out output stream
+     * @param out output stream (must not be closed)
      * @since 15386
      */
     public static void exportData(DataSet data, OutputStream out) {
         Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
+        OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, data.getVersion());
         data.getReadLock().lock();
-        try (OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, data.getVersion())) {
+        try {
             w.write(data);
             w.flush();
-        } catch (IOException e) {
-            // Catch needed since XmlWriter (parent of OsmWriter) has IOException in the method signature.
-            // It doesn't actually throw though. In other words, we should never hit this.
-            throw new UncheckedIOException(e);
         } finally {
             data.getReadLock().unlock();
         }
