Source:
public CompletableFuture<Void> update(FeaturedMod featuredMod, Integer version, Map<String, Integer> featuredModVersions, Set<String> simModUids) { List<PatchResult> patchResults = new ArrayList<>(); CompletableFuture<Void> future = updateFeaturedMod(featuredMod, version) .thenAccept(patchResults::add) .thenCompose(s -> downloadMissingSimMods(simModUids)); if (!NAMES_OF_FEATURED_BASE_MODS.contains(featuredMod.getTechnicalName())) { future = future.thenCompose(aVoid -> modService.getFeaturedMod(FAF.getTechnicalName())) .thenCompose(baseMod -> updateFeaturedMod(baseMod, version)) .thenAccept(patchResults::add); } verifyUniformModFormat(patchResults); return future .thenCompose(s -> updateGameBinaries(patchResults.get(patchResults.size() - 1).getVersion())) .thenRun(() -> { if (patchResults.stream().noneMatch(patchResult -> patchResult.getLegacyInitFile() != null)) { generateInitFile(patchResults); } else { Path initFile = patchResults.stream() .map(PatchResult::getLegacyInitFile) .filter(Objects::nonNull) .findFirst() .orElseThrow(() -> new ProgrammingError("No legacy init file is available")); createFaPathLuaFile(initFile.getParent().getParent()); copyLegacyInitFile(initFile); } }) .exceptionally(throwable -> { boolean allowReplaysWhileInGame = preferencesService.getPreferences().getForgedAlliance().isAllowReplaysWhileInGame(); if (throwable.getCause().getCause() instanceof AccessDeniedException && allowReplaysWhileInGame) { log.info("Unable to update file cause they are not writeable. " + "Experimental feature is turned on " + "that allows multiple game instances to run in parallel this is most likely the cause."); throw new UnsupportedOperationException("Unable to patch Forged Alliance to the required version due to conflicting version running"); } else if (!(allowReplaysWhileInGame && version != null)) { log.warn("Game not terminated correctly", throwable); notificationService.addImmediateErrorNotification(throwable, "error.game.notTerminatedCorrectly"); } return null; }); }

Target:
public CompletableFuture<Void> update(FeaturedMod featuredMod, Integer version, Map<String, Integer> featuredModVersions, Set<String> simModUids) { List<PatchResult> patchResults = new ArrayList<>(); CompletableFuture<Void> future = updateFeaturedMod(featuredMod, version) .thenAccept(patchResults::add) .thenCompose(s -> downloadMissingSimMods(simModUids)); if (!NAMES_OF_FEATURED_BASE_MODS.contains(featuredMod.getTechnicalName())) { future = future.thenCompose(aVoid -> modService.getFeaturedMod(FAF.getTechnicalName())) .thenCompose(baseMod -> updateFeaturedMod(baseMod, version)) .thenAccept(patchResults::add); } verifyUniformModFormat(patchResults); return future .thenCompose(s -> updateGameBinaries(patchResults.get(patchResults.size() - 1).getVersion())) .thenRun(() -> { if (patchResults.stream().noneMatch(patchResult -> patchResult.getLegacyInitFile() != null)) { generateInitFile(patchResults); } else { Path initFile = patchResults.stream() .map(PatchResult::getLegacyInitFile) .filter(Objects::nonNull) .findFirst() .orElseThrow(() -> new ProgrammingError("No legacy init file is available")); createFaPathLuaFile(initFile.getParent().getParent()); copyLegacyInitFile(initFile); } }) .exceptionally(throwable -> { boolean allowReplaysWhileInGame = preferencesService.getPreferences().getForgedAlliance().isAllowReplaysWhileInGame(); if (throwable.getCause().getCause() instanceof AccessDeniedException && allowReplaysWhileInGame) { log.info("Unable to update files and experimental replay feature is turned on " + "that allows multiple game instances to run in parallel this is most likely the cause."); throw new UnsupportedOperationException("Unable to patch Forged Alliance to the required version " + "due to conflicting version running", throwable); } else if (!allowReplaysWhileInGame) { log.warn("Game files not accessible", throwable); notificationService.addImmediateErrorNotification(throwable, "error.game.filesNotAccessible"); } else { log.info("Game files not accessible most likely due to concurrent game instances", throwable); } return null; }); }