ensured output streams are closed

Former-commit-id: c3102271cd7631bd1e38bf39b5f87ebb71da9e52
This commit is contained in:
Jeremy Long
2014-03-01 06:59:48 -05:00
parent a55710df7b
commit 9673b2aa7c

View File

@@ -25,6 +25,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
@@ -393,6 +394,8 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
} catch (IOException ex) {
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.SEVERE, null, ex);
} finally {
closeStream(bos);
closeStream(fos);
closeStream(input);
}
Model model = null;
@@ -439,6 +442,21 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
}
}
/**
* Silently closes an output stream ignoring errors.
*
* @param stream an output stream to close
*/
private void closeStream(OutputStream stream) {
if (stream != null) {
try {
stream.close();
} catch (IOException ex) {
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.FINEST, null, ex);
}
}
}
/**
* Retrieves the specified POM from a jar file and converts it to a Model.
*