oscerd commented on code in PR #28954:
URL: https://github.com/apache/camel/pull/28954#discussion_r4448218714
##########
components/camel-azure/camel-azure-cosmosdb/src/main/java/org/apache/camel/component/azure/cosmosdb/CosmosDbConfigurationOptionsProxy.java:
##########
@@ -99,8 +122,85 @@ public PartitionKey getItemPartitionKey(final Exchange
exchange) {
String.class));
}
+ /**
+ * The item that createItem, upsertItem and replaceItem write. A Map or a
POJO is returned as it is: the SDK
+ * serializes it with Jackson. JSON as text, bytes, a stream or a file is
parsed into a Map: the SDK would write a
+ * String (or a file, as its path) as a JSON string and cannot serialize a
stream. These operations write one item,
+ * so a List of items, or JSON that is not an object, fails.
+ */
public Object getItem(final Exchange exchange) {
- return exchange.getIn().getBody();
+ final Object body = exchange.getIn().getBody();
+ if (ObjectHelper.isEmpty(body)) {
+ // the operation fails as the item is empty
+ return body;
+ }
+ if (body instanceof Collection || body.getClass().isArray() && !(body
instanceof byte[])) {
Review Comment:
Thanks, done: the condition now reads `body instanceof Collection ||
(body.getClass().isArray() && !(body instanceof byte[]))`.
_Claude Code on behalf of Andrea Cosentino (oscerd)_
--
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]