Skip to content

Commit

Permalink
fix: return sane saving future when holder is closed
Browse files Browse the repository at this point in the history
Cherry-picked from 86ef860
  • Loading branch information
ishland committed Feb 16, 2025
1 parent ce05a9d commit c226730
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
public class NewChunkHolderVanillaInterface extends ChunkHolder implements IFastChunkHolder {

private static final List<ChunkStatus> CHUNK_STATUSES = ChunkStatus.createOrderedList();
private static final CompletableFuture<Void> COMPLETED_VOID_FUTURE = CompletableFuture.completedFuture(null);

private final ItemHolder<ChunkPos, ChunkState, ChunkLoadingContext, NewChunkHolderVanillaInterface> newHolder;

Expand Down Expand Up @@ -192,7 +193,13 @@ public WorldChunk getPostProcessedChunk() {

@Override
public CompletableFuture<?> getSavingFuture() {
return this.newHolder.getOpFuture(); // already safe to use as the implementation creates a new future
synchronized (this.newHolder) {
if (this.newHolder.isOpen()) {
return this.newHolder.getOpFuture(); // already safe to use as the implementation creates a new future
} else {
return COMPLETED_VOID_FUTURE;
}
}
}

@Override
Expand Down

0 comments on commit c226730

Please sign in to comment.