You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2020/07/16 10:31:55 UTC

[GitHub] [maven-resources-plugin] elharo opened a new pull request #3: close file

elharo opened a new pull request #3:
URL: https://github.com/apache/maven-resources-plugin/pull/3


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-resources-plugin] elharo merged pull request #3: close file

Posted by GitBox <gi...@apache.org>.
elharo merged pull request #3:
URL: https://github.com/apache/maven-resources-plugin/pull/3


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-resources-plugin] olamy commented on a change in pull request #3: close file

Posted by GitBox <gi...@apache.org>.
olamy commented on a change in pull request #3:
URL: https://github.com/apache/maven-resources-plugin/pull/3#discussion_r456059236



##########
File path: src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java
##########
@@ -291,24 +291,18 @@ private void createFiles( String parent, String testparent )
         }
     }
 
-    private void populateFile( File file )
+    private void populateFile( File file ) throws IOException
     {
-        FileOutputStream outputStream;
         String data = dataMap.get( file.getName() );
 
         if ( ( data != null ) && file.exists() )
         {
-            try
+            try ( FileOutputStream outputStream = new FileOutputStream( file ) )
             {
-                outputStream = new FileOutputStream( file );
                 outputStream.write( data.getBytes() );
                 outputStream.flush();
                 outputStream.close();

Review comment:
       yup no need of flush neither




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [maven-resources-plugin] roxspring commented on a change in pull request #3: close file

Posted by GitBox <gi...@apache.org>.
roxspring commented on a change in pull request #3:
URL: https://github.com/apache/maven-resources-plugin/pull/3#discussion_r455799993



##########
File path: src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java
##########
@@ -291,24 +291,18 @@ private void createFiles( String parent, String testparent )
         }
     }
 
-    private void populateFile( File file )
+    private void populateFile( File file ) throws IOException
     {
-        FileOutputStream outputStream;
         String data = dataMap.get( file.getName() );
 
         if ( ( data != null ) && file.exists() )
         {
-            try
+            try ( FileOutputStream outputStream = new FileOutputStream( file ) )
             {
-                outputStream = new FileOutputStream( file );
                 outputStream.write( data.getBytes() );
                 outputStream.flush();
                 outputStream.close();

Review comment:
       The try-with-resources should handle the `close()` - this line is now unnecessary. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org