gnodet-bot commented on code in PR #30457:
URL: https://github.com/apache/camel/pull/30457#discussion_r4635482553
##########
components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java:
##########
@@ -191,6 +190,37 @@ protected FTPClient createFtpClient() throws Exception {
return client;
}
+ /**
+ * The file option of the key store or trust store options, which the
other options need.
+ */
+ private static String storeFile(Map<String, Object> parameters, String
prefix) {
+ Object file = parameters.get("file");
+ if (file == null) {
+ throw new IllegalArgumentException(
+ prefix + "file must be set when other " + prefix + "*
options are set: " + parameters.keySet());
+ }
+ return file.toString();
+ }
+
+ /**
+ * Loads a key store or trust store file. Without a password the store is
loaded without one, as a store without a
+ * password, or a JKS trust store, can be read.
+ */
+ private static KeyStore loadStore(String type, String file, String
password, String name) throws Exception {
+ KeyStore store = KeyStore.getInstance(type);
+ FileInputStream is = new FileInputStream(new File(file));
+ try {
+ store.load(is, toChars(password));
+ } finally {
+ IOHelper.close(is, name, LOG);
+ }
Review Comment:
💡 `loadStore()` uses the `IOHelper.close`/`try-finally` pattern, but
`try-with-resources` is both idiomatic and shorter here — no need for the
`IOHelper` call at all:
```suggestion
try (FileInputStream is = new FileInputStream(new File(file))) {
store.load(is, toChars(password));
}
```
--
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]