Fix crash.

More small fixes.
This commit is contained in:
modmuss50
2022-10-07 10:28:53 +01:00
parent bfb7d9fcc2
commit 9d7a3eef8f
5 changed files with 19 additions and 7 deletions

View File

@@ -258,7 +258,13 @@ public class InterfaceInjectionProcessor implements JarProcessor, GenerateSource
* Reads the injected interfaces contained in a mod jar, or returns empty if there is none.
*/
public static List<InjectedInterface> fromModJar(Path modJarPath) {
return fromFabricModJson(FabricModJsonFactory.createFromZip(modJarPath));
FabricModJson fabricModJson = FabricModJsonFactory.createFromZipNullable(modJarPath);
if (fabricModJson == null) {
return Collections.emptyList();
}
return fromFabricModJson(fabricModJson);
}
public static List<InjectedInterface> fromFabricModJson(FabricModJson fabricModJson) {

View File

@@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.xml.xpath.XPath;

View File

@@ -57,6 +57,10 @@ public abstract class BuildSharedServiceManager implements BuildService<BuildSer
return provider;
}
public BuildSharedServiceManager() {
LOGGER.debug("New BuildSharedServiceManager instance");
}
public SharedServiceManager get() {
LOGGER.debug("Shared build service get");
return Objects.requireNonNull(sharedServiceManager);

View File

@@ -26,9 +26,9 @@ package net.fabricmc.loom.util.service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import org.slf4j.Logger;
@@ -40,7 +40,7 @@ import org.slf4j.LoggerFactory;
*/
public abstract class SharedServiceManager {
private static final Logger LOGGER = LoggerFactory.getLogger(BuildSharedServiceManager.class);
private final Map<String, SharedService> sharedServiceMap = new ConcurrentHashMap<>();
private final Map<String, SharedService> sharedServiceMap = new HashMap<>();
private boolean shutdown = false;
@@ -58,6 +58,7 @@ public abstract class SharedServiceManager {
S sharedService = (S) sharedServiceMap.get(id);
if (sharedService == null) {
LOGGER.debug("Creating service for {}", id);
sharedService = function.get();
sharedServiceMap.put(id, sharedService);
}
@@ -85,14 +86,14 @@ public abstract class SharedServiceManager {
sharedServiceMap.clear();
// This is required to ensure that mercury releases all of the file handles.
System.gc();
if (!exceptionList.isEmpty()) {
// Done to try and close all the services.
RuntimeException exception = new RuntimeException("Failed to close all shared services");
exceptionList.forEach(exception::addSuppressed);
throw exception;
}
// This is required to ensure that mercury releases all of the file handles.
System.gc();
}
}

View File

@@ -43,7 +43,7 @@ class FabricAPIBenchmark implements GradleProjectTestTrait {
allowExistingRepo: true,
repo: "https://github.com/FabricMC/fabric.git",
commit: "71b634e5b7845296b11be3fa6545f4fbfacc017f",
commit: "5f243a8b7849eac4b30cd876a22a127797a1c406",
patch: "fabric_api"
)