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

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


The following commit(s) were added to refs/heads/camel-2.x by this push:
     new 7686dc9  [CAMEL-13711] Files.createTempFile not equivalent to 
File.createTempFile
7686dc9 is described below

commit 7686dc90540966ec81c5e46f4fb599a2cf9f4502
Author: Thomas Diesler <tdies...@redhat.com>
AuthorDate: Mon Jul 8 16:15:17 2019 +0200

    [CAMEL-13711] Files.createTempFile not equivalent to File.createTempFile
---
 .../org/apache/camel/component/hdfs2/HdfsFileType.java    | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java
 
b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java
index c5648ed..3c29507 100644
--- 
a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java
+++ 
b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java
@@ -141,12 +141,19 @@ public enum HdfsFileType {
                 String fname = hdfsPath.substring(hdfsPath.lastIndexOf('/'));
 
                 // [CAMEL-13711] Files.createTempFile not equivalent to 
File.createTempFile
-                int dotIndex = fname.indexOf('.');
-                if (dotIndex > 0) {
-                    fname = fname.substring(0, dotIndex);
+                
+                File outputDest;
+                try {
+                    
+                    // First trying: Files.createTempFile
+                    outputDest = Files.createTempFile(fname, ".hdfs").toFile();
+                    
+                } catch (Exception ex) {
+                    
+                    // Now trying: File.createTempFile
+                    outputDest = File.createTempFile(fname, ".hdfs");
                 }
 
-                File outputDest = Files.createTempFile(fname, 
".hdfs").toFile();
                 if (outputDest.exists()) {
                     outputDest.delete();
                 }

Reply via email to