This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch close2 in repository https://gitbox.apache.org/repos/asf/maven-resources-plugin.git
commit a3a9da9e6365c56803d07c84b087935e660e05a6 Author: Elliotte Rusty Harold <elh...@ibiblio.org> AuthorDate: Thu Jul 16 10:39:07 2020 -0400 try with resources --- .../apache/maven/plugins/resources/ResourcesMojoTest.java | 12 +----------- .../plugins/resources/stub/MavenProjectBuildStub.java | 15 +++------------ 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/resources/ResourcesMojoTest.java b/src/test/java/org/apache/maven/plugins/resources/ResourcesMojoTest.java index bfbb903..169e2dc 100644 --- a/src/test/java/org/apache/maven/plugins/resources/ResourcesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/resources/ResourcesMojoTest.java @@ -37,7 +37,6 @@ import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; import org.sonatype.aether.RepositorySystemSession; public class ResourcesMojoTest @@ -691,18 +690,9 @@ public class ResourcesMojoTest throws IOException { assertTrue( FileUtils.fileExists( fileName ) ); - - BufferedReader reader = null; - try + try( BufferedReader reader = new BufferedReader( new FileReader( fileName ) ) ) { - reader = new BufferedReader( new FileReader( fileName ) ); assertEquals( data, reader.readLine() ); - reader.close(); - reader = null; - } - finally - { - IOUtil.close( reader ); } } diff --git a/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java b/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java index eee97a7..ad032c9 100644 --- a/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java +++ b/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java @@ -240,7 +240,7 @@ public class MavenProjectBuildStub } } - private void createFiles( String parent, String testparent ) + private void createFiles( String parent, String testparent ) throws IOException { File currentFile; @@ -278,15 +278,8 @@ public class MavenProjectBuildStub if ( !currentFile.exists() ) { - try - { - currentFile.createNewFile(); - populateFile( currentFile ); - } - catch ( IOException io ) - { - //TODO: handle exception - } + currentFile.createNewFile(); + populateFile( currentFile ); } } } @@ -300,8 +293,6 @@ public class MavenProjectBuildStub try ( FileOutputStream outputStream = new FileOutputStream( file ) ) { outputStream.write( data.getBytes() ); - outputStream.flush(); - outputStream.close(); } } }