From e7c9db836bb3b7b33f3e7894c0a3de6f9aeab621 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Sun, 13 Jun 2010 03:28:04 +0200 Subject: [PATCH] Make sure a Stream is closed upon errors in IpLogGenerator Signed-off-by: Robin Rosenberg --- .../eclipse/jgit/iplog/IpLogGenerator.java | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java index 28df8b7f5..f64c32984 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java @@ -236,36 +236,40 @@ public class IpLogGenerator { SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); File list = new File(repo.getDirectory(), "gerrit_committers"); BufferedReader br = new BufferedReader(new FileReader(list)); - String line; - - while ((line = br.readLine()) != null) { - String[] field = line.trim().split(" *\\| *"); - String user = field[1]; - String name = field[2]; - String email = field[3]; - Date begin = parseDate(dt, field[4]); - Date end = parseDate(dt, field[5]); - - if (user.startsWith("username:")) - user = user.substring("username:".length()); - - Committer who = committersById.get(user); - if (who == null) { - who = new Committer(user); - int sp = name.indexOf(' '); - if (0 < sp) { - who.setFirstName(name.substring(0, sp).trim()); - who.setLastName(name.substring(sp + 1).trim()); - } else { - who.setFirstName(name); - who.setLastName(null); + try { + String line; + + while ((line = br.readLine()) != null) { + String[] field = line.trim().split(" *\\| *"); + String user = field[1]; + String name = field[2]; + String email = field[3]; + Date begin = parseDate(dt, field[4]); + Date end = parseDate(dt, field[5]); + + if (user.startsWith("username:")) + user = user.substring("username:".length()); + + Committer who = committersById.get(user); + if (who == null) { + who = new Committer(user); + int sp = name.indexOf(' '); + if (0 < sp) { + who.setFirstName(name.substring(0, sp).trim()); + who.setLastName(name.substring(sp + 1).trim()); + } else { + who.setFirstName(name); + who.setLastName(null); + } + committersById.put(who.getID(), who); } - committersById.put(who.getID(), who); - } - who.addEmailAddress(email); - who.addActiveRange(new ActiveRange(begin, end)); - committersByEmail.put(email, who); + who.addEmailAddress(email); + who.addActiveRange(new ActiveRange(begin, end)); + committersByEmail.put(email, who); + } + } finally { + br.close(); } }