Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #185 from MarkEWaite/JENKINS-19994-close-changelog…
Browse files Browse the repository at this point in the history
…-opened-files

[JENKINS-19994] Close files opened by computeChangeLog, use abort()
  • Loading branch information
ndeloof committed Jan 6, 2014
2 parents 5ac9acd + 2faba2a commit d267bd6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/hudson/plugins/git/GitSCM.java
Expand Up @@ -938,6 +938,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspa
private void computeChangeLog(GitClient git, Revision revToBuild, BuildListener listener, BuildData previousBuildData, FilePath changelogFile, BuildChooserContext context) throws IOException, InterruptedException {
Writer out = new OutputStreamWriter(changelogFile.write(),"UTF-8");

boolean executed = false;
ChangelogCommand changelog = git.changelog();
changelog.includes(revToBuild.getSha1());
try {
Expand All @@ -955,10 +956,12 @@ private void computeChangeLog(GitClient git, Revision revToBuild, BuildListener
listener.getLogger().println("First time build. Skipping changelog.");
} else {
changelog.to(out).max(MAX_CHANGELOG).execute();
executed = true;
}
} catch (GitException ge) {
ge.printStackTrace(listener.error("Unable to retrieve changeset"));
} finally {
if (!executed) changelog.abort();
IOUtils.closeQuietly(out);
}
}
Expand Down

0 comments on commit d267bd6

Please sign in to comment.