fix it directory test... and use try-resources
authorolivier lamy <olamy@apache.org>
Sat, 8 Dec 2018 09:59:11 +0000 (19:59 +1000)
committerolivier lamy <olamy@apache.org>
Sat, 8 Dec 2018 09:59:11 +0000 (19:59 +1000)
Signed-off-by: olivier lamy <olamy@apache.org>
src/it/projects/container-descriptors/custom-handler-withMixedEntries/verify.bsh
src/main/java/org/apache/maven/plugins/assembly/filter/SimpleAggregatingDescriptorHandler.java

index b531e33..d380581 100644 (file)
@@ -23,8 +23,8 @@ boolean result = true;
 
 try
 {
-    File a = new File( basedir, "target/its/target/assembly-1-bin/file.txt");
-    File b = new File( basedir, "target/its/target/assembly-1-bin/b/file.txt");
+    File a = new File( basedir, "assembly/target/assembly-1-bin/file.txt");
+    File b = new File( basedir, "assembly/target/assembly-1-bin/b/file.txt");
     
     if(result && !a.exists() ) {
         System.out.println( "File: " + a + " should have been generated, but was not." );
index 3f7bc38..ff39122 100644 (file)
@@ -190,33 +190,16 @@ public class SimpleAggregatingDescriptorHandler
     private void readProperties( final FileInfo fileInfo )
         throws IOException
     {
-        Reader reader = null;
-        StringWriter writer = null;
-        try
+        try ( StringWriter writer = new StringWriter();
+            Reader reader = AssemblyFileUtils.isPropertyFile( fileInfo.getName() )
+                ? new InputStreamReader( fileInfo.getContents(), StandardCharsets.ISO_8859_1 )
+                : new InputStreamReader( fileInfo.getContents() ) ) // platform encoding
         {
-            writer = new StringWriter();
-
-            reader = AssemblyFileUtils.isPropertyFile( fileInfo.getName() )
-                         ? new InputStreamReader( fileInfo.getContents(), StandardCharsets.ISO_8859_1 )
-                         : new InputStreamReader( fileInfo.getContents() ); // platform encoding
-
             IOUtil.copy( reader, writer );
-
-            writer.close();
             final String content = writer.toString();
-            writer = null;
-
-            reader.close();
-            reader = null;
-
             aggregateWriter.write( "\n" );
             aggregateWriter.write( content );
         }
-        finally
-        {
-            IOUtil.close( writer );
-            IOUtil.close( reader );
-        }
     }
 
     protected final Logger getLogger()