urunni88 commented on code in PR #28361:
URL: https://github.com/apache/camel/pull/28361#discussion_r4361147792
##########
components/camel-file-watch/src/main/java/org/apache/camel/component/file/watch/FileWatchConsumer.java:
##########
@@ -171,12 +171,24 @@ private Exchange prepareExchange(FileEvent event) {
message.setHeader(FileWatchConstants.FILE_PARENT,
PathUtils.normalizeToString(event.getEventPath().getParent().toAbsolutePath()));
- message.setHeader(FileWatchConstants.FILE_LAST_MODIFIED,
event.getEventDate());
+ Long lastModified = lastModified(event.getEventPath());
+ if (lastModified != null) {
+ message.setHeader(FileWatchConstants.FILE_LAST_MODIFIED,
lastModified);
+ }
message.setHeader(Exchange.MESSAGE_TIMESTAMP, event.getEventDate());
return exchange;
}
+ private static Long lastModified(Path path) {
+ try {
+ return Files.getLastModifiedTime(path).toMillis();
+ } catch (IOException e) {
+ // the file no longer exists, such as for a DELETE event
Review Comment:
Thanks, now catching IOException | SecurityException.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]