diff --git a/citydb-cli/src/main/java/org/citydb/cli/deleter/DeleteCommand.java b/citydb-cli/src/main/java/org/citydb/cli/deleter/DeleteCommand.java index 685e0fc5..504d7f96 100644 --- a/citydb-cli/src/main/java/org/citydb/cli/deleter/DeleteCommand.java +++ b/citydb-cli/src/main/java/org/citydb/cli/deleter/DeleteCommand.java @@ -182,11 +182,10 @@ private DeleteOptions getExportOptions() { private void abort(long id, Throwable e) { synchronized (lock) { if (shouldRun) { + shouldRun = false; logger.warn("Database delete aborted due to an error."); helper.logException("Failed to delete feature (ID: " + id + ").", e); } - - shouldRun = false; } } } diff --git a/citydb-cli/src/main/java/org/citydb/cli/exporter/ExportController.java b/citydb-cli/src/main/java/org/citydb/cli/exporter/ExportController.java index 5d55a802..a0b0d63c 100644 --- a/citydb-cli/src/main/java/org/citydb/cli/exporter/ExportController.java +++ b/citydb-cli/src/main/java/org/citydb/cli/exporter/ExportController.java @@ -186,21 +186,14 @@ protected WriteOptions getWriteOptions(DatabaseAdapter databaseAdapter) { private void abort(Feature feature, long id, Throwable e) { synchronized (lock) { if (shouldRun) { - String message; - if (feature == null) { - message = "Failed to export feature (ID: " + id + ")."; - } else { - String objectId = feature.getObjectId().orElse(null); - message = "Failed to export " + feature.getFeatureType().getLocalName() + - (objectId != null ? " '" + objectId + "'" : "") + - " (ID: " + id + ")."; - } - + shouldRun = false; logger.warn("Database export aborted due to an error."); - helper.logException(message, e); + helper.logException(feature == null ? + "Failed to export feature (ID: " + id + ")." : + "Failed to export " + feature.getFeatureType().getLocalName() + + feature.getObjectId().map(objectId -> " '" + objectId + "'").orElse("") + + " (ID: " + id + ").", e); } - - shouldRun = false; } } } diff --git a/citydb-cli/src/main/java/org/citydb/cli/importer/ImportController.java b/citydb-cli/src/main/java/org/citydb/cli/importer/ImportController.java index 9a04224d..8162a374 100644 --- a/citydb-cli/src/main/java/org/citydb/cli/importer/ImportController.java +++ b/citydb-cli/src/main/java/org/citydb/cli/importer/ImportController.java @@ -211,12 +211,11 @@ protected ImportOptions getImportOptions() { private void abort(Feature feature, Throwable e) { synchronized (lock) { if (shouldRun) { + shouldRun = false; logger.warn("Database import aborted due to an error."); helper.logException("Failed to import " + feature.getFeatureType().getLocalName() + " '" + feature.getObjectId().orElse("unknown ID") + "'.", e); } - - shouldRun = false; } } }