Skip to content

Commit

Permalink
JENKINS-19090 closing the InputStream after using it
Browse files Browse the repository at this point in the history
  • Loading branch information
escoem committed Nov 4, 2016
1 parent 4cb5aee commit 90790e4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/jenkins/plugins/util/ReadUtil.java
Expand Up @@ -19,15 +19,25 @@ public class ReadUtil {
private static final Logger LOGGER = Logger.getLogger(ReadUtil.class.getName());

public static Properties getJobProperties(Job job) {
FileInputStream fs = null;
try {
File rootDir = job.getRootDir();
File file = new File(rootDir.getAbsolutePath() + File.separator + StoreUtil.BANGKOU_PROPERTIES);
fs = new FileInputStream(file);
Properties properties = new Properties();
properties.load(new FileInputStream(file));
properties.load(fs);
return properties;
} catch (IOException e) {
LOGGER.warning(String.format("get property file error : %s", e.getMessage()));
return null;
} finally {
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
LOGGER.warning(String.format("error while closing the stream: %s", e.getMessage()));
}
}
}
}

Expand Down

0 comments on commit 90790e4

Please sign in to comment.