You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2023/06/06 15:19:39 UTC

[GitHub] [camel] oscerd commented on a diff in pull request #10272: CAMEL-19421 - Camel-Jira: Use Files.createTempFile in FileConverter i…

oscerd commented on code in PR #10272:
URL: https://github.com/apache/camel/pull/10272#discussion_r1219844972


##########
components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java:
##########
@@ -34,20 +35,13 @@ private FileConverter() {
     @Converter
     public static File genericToFile(GenericFile<File> genericFile, Exchange exchange) throws IOException {
         Object body = genericFile.getBody();
-        File file;
+        File file = null;
+        Path path;
         if (body instanceof byte[]) {
             byte[] bos = (byte[]) body;
-            String destDir = System.getProperty("java.io.tmpdir");
-            if (destDir != null && !destDir.endsWith(File.separator)) {
-                destDir += File.separator;
-            }
-            file = new File(destDir, genericFile.getFileName());
-            if (!file.getCanonicalPath().startsWith(destDir)) {
-                throw new IOException("File is not jailed to the destination directory");
-            }
-            Files.write(file.toPath(), bos, StandardOpenOption.CREATE);
-            // delete the temporary file on exit, as other routing may need the file for post processing
-            file.deleteOnExit();
+            path = Files.createTempFile(genericFile.getFileName(), null, null);

Review Comment:
   Thanks for the hint, didn't notice that.



-- 
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: commits-unsubscribe@camel.apache.org

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