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