Browse Source

Make sure a Stream is closed upon errors in IpLogGenerator

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
stable-0.9
Robin Rosenberg 15 years ago
parent
commit
e7c9db836b
  1. 60
      org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java

60
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();
}
}

Loading…
Cancel
Save