Claus Ibsen created CAMEL-24835:
-----------------------------------

             Summary: camel-file: a consumer on the current directory (file:. 
or file:./) never delivers a file
                 Key: CAMEL-24835
                 URL: https://issues.apache.org/jira/browse/CAMEL-24835
             Project: Camel
          Issue Type: Bug
          Components: camel-file
            Reporter: Claus Ibsen


A route that reads from the directory the application runs in delivers nothing, 
without any warning:

{code:yaml}
- route:
    from:
      uri: "file:.?noop=true&include=order.json"
      steps:
        - log: "READ ${header.CamelFileName}"
{code}

The route starts ({{Started route1 (file://.)}}) and never logs. {{file:./}} 
behaves the same. {{file:sub}} and an absolute path deliver the file at once. A 
{{pollEnrich}} with {{file://.?fileName=order.json}} returns null for the same 
reason.

Cause: {{FileConsumer.listFiles}} returns null when {{directory.isHidden()}} is 
true and hidden directories are not included, and {{new File(".").isHidden()}} 
is true on Unix, because {{java.io.File.isHidden}} only looks at whether the 
name starts with a dot. The current directory is not hidden; its name is.

Suggested fix: resolve the directory before the hidden check (canonical or real 
path), or exempt {{.}} and {{..}} from it. The same check in 
{{isMatchedHiddenFile}} for sub-directories is fine, as a sub-directory named 
with a dot is hidden.

Found by a local model in the round-2 benchmark on the camel-jbang-examples 
ladder (Camel 4.23.0-SNAPSHOT, main d1d54fb835b2): two of six examples used 
{{file:.}} to read a file next to the route and got no output and no message. A 
person writing the same gets the same silence.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to