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


##########
components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java:
##########
@@ -125,22 +120,55 @@ public boolean storeFile(String name, Exchange exchange, 
long size) throws Gener
             }
         }
 
+        try {
+            if (is == null) {
+                is = exchange.getIn().getMandatoryBody(InputStream.class);
+            }
+            executeScpTransfer(file, is, cfg);
+        } catch (InvalidPayloadException e) {
+            throw new GenericFileOperationFailedException("Cannot store file: 
" + name, e);
+        } finally {
+            // must close stream after usage
+            IOHelper.close(is);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean storeFileDirectly(String name, String payload) throws 
GenericFileOperationFailedException {
+        checkFileName(name);
+        ObjectHelper.notNull(session, "session");

Review Comment:
   Guard order differs from `storeFile` (which calls `notNull` first at line 
105, then `checkFileName` at line 107). Consider swapping:
   
   ```suggestion
           ObjectHelper.notNull(session, "session");
           checkFileName(name);
   ```



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