`com/ishland/c2me/opts/allocs/mixin/MixinUtil.java` causing `SimpleReloadInstance` freeze if there is error when launching
SettingDust opened this issue ยท 0 comments
It's changing the behavior when combining. Disable the mixin with MixinCanceller allow my game crash correctly.
I'm not quite sure the reason. But the error is hidden, and the game will freeze in reload.
Looks like the original logic will add handler for all the futures. The overwrite only add one handler to the final future. Which cause the reload will freeze since there is error in the future, but nothing will be printed.
Original(mojmap):
public static <V> CompletableFuture<List<V>> sequenceFailFast(List<? extends CompletableFuture<? extends V>> list) {
CompletableFuture<List<V>> completablefuture = new CompletableFuture();
return fallibleSequence(list, completablefuture::completeExceptionally).applyToEither(completablefuture, Function.identity());
}
public static <V> CompletableFuture<List<V>> sequenceFailFastAndCancel(List<? extends CompletableFuture<? extends V>> list) {
CompletableFuture<List<V>> completablefuture = new CompletableFuture();
return fallibleSequence(list, throwable -> {
if (completablefuture.completeExceptionally(throwable)) {
for (CompletableFuture<? extends V> completablefuture1 : list) {
completablefuture1.cancel(true);
}
}
}).applyToEither(completablefuture, Function.identity());
}
private static <V> CompletableFuture<List<V>> fallibleSequence(List<? extends CompletableFuture<? extends V>> list2, Consumer<Throwable> consumer) {
List<V> list = Lists.<V>newArrayListWithCapacity(list2.size());
CompletableFuture<?>[] completablefuture = new CompletableFuture[list2.size()];
list2.forEach(completableFuture -> {
int i = list.size();
list.add(null);
completablefuture[i] = completableFuture.whenComplete((object, throwable) -> {
if (throwable != null) {
consumer.accept(throwable);
} else {
list.set(i, object);
}
});
});
return CompletableFuture.allOf(completablefuture).thenApply(void_ -> list);
}