Skip to content

Commit be74894

Browse files
author
Vladimir Kotal
authored
use try with resources (#2269)
1 parent 49ef723 commit be74894

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/GitAnnotationParser.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,22 @@ public Annotation getAnnotation() {
6969

7070
@Override
7171
public void processStream(InputStream input) throws IOException {
72-
BufferedReader in = new BufferedReader(GitRepository.newLogReader(input));
73-
String line = "";
74-
int lineno = 0;
75-
Matcher matcher = BLAME_PATTERN.matcher(line);
76-
while ((line = in.readLine()) != null) {
77-
++lineno;
78-
matcher.reset(line);
79-
if (matcher.find()) {
80-
String rev = matcher.group(1);
81-
String author = matcher.group(2).trim();
82-
annotation.addLine(rev, author, true);
83-
} else {
84-
LOGGER.log(Level.SEVERE,
85-
"Error: did not find annotation in line {0}: [{1}] of {2}",
86-
new Object[]{String.valueOf(lineno), line, annotation.getFilename()});
72+
try (BufferedReader in = new BufferedReader(GitRepository.newLogReader(input))) {
73+
String line = "";
74+
int lineno = 0;
75+
Matcher matcher = BLAME_PATTERN.matcher(line);
76+
while ((line = in.readLine()) != null) {
77+
++lineno;
78+
matcher.reset(line);
79+
if (matcher.find()) {
80+
String rev = matcher.group(1);
81+
String author = matcher.group(2).trim();
82+
annotation.addLine(rev, author, true);
83+
} else {
84+
LOGGER.log(Level.SEVERE,
85+
"Error: did not find annotation in line {0}: [{1}] of {2}",
86+
new Object[]{String.valueOf(lineno), line, annotation.getFilename()});
87+
}
8788
}
8889
}
8990
}

0 commit comments

Comments
 (0)