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

   # Description
   
   [CAMEL-25359](https://issues.apache.org/jira/browse/CAMEL-25359)
   
   Follow-up that @davsclaus asked for in the review of #27344 (CAMEL-25303): 
`getWriterHintMap()`/`getReaderHintMap()` returned the live hint maps, so 
changes made through them bypassed the add/remove tracking added there and were 
lost when the data format started again. `doStart()` computes the hints again 
(`optimizeHints()`, since CAMEL-22354) and re-applies only the changes made 
with `addToHintMap`/`removeFromHintMap`, so a hint put into or removed from the 
returned maps was lost before the start always, and after the start at the next 
restart.
   
   I considered two fixes:
   - read-only views: a change through the getters fails with 
`UnsupportedOperationException` instead of being lost, and 
`addToHintMap`/`removeFromHintMap` are the documented way to change hints;
   - a map view that routes `put`/`remove`/`clear`/iterator removal through the 
tracking: no exception, but a custom `Map` implementation (entry set, iterator, 
`setValue`) for a rarely used getter.
   
   This PR takes the read-only views. I checked the usage first: in Camel the 
getters are only read (by the camel-barcode tests), the reifier and the 
generated configurer only set `width`, `height`, `imageType` and 
`barcodeFormat`, the component page only shows `addToHintMap`, a GitHub code 
search for both getters finds only copies of Camel (nothing in 
camel-spring-boot, camel-quarkus, camel-kamelets or the examples), and property 
binding could not fill these maps anyway: it puts `String` keys, which an 
`EnumMap` rejects with a `ClassCastException`. Happy to switch to the routing 
view if you prefer no exception.
   
   This change:
   - both getters return `Collections.unmodifiableMap` views; they still show 
later changes. Javadoc points to `addToHintMap`/`removeFromHintMap`;
   - the component page says the maps are read-only and mentions 
`removeFromHintMap` (catalog copy updated);
   - upgrade guide: a new 4.23 section `=== camel-barcode - the hint maps are 
read-only (Breaking change)` (a change through the maps after the start used to 
work until the next restart, and now throws), next to the `=== camel-barcode - 
text outside ISO-8859-1` section from #27344.
   
   Tests (`BarcodeDataFormatTest`):
   - `testHintMapsAreReadOnly`: `put`, `remove` and `clear` on both maps throw 
`UnsupportedOperationException`, and the hints are unchanged. Fails without the 
change (nothing thrown).
   
   camel-barcode module with the change: 39 tests, 0 failures.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested the affected module, including the formatter and 
import-sort plugins. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commits carry 
a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 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