diff --git a/nuxeo-platform-document-routing-core/src/main/java/org/nuxeo/ecm/platform/routing/core/persistence/RouteModelsZipImporter.java b/nuxeo-platform-document-routing-core/src/main/java/org/nuxeo/ecm/platform/routing/core/persistence/RouteModelsZipImporter.java
index ea2e99b..b9e19c5 100644
--- a/nuxeo-platform-document-routing-core/src/main/java/org/nuxeo/ecm/platform/routing/core/persistence/RouteModelsZipImporter.java
+++ b/nuxeo-platform-document-routing-core/src/main/java/org/nuxeo/ecm/platform/routing/core/persistence/RouteModelsZipImporter.java
@@ -61,67 +61,70 @@ public class RouteModelsZipImporter extends ExportedZipImporter {
             throws ClientException, IOException {
 
         File tmp = File.createTempFile("xml-importer", null);
-        content.transferTo(tmp);
-        ZipFile zip = getArchiveFileIfValid(tmp);
+        try {
+            content.transferTo(tmp);
+            ZipFile zip = getArchiveFileIfValid(tmp);
 
-        if (zip == null) {
-            tmp.delete();
-            return null;
-        }
+            if (zip == null) {
+                return null;
+            }
 
-        boolean overWrite = false;
-        DocumentReader reader = new NuxeoArchiveReader(tmp);
-        ExportedDocument root = reader.read();
-        PathRef rootRef = new PathRef(path, root.getPath().toString());
-        ACP currentRouteModelACP = null;
-        if (session.exists(rootRef)) {
-            DocumentModel target = session.getDocument(rootRef);
-            if (target.getPath().removeLastSegments(1).equals(new Path(path))) {
-                overWrite = true;
-                // clean up existing route before import
-                DocumentModel routeModel = session.getDocument(rootRef);
-                currentRouteModelACP = routeModel.getACP();
-                session.removeDocument(rootRef);
+            boolean overWrite = false;
+            DocumentReader reader = new NuxeoArchiveReader(tmp);
+            ExportedDocument root = reader.read();
+            PathRef rootRef = new PathRef(path, root.getPath().toString());
+            ACP currentRouteModelACP = null;
+            if (session.exists(rootRef)) {
+                DocumentModel target = session.getDocument(rootRef);
+                if (target.getPath().removeLastSegments(1).equals(
+                        new Path(path))) {
+                    overWrite = true;
+                    // clean up existing route before import
+                    DocumentModel routeModel = session.getDocument(rootRef);
+                    currentRouteModelACP = routeModel.getACP();
+                    session.removeDocument(rootRef);
+                }
             }
-        }
 
-        DocumentWriter writer = new DocumentModelWriter(session, path, 10);
-        reader.close();
-        reader = new NuxeoArchiveReader(tmp);
+            DocumentWriter writer = new DocumentModelWriter(session, path, 10);
+            reader.close();
+            reader = new NuxeoArchiveReader(tmp);
 
-        DocumentRef resultingRef;
-        if (overwrite && overWrite) {
-            resultingRef = rootRef;
-        } else {
-            String rootName = root.getPath().lastSegment();
-            resultingRef = new PathRef(path, rootName);
-        }
+            DocumentRef resultingRef;
+            if (overwrite && overWrite) {
+                resultingRef = rootRef;
+            } else {
+                String rootName = root.getPath().lastSegment();
+                resultingRef = new PathRef(path, rootName);
+            }
 
-        try {
-            DocumentPipe pipe = new DocumentPipeImpl(10);
-            pipe.setReader(reader);
-            pipe.setWriter(writer);
-            pipe.run();
-        } catch (IllegalArgumentException e) {
-            log.error("Can not import route model", e);
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new RuntimeException("interrupted", e);
-        } catch (RuntimeException e) {
-            log.error("Can not import route model", e);
-            throw e;
-        } catch (Exception e) {
-            log.error("Can not import route model", e);
-            throw new RuntimeException(e);
+            try {
+                DocumentPipe pipe = new DocumentPipeImpl(10);
+                pipe.setReader(reader);
+                pipe.setWriter(writer);
+                pipe.run();
+            } catch (IllegalArgumentException e) {
+                log.error("Can not import route model", e);
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                throw new RuntimeException("interrupted", e);
+            } catch (RuntimeException e) {
+                log.error("Can not import route model", e);
+                throw e;
+            } catch (Exception e) {
+                log.error("Can not import route model", e);
+                throw new RuntimeException(e);
+            } finally {
+                reader.close();
+                writer.close();
+            }
+            DocumentModel newRouteModel = session.getDocument(resultingRef);
+            if (currentRouteModelACP != null && overwrite && overWrite) {
+                newRouteModel.setACP(currentRouteModelACP, true);
+            }
+            return session.saveDocument(newRouteModel);
         } finally {
-            reader.close();
-            writer.close();
-        }
-        tmp.delete();
-        DocumentModel newRouteModel = session.getDocument(resultingRef);
-        if (currentRouteModelACP != null && overwrite && overWrite) {
-            newRouteModel.setACP(currentRouteModelACP, true);
+            tmp.delete();
         }
-        return session.saveDocument(newRouteModel);
     }
 }
