gnodet-bot commented on code in PR #29463:
URL: https://github.com/apache/camel/pull/29463#discussion_r4511873898


##########
components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java:
##########
@@ -30,20 +30,23 @@ public class SftpSimpleConsumeNoStartingDirIT extends 
SftpServerTestSupport {
 
     @Test
     public void testSftpSimpleConsume() throws Exception {
-        // create files using regular file
         File file = new File("a.txt");
-        FileOutputStream fos = new FileOutputStream(file, false);
-        fos.write("ABC".getBytes());
-        fos.close();
+        try {
+            // create files using regular file
+            FileOutputStream fos = new FileOutputStream(file, false);
+            fos.write("ABC".getBytes());
+            fos.close();

Review Comment:
   💡 Minor nit: `fos` is not closed if `fos.write()` throws — the `close()` 
call would be skipped. Since the code is being restructured anyway, consider 
using try-with-resources:
   
   ```suggestion
               try (FileOutputStream fos = new FileOutputStream(file, false)) {
                   fos.write("ABC".getBytes());
               }
   ```



##########
components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpSimpleConsumeNoStartingDirIT.java:
##########
@@ -30,20 +30,23 @@ public class SftpSimpleConsumeNoStartingDirIT extends 
SftpServerTestSupport {
 
     @Test
     public void testSftpSimpleConsume() throws Exception {
-        // create files using regular file
         File file = new File("a.txt");
-        FileOutputStream fos = new FileOutputStream(file, false);
-        fos.write("ABC".getBytes());
-        fos.close();
+        try {
+            // create files using regular file
+            FileOutputStream fos = new FileOutputStream(file, false);
+            fos.write("ABC".getBytes());
+            fos.close();

Review Comment:
   💡 Minor nit: same issue — use try-with-resources for `fos` to ensure it's 
closed even if `write()` throws:
   
   ```suggestion
               try (FileOutputStream fos = new FileOutputStream(file, false)) {
                   fos.write("ABC".getBytes());
               }
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to