fix try...catch segments not closing files in some cases
parent
cffd468b68
commit
dbaba22207
|
@ -64,17 +64,24 @@ public class MapJarsTiny {
|
|||
.withMappings(TinyUtils.createTinyMappingProvider(mappings, fromM, toM))
|
||||
.build();
|
||||
|
||||
OutputConsumerPath outputConsumer = null;
|
||||
try {
|
||||
OutputConsumerPath outputConsumer = new OutputConsumerPath(output);
|
||||
outputConsumer = new OutputConsumerPath(output);
|
||||
outputConsumer.addNonClassFiles(input);
|
||||
remapper.read(input);
|
||||
remapper.read(classpath);
|
||||
remapper.apply(input, outputConsumer);
|
||||
outputConsumer.finish();
|
||||
remapper.finish();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to remap JAR", e);
|
||||
} finally {
|
||||
if (outputConsumer != null) {
|
||||
try {
|
||||
outputConsumer.finish();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
remapper.finish();
|
||||
throw new RuntimeException("Failed to remap minecraft to " + toM, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,11 +80,9 @@ public final class MixinRefmapHelper {
|
|||
ZipUtil.iterate(output, (stream, entry) -> {
|
||||
if (!entry.isDirectory() && entry.getName().endsWith(".json") && !entry.getName().contains("/") && !entry.getName().contains("\\")) {
|
||||
// JSON file in root directory
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(stream);
|
||||
try {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(stream);
|
||||
JsonObject json = GSON.fromJson(inputStreamReader, JsonObject.class);
|
||||
inputStreamReader.close();
|
||||
stream.close();
|
||||
if (json != null && json.has("mixins") && json.get("mixins").isJsonArray()) {
|
||||
if (!onlyWithoutRefmap || !json.has("refmap")) {
|
||||
mixinFilename.add(entry.getName());
|
||||
|
@ -92,6 +90,9 @@ public final class MixinRefmapHelper {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
// ...
|
||||
} finally {
|
||||
inputStreamReader.close();
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -105,16 +106,17 @@ public final class MixinRefmapHelper {
|
|||
ZipUtil.iterate(output, (stream, entry) -> {
|
||||
if (!entry.isDirectory() && entry.getName().endsWith(".json") && !entry.getName().contains("/") && !entry.getName().contains("\\")) {
|
||||
// JSON file in root directory
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(stream);
|
||||
try {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(stream);
|
||||
JsonObject json = GSON.fromJson(inputStreamReader, JsonObject.class);
|
||||
inputStreamReader.close();
|
||||
stream.close();
|
||||
if (json != null && json.has("refmap")) {
|
||||
mixinRefmapFilenames.add(json.get("refmap").getAsString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ...
|
||||
} finally {
|
||||
inputStreamReader.close();
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -99,8 +99,9 @@ public class ModProcessor {
|
|||
.withMappings(TinyUtils.createTinyMappingProvider(mappings, fromM, toM))
|
||||
.build();
|
||||
|
||||
OutputConsumerPath outputConsumer = null;
|
||||
try {
|
||||
OutputConsumerPath outputConsumer = new OutputConsumerPath(Paths.get(output.getAbsolutePath()));
|
||||
outputConsumer = new OutputConsumerPath(Paths.get(output.getAbsolutePath()));
|
||||
outputConsumer.addNonClassFiles(input.toPath());
|
||||
if (!modCompileFiles.contains(input)) {
|
||||
remapper.read(input.toPath());
|
||||
|
@ -112,9 +113,18 @@ public class ModProcessor {
|
|||
outputConsumer.finish();
|
||||
remapper.finish();
|
||||
} catch (Exception e){
|
||||
remapper.finish();
|
||||
throw new RuntimeException("Failed to remap JAR to " + toM, e);
|
||||
} finally {
|
||||
if (outputConsumer != null) {
|
||||
try {
|
||||
outputConsumer.finish();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
remapper.finish();
|
||||
}
|
||||
|
||||
if(!output.exists()){
|
||||
throw new RuntimeException("Failed to remap JAR to " + toM + " file not found: " + output.getAbsolutePath());
|
||||
}
|
||||
|
|
|
@ -79,17 +79,24 @@ public class ModRemapper {
|
|||
|
||||
TinyRemapper remapper = remapperBuilder.build();
|
||||
|
||||
OutputConsumerPath outputConsumer = null;
|
||||
try {
|
||||
OutputConsumerPath outputConsumer = new OutputConsumerPath(modJarOutputPath);
|
||||
outputConsumer = new OutputConsumerPath(modJarOutputPath);
|
||||
outputConsumer.addNonClassFiles(modJarPath);
|
||||
remapper.read(classpath);
|
||||
remapper.read(modJarPath);
|
||||
remapper.apply(modJarPath, outputConsumer);
|
||||
outputConsumer.finish();
|
||||
remapper.finish();
|
||||
} catch (Exception e){
|
||||
remapper.finish();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to remap JAR", e);
|
||||
} finally {
|
||||
if (outputConsumer != null) {
|
||||
try {
|
||||
outputConsumer.finish();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
remapper.finish();
|
||||
}
|
||||
|
||||
if (!modJarOutput.exists()){
|
||||
|
|
Loading…
Reference in New Issue