aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaven Szewczyk <git@eigenraven.me>2024-08-18 18:56:49 +0100
committerGitHub <noreply@github.com>2024-08-18 12:56:49 -0500
commit1693e69c9776ea7ef43ac42485ffcb25a5334627 (patch)
tree4c64d26210d7d4025f7944bc59c624976b1f4c27
parent8199ce2fbf3116dea5edc188919de1ce3ad8f7d6 (diff)
downloadGT5-Unofficial-1693e69c9776ea7ef43ac42485ffcb25a5334627.tar.gz
GT5-Unofficial-1693e69c9776ea7ef43ac42485ffcb25a5334627.tar.bz2
GT5-Unofficial-1693e69c9776ea7ef43ac42485ffcb25a5334627.zip
Add additional information if GT_NEI_DefaultHandler cache construction fails (#2922)
* Add additional information if GT_NEI_DefaultHandler cache construction fails * Missed exception chain
-rw-r--r--src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java88
1 files changed, 50 insertions, 38 deletions
diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
index dd99b6bb0e..99e7dc5459 100644
--- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
+++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
@@ -154,47 +154,59 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler {
List<CachedDefaultRecipe> cache;
if (cacheHolder.getCachedRecipesVersion() != GT_Mod.gregtechproxy.getNEIReloadCount()
|| (cache = cacheHolder.getCachedRecipes()) == null) {
- RecipeCategory defaultCategory = recipeMap.getDefaultRecipeCategory();
- Collection<GT_Recipe> recipes;
- if (this.recipeCategory == defaultCategory) {
- // This is main category, so merge categories that are configured as such
- Stream<GT_Recipe> recipesToMerge = recipeMap.getBackend()
- .getRecipeCategoryMap()
- .entrySet()
- .stream()
- .flatMap(entry -> {
- boolean merge = entry.getKey() != defaultCategory && GT_Mod.gregtechproxy.recipeCategorySettings
- .getOrDefault(entry.getKey(), RecipeCategorySetting.getDefault())
- == RecipeCategorySetting.MERGE;
- return merge ? entry.getValue()
- .stream() : Stream.empty();
- });
- recipes = Stream.concat(
- recipesToMerge,
- recipeMap.getBackend()
- .getRecipesByCategory(defaultCategory)
- .stream())
- .collect(Collectors.toList());
- } else {
- // This is "sub" category
- if (GT_Mod.gregtechproxy.recipeCategorySettings
- .getOrDefault(recipeCategory, RecipeCategorySetting.getDefault()) == RecipeCategorySetting.ENABLE) {
- recipes = recipeMap.getBackend()
- .getRecipesByCategory(recipeCategory);
+ try {
+ RecipeCategory defaultCategory = recipeMap.getDefaultRecipeCategory();
+ Collection<GT_Recipe> recipes;
+ if (this.recipeCategory == defaultCategory) {
+ // This is main category, so merge categories that are configured as such
+ Stream<GT_Recipe> recipesToMerge = recipeMap.getBackend()
+ .getRecipeCategoryMap()
+ .entrySet()
+ .stream()
+ .flatMap(entry -> {
+ boolean merge = entry.getKey() != defaultCategory
+ && GT_Mod.gregtechproxy.recipeCategorySettings
+ .getOrDefault(entry.getKey(), RecipeCategorySetting.getDefault())
+ == RecipeCategorySetting.MERGE;
+ return merge ? entry.getValue()
+ .stream() : Stream.empty();
+ });
+ recipes = Stream.concat(
+ recipesToMerge,
+ recipeMap.getBackend()
+ .getRecipesByCategory(defaultCategory)
+ .stream())
+ .collect(Collectors.toList());
} else {
- recipes = Collections.emptyList();
+ // This is "sub" category
+ if (GT_Mod.gregtechproxy.recipeCategorySettings
+ .getOrDefault(recipeCategory, RecipeCategorySetting.getDefault())
+ == RecipeCategorySetting.ENABLE) {
+ recipes = recipeMap.getBackend()
+ .getRecipesByCategory(recipeCategory);
+ } else {
+ recipes = Collections.emptyList();
+ }
}
+ cache = recipes.stream() // do not use parallel stream. This is already parallelized by NEI
+ .filter(r -> !r.mHidden)
+ .sorted(neiProperties.comparator)
+ .map(CachedDefaultRecipe::new)
+ .collect(Collectors.toList());
+ // while the NEI parallelize handlers, for each individual handler it still uses sequential execution
+ // model,
+ // so we do not need any synchronization here
+ // even if it does break, at worst case it's just recreating the cache multiple times, which should be
+ // fine
+ cacheHolder.setCachedRecipes(cache);
+ cacheHolder.setCachedRecipesVersion(GT_Mod.gregtechproxy.getNEIReloadCount());
+ } catch (Exception e) {
+ throw new RuntimeException(
+ "Could not construct GT NEI Handler cache for category " + recipeCategory
+ + ", display name "
+ + recipeNameDisplay,
+ e);
}
- cache = recipes.stream() // do not use parallel stream. This is already parallelized by NEI
- .filter(r -> !r.mHidden)
- .sorted(neiProperties.comparator)
- .map(CachedDefaultRecipe::new)
- .collect(Collectors.toList());
- // while the NEI parallelize handlers, for each individual handler it still uses sequential execution model,
- // so we do not need any synchronization here
- // even if it does break, at worst case it's just recreating the cache multiple times, which should be fine
- cacheHolder.setCachedRecipes(cache);
- cacheHolder.setCachedRecipesVersion(GT_Mod.gregtechproxy.getNEIReloadCount());
}
return cache;
}