Index: trunk/src/org/openstreetmap/josm/io/OsmExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmExporter.java	(revision 7561)
+++ trunk/src/org/openstreetmap/josm/io/OsmExporter.java	(revision 7562)
@@ -23,5 +23,5 @@
 
 /**
- * Exports data to an .Osm file.
+ * Exports data to an .osm file.
  * @since 1949
  */
@@ -68,5 +68,5 @@
     }
 
-    protected static final void checkOsmDataLayer(Layer layer) throws IllegalArgumentException {
+    protected static void checkOsmDataLayer(Layer layer) throws IllegalArgumentException {
         if (!(layer instanceof OsmDataLayer)) {
             throw new IllegalArgumentException(MessageFormat.format("Expected instance of OsmDataLayer. Got ''{0}''.", layer
@@ -90,17 +90,5 @@
             }
 
-            // create outputstream and wrap it with gzip or bzip, if necessary
-            try (
-                OutputStream out = getOutputStream(file);
-                Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
-                OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, layer.data.getVersion());
-            ) {
-                layer.data.getReadLock().lock();
-                try {
-                    w.writeLayer(layer);
-                } finally {
-                    layer.data.getReadLock().unlock();
-                }
-            }
+            doSave(file, layer);
             if (noBackup || !Main.pref.getBoolean("save.keepbackup", false)) {
                 if (tmpFile != null) {
@@ -135,3 +123,19 @@
         }
     }
+
+    protected void doSave(File file, OsmDataLayer layer) throws IOException, FileNotFoundException {
+        // create outputstream and wrap it with gzip or bzip, if necessary
+        try (
+            OutputStream out = getOutputStream(file);
+            Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
+            OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, layer.data.getVersion());
+        ) {
+            layer.data.getReadLock().lock();
+            try {
+                w.writeLayer(layer);
+            } finally {
+                layer.data.getReadLock().unlock();
+            }
+        }
+    }
 }
