From 0819849ff991c765376d413b60367eb9ce7ebdba Mon Sep 17 00:00:00 2001 From: Michael Innerberger Date: Wed, 15 May 2024 22:59:11 -0400 Subject: [PATCH] Fix potential deadlock when fit failed --- mpicbg/src/main/java/mpicbg/models/TileUtil.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mpicbg/src/main/java/mpicbg/models/TileUtil.java b/mpicbg/src/main/java/mpicbg/models/TileUtil.java index 103f77a..9bfc086 100644 --- a/mpicbg/src/main/java/mpicbg/models/TileUtil.java +++ b/mpicbg/src/main/java/mpicbg/models/TileUtil.java @@ -249,9 +249,13 @@ private static Void fitAndApplyWorker( final boolean canBeProcessed = Collections.disjoint(tile.getConnectedTiles(), executingTiles); if (canBeProcessed) { - tile.fitModel(); - tile.apply(damp); - executingTiles.remove(tile); + try { + tile.fitModel(); + tile.apply(damp); + } finally { + // clean up if there was an exception, otherwise this can cause a deadlock + executingTiles.remove(tile); + } } else { executingTiles.remove(tile); pendingTiles.addLast(tile);