gnodet-bot commented on code in PR #28309:
URL: https://github.com/apache/camel/pull/28309#discussion_r4352213134


##########
components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java:
##########
@@ -63,6 +66,26 @@
  */
 @UriEndpoint(firstVersion = "2.19.0", scheme = "couchbase", title = 
"Couchbase", syntax = "couchbase:protocol://hostname:port",
              category = { Category.DATABASE }, headersClass = 
CouchbaseConstants.class)
+@BodyTypes(consumerOut = @BodyType(value = Carrier.POJO, javaType = 
"com.couchbase.client.java.kv.GetResult",
+                                   byOption = {
+                                           @BodyType.When(option = 
"fullDocument", value = "false", carriers = Carrier.TEXT,
+                                                          javaType = 
"java.lang.String"),
+                                           @BodyType.When(option = "useView", 
value = "true", carriers = Carrier.POJO,
+                                                          javaType = 
"com.couchbase.client.java.kv.GetResult") },
+                                   description = "One message per document the 
query finds, read by its id (the"
+                                                 + " CamelCouchbaseId header) 
as the GetResult of the Couchbase SDK:"
+                                                 + " contentAsObject() gives 
the JSON document. With fullDocument=false the row"
+                                                 + " of the SQL++ query as 
JSON text, or with useView=true the value the view"
+                                                 + " emits"),
+           producerIn = @BodyType(value = { Carrier.TEXT, Carrier.MAP, 
Carrier.LIST, Carrier.POJO }, dependsOn = "operation",
+                                  description = "The document that CCB_PUT, 
the default, stores as JSON: a Map, a List or a"
+                                                + " POJO becomes JSON, and 
text is stored as a JSON string, so unmarshal JSON"
+                                                + " text first. Bytes, a 
stream or no body fail. CCB_GET and CCB_DEL do not use"
+                                                + " the body: the id is the 
CamelCouchbaseId header"),
+           producerOut = @BodyType(value = Carrier.VALUE, javaType = 
"java.lang.Boolean", dependsOn = "operation",

Review Comment:
   ⚠️ **Incomplete `byOption` coverage for `producerOut`:** The description 
correctly lists three distinct return types — `true` (Boolean) for `CCB_PUT`, 
the `GetResult` of the Couchbase SDK for `CCB_GET`, and the `MutationResult` as 
text for `CCB_DEL` — but the structured metadata only declares `Carrier.VALUE` 
/ `java.lang.Boolean`, which matches CCB_PUT alone. The other two cases fall 
through to the default `Carrier.VALUE` / Boolean, which is semantically 
incorrect.
   
   The `consumerOut` in this same annotation uses `byOption` with 
`fullDocument` and `useView` — the pattern is already present here. Consider 
adding:
   
   ```java
   producerOut = @BodyType(value = Carrier.VALUE, javaType = 
"java.lang.Boolean", dependsOn = "operation",
                            byOption = {
                                    @BodyType.When(option = "operation", value 
= "CCB_GET", carriers = Carrier.POJO,
                                                   javaType = 
"com.couchbase.client.java.kv.GetResult"),
                                    @BodyType.When(option = "operation", value 
= "CCB_DEL", carriers = Carrier.TEXT,
                                                   javaType = 
"java.lang.String") },
                            description = "true for CCB_PUT, the default; the 
GetResult of the Couchbase SDK for"
                                          + " CCB_GET, and the MutationResult 
as text for CCB_DEL. The producer removes"
                                          + " the CamelCouchbaseId header")
   ```



##########
components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisEndpoint.java:
##########
@@ -31,6 +34,87 @@
  */
 @UriEndpoint(firstVersion = "2.11.0", scheme = "spring-redis", title = "Spring 
Redis", syntax = "spring-redist:host:port",
              category = { Category.CACHE }, headersClass = 
RedisConstants.class)
+@BodyTypes(consumerOut = @BodyType(value = Carrier.UNKNOWN,
+                                   description = "The message as the 
serializer reads it: with the default JDK serializer the"
+                                                 + " Java object the publisher 
serialized, such as the String a PUBLISH of this"
+                                                 + " component sent, with the 
channel in the CamelRedis.Channel header. A"
+                                                 + " message that is not Java 
serialized, such as one from redis-cli, is"
+                                                 + " dropped with a WARN: set 
a StringRedisSerializer as the serializer to"
+                                                 + " receive text"),
+           producerIn = @BodyType(value = Carrier.ANY,
+                                  description = "The body is not used: the 
key, the value and the other arguments of the"
+                                                + " command come from headers, 
such as CamelRedis.Key and CamelRedis.Value, or"
+                                                + " CamelRedis.Channel and 
CamelRedis.Message for PUBLISH. Set CamelRedis.Value"
+                                                + " from the body to store the 
body: with the default serializer it must be"
+                                                + " Serializable, so a stream 
fails"),
+           producerOut = @BodyType(value = Carrier.UNCHANGED, dependsOn = 
"command",
+                                   byOption = {
+                                           @BodyType.When(option = "command", 
value = "SET", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "SETEX", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "MSET", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "HSET", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "HMSET", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "HDEL", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "DEL", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "PUBLISH", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "LSET", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "LTRIM", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "RENAME", carriers = Carrier.UNCHANGED),
+                                           @BodyType.When(option = "command", 
value = "EXISTS", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Boolean"),
+                                           @BodyType.When(option = "command", 
value = "EXPIRE", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Boolean"),
+                                           @BodyType.When(option = "command", 
value = "SETNX", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Boolean"),
+                                           @BodyType.When(option = "command", 
value = "HEXISTS", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Boolean"),
+                                           @BodyType.When(option = "command", 
value = "SISMEMBER", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Boolean"),
+                                           @BodyType.When(option = "command", 
value = "INCR", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "INCRBY", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "DECR", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "DECRBY", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "LPUSH", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "RPUSH", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "LLEN", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "SADD", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "SREM", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "SCARD", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "HLEN", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "TTL", carriers = Carrier.VALUE,
+                                                          javaType = 
"java.lang.Long"),
+                                           @BodyType.When(option = "command", 
value = "PING", carriers = Carrier.TEXT,
+                                                          javaType = 
"java.lang.String"),
+                                           @BodyType.When(option = "command", 
value = "ECHO", carriers = Carrier.TEXT,
+                                                          javaType = 
"java.lang.String"),
+                                           @BodyType.When(option = "command", 
value = "HGETALL", carriers = Carrier.MAP),
+                                           @BodyType.When(option = "command", 
value = "KEYS", carriers = Carrier.LIST),
+                                           @BodyType.When(option = "command", 
value = "HKEYS", carriers = Carrier.LIST),
+                                           @BodyType.When(option = "command", 
value = "HVALS", carriers = Carrier.LIST),
+                                           @BodyType.When(option = "command", 
value = "SMEMBERS", carriers = Carrier.LIST),
+                                           @BodyType.When(option = "command", 
value = "ZRANGE", carriers = Carrier.LIST),
+                                           @BodyType.When(option = "command", 
value = "ZREVRANGE", carriers = Carrier.LIST),
+                                           @BodyType.When(option = "command", 
value = "LRANGE", carriers = Carrier.LIST),
+                                           @BodyType.When(option = "command", 
value = "MGET", carriers = Carrier.LIST),
+                                           @BodyType.When(option = "command", 
value = "HMGET", carriers = Carrier.LIST) },

Review Comment:
   ⚠️ **Value-returning commands missing from `byOption`:** The description 
says _"the stored object for GET and the commands that read or pop one value"_ 
— but GET, HGET, LPOP, RPOP, SPOP, BLPOP, BRPOP, LINDEX, and SRANDMEMBER are 
absent from `byOption`. These commands replace the body with the stored value, 
so they fall through to `Carrier.UNCHANGED` (the default), which is 
semantically wrong. The PR's own test acknowledges the gap with the comment "is 
not known for GET."
   
   The PR description says "not known for the rest", so this is intentional for 
now — but naming the uncovered commands explicitly in the description (similar 
to how ssh says what fails) would help users understand the limitation. 
Alternatively, adding `byOption` entries for the main read commands (`GET`, 
`HGET`, `LPOP`, `RPOP`, `SPOP`) would close the most common usage gap.



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