Closed
Description
In what version(s) of Spring Integration are you seeing this issue?
6.3.5
Describe the bug
When FileReadingMessageSource
's directory contains something like [dir]
or (dir)
in its absolute path (C:\[dir]
, /user/(dir)
, etc.) the value that ends up in FileHeaders.RELATIVE_PATH
header is incorrect (C:\[dir]\file.txt
instead of file.txt
). There is a misuse of Matcher.quoteReplacement
inside doReceive
where FileHeaders.RELATIVE_PATH
gets set. Pattern.quote
seems to be a better fit, or something like StringUtils.replaceOnce
.
To Reproduce
- Make a directory
C:\[dir]
with a filefile.txt
inside. - Make and run a simple Spring Boot Integration app with a single
IntegrationFlow
like this:
@Bean
IntegrationFlow flow() {
File dir = new File("C:\\[dir]");
return IntegrationFlow.from(Files.inboundAdapter(dir))
.handle(msg -> System.out.println(msg.getHeaders().get(FileHeaders.RELATIVE_PATH)))
.get();
}
Expected behavior
Expecting just file.txt
in the output.
Sample
https://github.com/ilya-komlev/spring-integration-bug-202410251558