Merge pull request #776 from W25X80/feature_resource_leaks

Fix potential resource leaks in core file processing classes
This commit is contained in:
Jochen Staerk
2025-03-25 19:17:55 +01:00
committed by GitHub
6 changed files with 31 additions and 25 deletions

View File

@@ -142,8 +142,9 @@ public class ZUGFeRDVisualizer {
public String visualize(String xmlFilename, Language lang)
throws IOException, TransformerException, ParserConfigurationException {
FileInputStream fis = new FileInputStream(xmlFilename);
return visualize(fis, lang);
try (FileInputStream fis = new FileInputStream(xmlFilename)) {
return visualize(fis, lang);
}
}
public String visualize(InputStream inputXml, Language lang)
@@ -233,12 +234,14 @@ public class ZUGFeRDVisualizer {
protected String toFOP(String xmlFilename)
throws IOException, TransformerException, ParserConfigurationException {
FileInputStream fis = new FileInputStream(xmlFilename);
EStandard theStandard = findOutStandardFromRootNode(fis);
fis = new FileInputStream(xmlFilename);//rewind :-(
return toFOP(fis, theStandard);
EStandard theStandard;
try (FileInputStream fis = new FileInputStream(xmlFilename)) {
theStandard = findOutStandardFromRootNode(fis);
}
try (FileInputStream fis = new FileInputStream(xmlFilename)) {
return toFOP(fis, theStandard);
}
}
protected String toFOP(InputStream is, EStandard theStandard)