mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 09:17:39 +00:00
fix: add timeout to reading history from exchanger (#2920)
This commit is contained in:
parent
7e75ce78ec
commit
393f80165c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user