fix try...catch segments not closing files in some cases

This commit is contained in:
asie
2018-11-12 00:17:44 +01:00
parent cffd468b68
commit dbaba22207
4 changed files with 43 additions and 17 deletions

View File

@@ -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);
}
}
}