3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 18:40:05 +01:00

fix: add timeout to reading history from exchanger (#2920)

Dieser Commit ist enthalten in:
Jordan 2024-09-19 05:55:53 +01:00 committet von GitHub
Ursprung 7e75ce78ec
Commit 393f80165c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -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;