This is an automated email from the ASF dual-hosted git repository.
pottlinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
The following commit(s) were added to refs/heads/master by this push:
new 42a4f78b RAT-348: Use try-with-resources when reading ignore files
42a4f78b is described below
commit 42a4f78bfbeba3195dc1bded1e5653b527e5d469
Author: P. Ottlinger <[email protected]>
AuthorDate: Mon Jan 15 23:22:43 2024 +0100
RAT-348: Use try-with-resources when reading ignore files
---
.../java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git
a/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java
b/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java
index 4f5adccd..de9061bd 100644
---
a/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java
+++
b/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ignore/GlobIgnoreMatcher.java
@@ -19,7 +19,6 @@ package org.apache.rat.mp.util.ignore;
* under the License.
*/
-import org.apache.commons.io.IOUtils;
import org.apache.maven.plugin.logging.Log;
import java.io.BufferedReader;
@@ -77,9 +76,8 @@ public class GlobIgnoreMatcher implements IgnoreMatcher {
public void loadFile(final Log log, final File scmIgnore) {
if (scmIgnore != null && scmIgnore.exists() && scmIgnore.isFile()) {
log.debug("Parsing exclusions from " + scmIgnore);
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(scmIgnore));
+
+ try (BufferedReader reader = new BufferedReader(new
FileReader(scmIgnore))) {
String line;
while ((line = reader.readLine()) != null) {
if (!isComment(line)) {
@@ -90,8 +88,6 @@ public class GlobIgnoreMatcher implements IgnoreMatcher {
} catch (final IOException e) {
log.warn("Cannot parse " + scmIgnore + " for exclusions. Will
skip this file.");
log.debug("Skip parsing " + scmIgnore + " due to " +
e.getMessage());
- } finally {
- IOUtils.closeQuietly(reader);
}
}
}