mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-22 09:09:31 +01:00
ensured FileInputStream is correctly closed
Former-commit-id: 6e0362476f456e5af07e686fdccf04e600a97de8
This commit is contained in:
@@ -27,11 +27,9 @@ import java.io.Reader;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.parsers.SAXParser;
|
import javax.xml.parsers.SAXParser;
|
||||||
import javax.xml.parsers.SAXParserFactory;
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
|
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
@@ -68,11 +66,21 @@ public class SuppressionParser {
|
|||||||
* @throws SuppressionParseException thrown if the xml file cannot be parsed
|
* @throws SuppressionParseException thrown if the xml file cannot be parsed
|
||||||
*/
|
*/
|
||||||
public List<SuppressionRule> parseSuppressionRules(File file) throws SuppressionParseException {
|
public List<SuppressionRule> parseSuppressionRules(File file) throws SuppressionParseException {
|
||||||
|
FileInputStream fis = null;
|
||||||
try {
|
try {
|
||||||
return parseSuppressionRules(new FileInputStream(file));
|
fis = new FileInputStream(file);
|
||||||
|
return parseSuppressionRules(fis);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOGGER.log(Level.FINE, null, ex);
|
LOGGER.log(Level.FINE, null, ex);
|
||||||
throw new SuppressionParseException(ex);
|
throw new SuppressionParseException(ex);
|
||||||
|
} finally {
|
||||||
|
if (fis != null) {
|
||||||
|
try {
|
||||||
|
fis.close();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOGGER.log(Level.FINE, "Unable to close stream", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user