Claus Ibsen created CAMEL-27913:
-----------------------------------
Summary: camel-file: checksumFileAlgorithm enum values fail,
readLockDeleteOrphanLockFiles ignored for readLock=rename, extendedAttributes
not trimmed, allowNullBody skips chmod
Key: CAMEL-27913
URL: https://issues.apache.org/jira/browse/CAMEL-27913
Project: Camel
Issue Type: Bug
Components: camel-file
Reporter: Claus Ibsen
Fix For: 4.25.0
Found while improving the option descriptions of camel-file for CAMEL-23832
(pull request https://github.com/apache/camel/pull/31179).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. checksumFileAlgorithm: most enum values fail
The enum of checksumFileAlgorithm lists SHA_1, SHA_224, SHA_256, SHA_384,
SHA_512, SHA_512_224, SHA_512_256 and SHA3_*, but {{GenericFileProducer}} /
{{FileOperations}} pass the value to MessageDigest.getInstance, which rejects
these names with NoSuchAlgorithmException. Only MD2 and MD5 work; the tests use
md5/sha256, which the catalog validation would flag as invalid.
Proposed change: use the JDK names (SHA-1, SHA-256, SHA-512/224, SHA3-256, ...)
in the enum, or map the enum names to them.
h4. 2. readLock=rename: readLockDeleteOrphanLockFiles has no effect
{{FileRenameExclusiveReadLockStrategy}} creates a .camelLock marker file when
readLockMarkerFile=true, but does not override prepareOnStartup and
setDeleteOrphanLockFiles, which are no-ops in
{{GenericFileRenameExclusiveReadLockStrategy}}. A marker file left behind by a
crash is never deleted, so that file is never picked up again.
Proposed change: delegate prepareOnStartup and setDeleteOrphanLockFiles to the
inner marker file strategy when the marker file is used.
h4. 3. extendedAttributes: names not trimmed, unsupported names fail every poll
The {{FileConsumer}} constructor splits extendedAttributes on "," without
trimming, so "posix:owner, basic:size" fails. An UnsupportedOperationException
or IllegalArgumentException from Files.getAttribute (unsupported view or
unknown name) is not caught, so every poll fails.
Proposed change: trim the names, and validate them at start or catch these
exceptions like the IOException.
h4. 4. allowNullBody=true: the empty file gets no chmod and no keepLastModified
{{FileOperations}} handleNullBody / writeFileEmptyBody write the empty file
without calling setPermissions and keepLastModified.
Proposed change: call them there too.
h4. 5. renameUsingCopy is ignored for the local work file
{{FileOperations.writeFileByLocalWorkPath}} calls FileUtil.renameFile directly,
so renameUsingCopy has no effect when the local work file is moved to the
target.
Proposed change: go through renameFile(from, to) or check
endpoint.isRenameUsingCopy().
h4. 6. Smaller issues
{{FileEndpoint.chmodPermissionsAreValid}} does not check the first of 4
characters (x755 is accepted), and it trims before taking the substring but
uses the untrimmed length. The error messages of FileLockClusterService
setClusterDataTaskMaxAttempts and setClusterDataTaskTimeout say
"clusterDataTaskMaxRetries must be greater than 0". FileUtil.renameFile
(camel-util) sleeps 1 s after the last failed attempt too.
includeExt/excludeExt are split on "," without trimming.
readLock=idempotent-changed and idempotent-rename without idempotentRepository
fail only in doStart, while doInit checks only readLock=idempotent.
CamelFileInitialOffset is typed long in the metadata but holds a Resumable, and
is set on every message even without a resume strategy. chmodDirectory is
labelled producer although the consumer applies it when it creates the starting
directory. The old text of readLockIdempotentReleaseAsyncPoolSize claimed a
default of 1 (the field defaults to 0).
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)