[
https://issues.apache.org/jira/browse/CAMEL-24094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18096700#comment-18096700
]
Claus Ibsen commented on CAMEL-24094:
-------------------------------------
Fixed via PR https://github.com/apache/camel/pull/24749 (merged to main).
> camel-file: forceWrites option is dead since Camel 2.20 - no fsync is ever
> performed despite documented durability guarantee
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24094
> URL: https://issues.apache.org/jira/browse/CAMEL-24094
> Project: Camel
> Issue Type: Bug
> Components: camel-file
> Affects Versions: 4.21.0
> Reporter: Federico Mariani
> Assignee: Claus Ibsen
> Priority: Major
> Labels: code-review
> Fix For: 4.22.0
>
>
> h3. Problem
> {{forceWrites}} defaults to {{true}} and is documented as "Whether to force
> syncing writes to the file system. You can turn this off if you do not want
> this level of guarantee". The only references in camel-file main sources are
> the field/getter/setter in {{FileEndpoint}} (FileEndpoint.java:84-85,
> 361-371) - no write path in {{FileOperations}} calls {{isForceWrites()}},
> {{FileChannel.force()}}, {{FileDescriptor.sync()}} or uses
> {{StandardOpenOption.SYNC/DSYNC}}.
> h3. Failure scenario
> Users relying on the advertised durability (write a file, then ack a JMS
> message / commit a consumer offset) get no fsync at all; on power loss or
> crash the "written" file can be lost or partial despite {{forceWrites=true}}.
> h3. History
> CAMEL-6205 added the option and wired it through {{IOHelper.close(out, name,
> LOG, endpoint.isForceWrites())}} (which called {{channel.force(true)}}).
> Commit d8c0a53b6787 ("Start using Files.newXXputStream instead of new
> FileXXputStream to reduce finalizer contention", July 2017, Camel 2.20)
> replaced all write paths with NIO ({{Files.newByteChannel}}, {{Files.copy}},
> {{Files.newBufferedWriter}}) and dropped every {{isForceWrites()}} call - no
> JIRA, no doc/upgrade-guide change. The unused {{IOHelper.force(...)}} helpers
> still exist in core. This was collateral damage of a refactor, not an
> intentional semantics change: the option and its default were left in place
> and are still generated into the docs today.
> h3. Suggested fix
> Decision needed: re-wire fsync into the NIO write paths (honoring the
> option), or deprecate/remove the option with an upgrade-guide note stating
> the actual behavior since 2.20. Silently keeping a documented-but-dead
> durability knob is the worst of both.
> h3. Reproducer
> Not applicable - dead code is verifiable by inspection: {{grep -rn
> forceWrites components/camel-file/src/main/java}} returns only the
> FileEndpoint field/accessors.
> ----
> _This issue was researched and filed by Claude Code on behalf of [~croway]
> (GitHub: Croway), as part of a deep code review of camel-file and camel-ftp
> on current main (4.22.0-SNAPSHOT)._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)