allthingssecurity commented on code in PR #27586:
URL: https://github.com/apache/camel/pull/27586#discussion_r4225498681
##########
components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatTest.java:
##########
@@ -229,6 +231,30 @@ final void testGetReaderHintMap() throws IOException {
}
}
+ /**
+ * A change made through the maps returned by the getters would bypass the
hints tracked by
+ * {@code addToHintMap}/{@code removeFromHintMap}, and be lost when the
data format starts again, so the maps are
+ * read-only.
+ */
+ @Test
+ final void testHintMapsAreReadOnly() throws IOException {
Review Comment:
Added `testHintMapsAreLiveViews` in a7c1f66a10a0: views obtained before the
first start show `addToHintMap` changes, the hints computed on start,
`removeFromHintMap` changes, and the hints computed again after a stop and
start (the backing maps are final and `optimizeHints()` refills them in place,
so the view stays live across restarts). camel-barcode: 40 tests, 0 failures.
_Claude Code on behalf of allthingssecurity_
##########
components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java:
##########
@@ -313,17 +314,21 @@ public final BarcodeParameters getParams() {
}
/**
- * The writer (encode) hint map.
+ * The writer (encode) hint map, as a read-only view. Use {@link
#addToHintMap(EncodeHintType, Object)} and
Review Comment:
Done in a7c1f66a10a0: the Javadoc now says it is a read-only live view that
shows later `addToHintMap`/`removeFromHintMap` changes and the hints computed
again on a start or restart.
_Claude Code on behalf of allthingssecurity_
##########
components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java:
##########
@@ -313,17 +314,21 @@ public final BarcodeParameters getParams() {
}
/**
- * The writer (encode) hint map.
+ * The writer (encode) hint map, as a read-only view. Use {@link
#addToHintMap(EncodeHintType, Object)} and
+ * {@link #removeFromHintMap(EncodeHintType)} to change it: the hints are
computed again when the data format
+ * starts, and only the changes made with these methods are applied again.
*/
public final Map<EncodeHintType, Object> getWriterHintMap() {
- return writerHintMap;
+ return Collections.unmodifiableMap(writerHintMap);
}
/**
- * The reader (decode) hint map.
+ * The reader (decode) hint map, as a read-only view. Use {@link
#addToHintMap(DecodeHintType, Object)} and
Review Comment:
Done in a7c1f66a10a0, same wording as `getWriterHintMap`: read-only live
view, showing later `addToHintMap`/`removeFromHintMap` changes and the hints
computed again on a start or restart.
_Claude Code on behalf of allthingssecurity_
--
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]