davsclaus opened a new pull request, #30282:
URL: https://github.com/apache/camel/pull/30282

   ## Summary
   
   [CAMEL-27112](https://issues.apache.org/jira/browse/CAMEL-27112): 
`FileIdempotentRepository` and `FileStateRepository` took their file only as a 
`java.io.File`. Declaring one as a bean in YAML or properties with a file name 
failed with `NoTypeConversionAvailableException: ... java.lang.String to the 
required type: java.io.File`.
   
   - New `fileName` option (`setFileName(String)` / `getFileName()`) on both 
repositories, plus `String` variants of the static factory methods 
(`fileIdempotentRepository(String ...)`, `fileStateRepository(String ...)`).
   - `fileStore` (`java.io.File`) is unchanged. Either option must be set; 
`doStart` says `fileStore or fileName must be specified`. In the bean catalog, 
`fileStore` is no longer `required` (now either one is).
   - No general String to File type converter, as the ticket asks.
   
   ```yaml
   - beans:
       - name: readFiles
         type: 
"#class:org.apache.camel.support.processor.idempotent.FileIdempotentRepository"
         properties:
           fileName: /var/data/read-files.dat
   ```
   
   ### Why not an overloaded `setFileStore(String)`
   
   `FileIdempotentRepository` has a generated configurer. When setters are 
overloaded, the generator keeps the one that matches the field type (`File`), 
so YAML and properties would still fail. Making the configurer use the String 
setter instead would break the current workaround, `fileStore: 
"#class:java.io.File('...')"`: the File value would be converted to String by 
`IOConverter`, which reads the **content** of the file.
   
   ### Docs
   
   - file component: the "Using a file-based idempotent repository" section 
named the old package and a 1mb limit (it is 32mb, and the oldest entries are 
dropped), and announced an example that was missing. It now has a Java and a 
YAML example.
   - Idempotent Consumer EIP: a YAML bean example with `fileName`.
   - The CLI example `enrich-and-dedupe` README and a YAML validator hint 
suggested `fileStore` in YAML (the failing form); they now say `fileName`.
   
   ## Tests
   
   - `FileIdempotentRepositoryConfigurerTest` (camel-main): `fileName` binds 
through the generated configurer without reflection; `fileStore` with 
`#class:java.io.File(...)` still works.
   - `BeansTest` (camel-yaml-dsl): the YAML bean from the ticket, with 
`fileName`.
   - `FileStateRepositoryTest` (camel-core): `fileName` binds, the state is 
read again by a new repository with the same file name, and starting without a 
file fails with a clear message.
   - Ran `FileStateRepositoryTest` and `FileIdempotent*Test` in camel-core 
(41), `BeansTest` (25), `FileIdempotentRepositoryConfigurerTest` (3), 
`YamlValidatorPropertyHintTest` (92): all pass. The YAML doc example passes 
`camel validate yaml`.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to