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

   # Description
   
   [CAMEL-27616](https://issues.apache.org/jira/browse/CAMEL-27616)
   
   The ticket lists six problems of camel-spring-redis that came up while the 
option descriptions were written for CAMEL-23832 (#30953). I checked each one 
against main. All six are fixed here; for point 3 I took a slightly different 
route than the ticket proposes, and for point 4 I left out one part of the 
proposal.
   
   Fixed:
   1. **ZREMRANGEBYSCORE read the score range as Long from CamelRedis.Start and 
CamelRedis.End.** The other score commands (ZCOUNT, ZRANGEBYSCORE, 
ZREVRANGEBYSCORE) read `CamelRedis.Min` and `CamelRedis.Max` as Double. So a 
fractional range could not be given, and a route that set Min and Max as for 
the other commands failed with a NullPointerException. ZREMRANGEBYSCORE now 
reads Min and Max as Double, and for each bound that is not set it falls back 
to Start or End, so existing routes keep working. `RedisClient` gets a 
`zremrangebyscore(String, Double, Double)`; the `Long` variant stays.
   2. **Typo in the endpoint syntax.** `@UriEndpoint` had 
`spring-redist:host:port`. It is now `spring-redis:host:port`. The generated 
JSON already showed the right scheme, so nothing generated changes for this 
point.
   3. **host and port were required but had no default.** When they are not 
set, the endpoint creates a `JedisConnectionFactory` that connects to 
localhost:6379 (the defaults of `RedisStandaloneConfiguration` in Spring Data 
Redis). They now have `defaultValue` `localhost` and `6379`. I kept them 
required rather than dropping `required`: for a required path parameter with a 
default, the endpoint URI factory and the catalog fill in the default when the 
value is missing. With `required = false` they would leave it out, so a port 
without a host would build `spring-redis:6379`, which the component reads as 
host `6379`. The generated `RedisEndpointUriFactory` now builds 
`spring-redis:localhost:6379` instead of failing with "Option host is required".
   4. **channels and redisTemplate had no label.** `channels` now has label 
`consumer` and `redisTemplate` has label `producer`. I did not add `advanced` 
to `connectionFactory` and `serializer`: it would move them to the Advanced 
builders of the Endpoint DSL, so 
`springRedis("localhost:6379").connectionFactory(cf)` would stop compiling, and 
both options are used by the consumer and by the producer.
   5. **Wrong javaType of the CamelRedis.Channel header.** The consumer sets a 
`String` (UTF-8 decoded) and PUBLISH reads a `String`, so the javaType is now 
`String`.
   6. **Headers had no label.** Every header that only the producer reads now 
has label `producer`. `CamelRedis.Channel` and `CamelRedis.Pattern`, which the 
consumer sets and the producer reads (PUBLISH and KEYS), stay common.
   
   The 4.24 upgrade guide has an entry for point 1, and for the Endpoint DSL 
side of point 4: `channels` is now only in the consumer builders and 
`redisTemplate` only in the producer builders, so code that sets `channels` on 
a producer endpoint, or `redisTemplate` on a consumer endpoint, no longer 
compiles. Neither option has any effect there.
   
   This touches the same lines as #30953 (the `@UriPath`, `@UriParam` and 
header `@Metadata` annotations, and the generated files), so whichever is 
merged second needs a small rebase. Two texts of #30953 become incomplete with 
this change: the description of `CamelRedis.Min` and `CamelRedis.Max` lists 
ZCOUNT, ZRANGEBYSCORE and ZREVRANGEBYSCORE but not ZREMRANGEBYSCORE, and the 
description of `CamelRedis.Start` and `CamelRedis.End` says they are the score 
range for ZREMRANGEBYSCORE, which is now only the fallback. The `javaType` of 
`CamelRedis.Channel` in #30953 is still `byte[] or String`.
   
   Tests (unit tests with a mocked `RedisTemplate`, no Redis server needed):
   - `RedisSortedSetTest`: two new tests, ZREMRANGEBYSCORE with Min and Max of 
1.5 and 2.5, and Min and Max winning over Start and End. The existing test with 
Start and End still passes unchanged.
   - `RedisEndpointUriFactoryTest` (new): the URI factory fills in localhost 
and 6379 when host or port is missing.
   
   Against the main sources the three new tests fail (the mocked 
`removeRangeByScore` is not called because of the NullPointerException, Start 
and End are used instead of Min and Max, and the URI factory throws "Option 
host is required").
   
   Results (offline, module build of camel-spring-redis, test phase): 289 tests 
run, 0 failures, 0 errors. The new tests pass 5 runs in a row.
   
   Generated files: `spring-redis.json` of the component and its catalog copy, 
the catalog copy of the doc page, `RedisEndpointUriFactory`, and the endpoint 
DSL (`RedisEndpointBuilderFactory` and the `Default value` lines in 
`StaticEndpointBuilders`).
   
   # 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): 
[CAMEL-27616](https://issues.apache.org/jira/browse/CAMEL-27616).
   
   # 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 camel-spring-redis and ran its unit tests, and committed the 
regenerated component JSON and URI factory. The catalog copies were updated to 
match them, and the endpoint DSL was generated from the catalog JSON with the 
camel-package goals, as an offline build of those modules was not possible 
here. 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 commit 
carries 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