Claus Ibsen created CAMEL-26229:
-----------------------------------

             Summary: camel-mongodb-gridfs - the consumer marks a file done 
when its route fails, and an unknown producer operation silently does nothing
                 Key: CAMEL-26229
                 URL: https://issues.apache.org/jira/browse/CAMEL-26229
             Project: Camel
          Issue Type: Bug
          Components: camel-mongodb-gridfs
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of mongodb-gridfs (CAMEL-24961, PR 
#28398).

h4. 1. The consumer marks a failed file as done

{{GridFsConsumer.processCollection}} (main 2a465aa4814c, lines 227-242) calls 
{{getProcessor().process(exchange)}} and never checks 
{{exchange.getException()}}, then marks the file done (line 230) and moves the 
timestamp past it (lines 233-238); an exception thrown by the processor is 
caught and ignored (line 241). A file whose route fails is never offered again. 
Read in the code, not run.

Proposed: check the exchange for an exception, leave the file and the timestamp 
unchanged when it failed, and report it through the exception handler.

h4. 2. The consumer never closes the download stream

{{processCollection}} opens a {{GridFSDownloadStream}} for each file (line 212) 
and sets it as the body (line 226), but never closes it after the exchange. 
Read in the code, not run.

Proposed: close the stream when the exchange is done (for example with an 
on-completion).

h4. 3. The consumer sets no CamelFileName

The consumer sets the content type, metadata, length and upload date headers 
(lines 215-225) but not the file name, so the route does not know which file it 
got. Checked on 4.24.0-SNAPSHOT with MongoDB from test-infra (docker).

Proposed: set {{CamelFileName}} to {{file.getFilename()}}.

h4. 4. An unknown operation silently does nothing

{{GridFsProducer.process}} (lines 50-129) is an if/else-if chain over the 
operation names with no final else, so a misspelled operation (for example 
{{findone}}) succeeds and does nothing. Checked on 4.24.0-SNAPSHOT with MongoDB 
from test-infra (docker).

Proposed: fail with the list of supported operations.

h4. 5. listAll prints the id as {{BsonObjectId\{value=...\}}}

{{DBCursorFilenameReader.fill}} (line 151) appends {{file.getId()}}, a 
{{BsonValue}}, so each line reads {{name<TAB>BsonObjectId\{value=665f...\}}} 
instead of the hex id. Checked on 4.24.0-SNAPSHOT with MongoDB from test-infra 
(docker).

Proposed: append {{file.getObjectId().toHexString()}}.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to