Skip to content

Commit

Permalink
Use traditional try block to close object reader
Browse files Browse the repository at this point in the history
Support for withCloseable for the AutoCloseable interface, which
ObjectReader implements isn't added until Groovy 2.5. This would have
meant dropping compatibility with Groovy 2.4 and Gradle versions below
5, which isn't necessary.
  • Loading branch information
ajoberstar committed Mar 23, 2019
1 parent 1ead473 commit efe830d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ class JGitUtil {
static Commit convertCommit(Repository repo, RevCommit rev) {
Map props = [:]
props.id = ObjectId.toString(rev)
repo.jgit.repository.newObjectReader().withCloseable { reader ->
def reader = repo.jgit.repository.newObjectReader()
try {
props.abbreviatedId = reader.abbreviate(rev).name()
} finally {
reader.close()
}
PersonIdent committer = rev.committerIdent
props.committer = new Person(committer.name, committer.emailAddress)
Expand Down

0 comments on commit efe830d

Please sign in to comment.