ensured output streams are closed

Former-commit-id: 0c9b622e46349690cf68a383be0ee6c8fd7c553d
This commit is contained in:
Jeremy Long
2014-03-01 06:59:48 -05:00
parent b3d08e4cb8
commit 3c1a1fcca1

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.
*