mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Fixed the problem where an error would cause the main thread to continue
even though there were still parallel threads running. Also, handle exceptions in the AutomaticEventSubscriber rather than leaking them to the Parallel processor. Actually closes #6148 Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
3 files changed
+24
-4
No files matched your search
@@ -29,6 +29,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -138,7 +139,14 @@ public class ModList
|
||||
}
|
||||
catch (InterruptedException | ExecutionException e)
|
||||
{
|
||||
LOGGER.error(LOADING, "Encountered an exception during parallel processing", e);
|
||||
LOGGER.error(LOADING, "Encountered an exception during parallel processing - sleeping 10 seconds to wait for jobs to finish", e);
|
||||
errorHandler.accept(Collections.singletonList(new UncaughtModLoadingException(lifecycleEvent.fromStage(), e)));
|
||||
modLoadingThreadPool.awaitQuiescence(10, TimeUnit.SECONDS);
|
||||
if (!modLoadingThreadPool.isQuiescent()) {
|
||||
LOGGER.fatal(LOADING, "The parallel pool has failed to quiesce correctly, forcing a shutdown. There is something really wrong here");
|
||||
modLoadingThreadPool.shutdownNow();
|
||||
throw new RuntimeException("Forge played \"STOP IT NOW MODS!\" - it was \"NOT VERY EFFECTIVE\"");
|
||||
}
|
||||
}
|
||||
DeferredWorkQueue.runTasks(lifecycleEvent.fromStage(), errorHandler, executor);
|
||||
FMLLoader.getLanguageLoadingProvider().forEach(lp->lp.consumeLifecycleEvent(()->lifecycleEvent));
|
||||
@@ -212,4 +220,10 @@ public class ModList
|
||||
public <T> Stream<T> applyForEachModContainer(Function<ModContainer, T> function) {
|
||||
return indexedMods.values().stream().map(function);
|
||||
}
|
||||
|
||||
private static class UncaughtModLoadingException extends ModLoadingException {
|
||||
public UncaughtModLoadingException(ModLoadingStage stage, Throwable originalException) {
|
||||
super(null, stage, "fml.modloading.uncaughterror", originalException);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,9 +136,14 @@ public class FMLModContainer extends ModContainer
|
||||
LOGGER.error(LOADING,"Failed to create mod instance. ModID: {}, class {}", getModId(), modClass.getName(), e);
|
||||
throw new ModLoadingException(modInfo, event.fromStage(), "fml.modloading.failedtoloadmod", e, modClass);
|
||||
}
|
||||
LOGGER.debug(LOADING, "Injecting Automatic event subscribers for {}", getModId());
|
||||
AutomaticEventSubscriber.inject(this, this.scanResults, this.modClass.getClassLoader());
|
||||
LOGGER.debug(LOADING, "Completed Automatic event subscribers for {}", getModId());
|
||||
try {
|
||||
LOGGER.debug(LOADING, "Injecting Automatic event subscribers for {}", getModId());
|
||||
AutomaticEventSubscriber.inject(this, this.scanResults, this.modClass.getClassLoader());
|
||||
LOGGER.debug(LOADING, "Completed Automatic event subscribers for {}", getModId());
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error(LOADING,"Failed to register automatic subscribers. ModID: {}, class {}", getModId(), modClass.getName(), e);
|
||||
throw new ModLoadingException(modInfo, event.fromStage(), "fml.modloading.failedtoloadmod", e, modClass);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user