From 97ed8d383e89a9950a26b7dde8b678a605a13263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Fri, 24 Sep 2021 10:09:18 +0200 Subject: [PATCH] Auto-close exploited resource --- .../org/apache/maven/plugins/invoker/InvokerSession.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java index 27820b42..c8ef9ca4 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java @@ -236,8 +236,10 @@ public void logFailedBuildLog( Log logger, boolean ignoreFailures ) buildLogMessage.append( System.lineSeparator() ); buildLogMessage.append( "*** begin build.log for: " + buildJob.getProject() + " ***" ); buildLogMessage.append( System.lineSeparator() ); - FileReader buildLogReader = new FileReader( buildLogFile ); - buildLogMessage.append( IOUtil.toString( buildLogReader ) ); + try ( FileReader buildLogReader = new FileReader( buildLogFile ) ) + { + buildLogMessage.append( IOUtil.toString( buildLogReader ) ); + } buildLogMessage.append( "*** end build.log for: " + buildJob.getProject() + " ***" ); buildLogMessage.append( System.lineSeparator() );