mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-21 16:49:43 +01:00
refactored closing input streams
Former-commit-id: 04c8b13428a4c7a215058bf54d47c62374d6a946
This commit is contained in:
@@ -393,11 +393,7 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
closeStream(input);
|
||||||
input.close();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Model model = null;
|
Model model = null;
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
@@ -423,17 +419,26 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.FINE, null, ex);
|
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.FINE, null, ex);
|
||||||
throw ex;
|
throw ex;
|
||||||
} finally {
|
} finally {
|
||||||
if (fis != null) {
|
closeStream(fis);
|
||||||
try {
|
|
||||||
fis.close();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.FINEST, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Silently closes an input stream ignoring errors.
|
||||||
|
*
|
||||||
|
* @param stream an input stream to close
|
||||||
|
*/
|
||||||
|
private void closeStream(InputStream 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.
|
* Retrieves the specified POM from a jar file and converts it to a Model.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user