diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/ChangeExchangeCoordinator.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/ChangeExchangeCoordinator.java index 2f3398a60..3c020d422 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/ChangeExchangeCoordinator.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/ChangeExchangeCoordinator.java @@ -4,6 +4,8 @@ import com.sk89q.worldedit.history.change.Change; import org.jetbrains.annotations.ApiStatus; import java.util.concurrent.Exchanger; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.function.BiConsumer; /** @@ -32,8 +34,9 @@ public class ChangeExchangeCoordinator implements AutoCloseable { .start(() -> this.runnerTask.accept(this.exchanger, new Change[length])); } try { - return exchanger.exchange(consumed); - } catch (InterruptedException e) { + // Allow a reasonable timeout in case of weirdness + return exchanger.exchange(consumed, 30, TimeUnit.SECONDS); + } catch (InterruptedException | TimeoutException e) { this.runner.interrupt(); Thread.currentThread().interrupt(); return null;