fix: assure close inputstream in TranslatorXliff after reading xlf file

by using try-wiht-resource block
pull/56/head
reger 9 years ago
parent 19509438d9
commit bb0076c3dd

@ -85,8 +85,7 @@ public class TranslatorXliff extends Translator {
* </xliff> * </xliff>
*/ */
Xliff xliffTranslation; Xliff xliffTranslation;
try { try (FileInputStream fis = new FileInputStream(xliffFile)){ // try-with-resource to close inputstream
FileInputStream fis = new FileInputStream(xliffFile);
JAXBContext ctx = JAXBContext.newInstance(org.oasis.xliff.core_12.Xliff.class); JAXBContext ctx = JAXBContext.newInstance(org.oasis.xliff.core_12.Xliff.class);
Unmarshaller un = ctx.createUnmarshaller(); Unmarshaller un = ctx.createUnmarshaller();
Object obj = un.unmarshal(fis); Object obj = un.unmarshal(fis);
@ -132,6 +131,8 @@ public class TranslatorXliff extends Translator {
ConcurrentLog.warn("TRANSLATOR", je.getMessage()); ConcurrentLog.warn("TRANSLATOR", je.getMessage());
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
ConcurrentLog.warn("TRANSLATOR", "File not found: " + xliffFile.getAbsolutePath()); ConcurrentLog.warn("TRANSLATOR", "File not found: " + xliffFile.getAbsolutePath());
} catch (IOException ex) {
ConcurrentLog.warn("TRANSLATOR", ex.getMessage());
} }
return lngLists; return lngLists;
} }

Loading…
Cancel
Save