You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/06/06 15:50:30 UTC

[camel] branch camel-3.18.x updated (ae146848232 -> c31535f43ba)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


    from ae146848232 CAMEL-19399: camel-cxf - Don't add entry in Converter cache on error (#10232)
     new 50a4d396d37 CAMEL-19421 - Camel-Jira: Use Files.createTempFile in FileConverter instead of creating File directly
     new c31535f43ba Update components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/camel/component/jira/FileConverter.java | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)


[camel] 01/02: CAMEL-19421 - Camel-Jira: Use Files.createTempFile in FileConverter instead of creating File directly

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 50a4d396d37c20c5be6aa0a5a4a8b85d2923fb5c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jun 6 17:06:33 2023 +0200

    CAMEL-19421 - Camel-Jira: Use Files.createTempFile in FileConverter instead of creating File directly
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../org/apache/camel/component/jira/FileConverter.java | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
index d7d2f3642d7..e19d85e4ef9 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.jira;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
 
 import org.apache.camel.Converter;
@@ -34,20 +35,13 @@ public final class 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);
+            Files.write(path, bos, StandardOpenOption.CREATE);
+            path.toFile().deleteOnExit();
         } else {
             file = (File) body;
         }


[camel] 02/02: Update components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c31535f43ba2f5992b280c336a2621aa15900da9
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jun 6 17:16:09 2023 +0200

    Update components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
    
    Co-authored-by: Jonathan Leitschuh <jo...@gmail.com>
---
 .../src/main/java/org/apache/camel/component/jira/FileConverter.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
index e19d85e4ef9..f3d838aedea 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
@@ -39,7 +39,7 @@ public final class FileConverter {
         Path path;
         if (body instanceof byte[]) {
             byte[] bos = (byte[]) body;
-            path = Files.createTempFile(genericFile.getFileName(), null, null);
+            path = Files.createTempFile(genericFile.getFileName(), null);
             Files.write(path, bos, StandardOpenOption.CREATE);
             path.toFile().deleteOnExit();
         } else {