]> source.dussan.org Git - jgit.git/commitdiff
Make sure a Stream is closed upon errors in IpLogGenerator 51/851/1
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 13 Jun 2010 01:28:04 +0000 (03:28 +0200)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 13 Jun 2010 01:28:04 +0000 (03:28 +0200)
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java

index 28df8b7f53119a856086e61d9ea6b48c7dc110f6..f64c3298478efbaab857c75f1b29507e8743d75d 100644 (file)
@@ -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();
                }
        }