davsclaus commented on code in PR #27344:
URL: https://github.com/apache/camel/pull/27344#discussion_r4181088341


##########
components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java:
##########
@@ -236,12 +256,14 @@ public final void addToHintMap(final EncodeHintType 
hintType, final Object value
      */
     public final void addToHintMap(final DecodeHintType hintType, final Object 
value) {
         this.readerHintMap.put(hintType, value);
+        this.userReaderHintMap.put(hintType, value);
     }
 
     /**
      * Removes a hint from writer (encode) hint map.
      */
     public final void removeFromHintMap(final EncodeHintType hintType) {
+        this.userWriterHintMap.remove(hintType);

Review Comment:
   Calling `removeFromHintMap` before start still cannot remove a *default* 
hint (e.g. `ERROR_CORRECTION`): `writerHintMap` is empty before start, so it 
logs the 'Could not find' WARN, and `doStart()` then adds the default back. 
This worked before CAMEL-22354. Should a removal before start also be 
remembered and applied after `optimizeHints()`?



##########
components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java:
##########
@@ -188,13 +199,21 @@ private void printImage(final Exchange exchange, final 
Object graph, final Outpu
         // set values
         final String type = this.params.getType().toString();
 
+        // ZXing writes the text in ISO-8859-1 unless a character set is 
given, so use UTF-8 for a text that
+        // ISO-8859-1 cannot represent (ZXing then writes an ECI that tells 
the reader the character set)
+        Map<EncodeHintType, Object> hints = writerHintMap;
+        if (!hints.containsKey(EncodeHintType.CHARACTER_SET) && 
!StandardCharsets.ISO_8859_1.newEncoder().canEncode(payload)) {

Review Comment:
   Non-Latin-1 text now produces a barcode with an ECI segment and UTF-8 bytes 
instead of `?`. That is the right call, but readers without ECI support will 
see a different payload, and the documented default changes from 'UTF-8' to 
'ISO-8859-1 or UTF-8'. Should the 4.23 upgrade guide have a short note?



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