gnodet-bot commented on code in PR #29505:
URL: https://github.com/apache/camel/pull/29505#discussion_r4559764388
##########
components/camel-redis/src/main/java/org/apache/camel/component/redis/processor/aggregate/RedisAggregationRepository.java:
##########
@@ -58,6 +60,35 @@ public class RedisAggregationRepository extends
ServiceSupport
private Map<String, DefaultExchangeHolder> persistedCache;
private boolean shutdownRedisson;
+ /**
+ * Atomic Lua script for optimistic removal with recovery.
+ *
+ * <p>
+ * Implements compare-and-swap by comparing the current serialized
exchange in the active map with the expected
+ * serialized holder. If they match, the script writes the holder to the
recovery map and removes it from the active
+ * map atomically.
+ *
+ * <p>
+ * Returns 1 on success and 0 if the active exchange does not match the
expected holder.
+ *
+ * <p>
+ * The comparison uses serialized bytes. Therefore, the configured
Redisson codec must produce identical serialized
+ * bytes for the same holder when storing and comparing it.
+ */
Review Comment:
💡 **Missing ordering rationale in Javadoc** (requested by @davsclaus)
The comment covers _what_ the script does and the codec requirement, but not
_why_ the `HSET` must come before the `HDEL`. Add a paragraph explaining the
ordering guarantee:
```suggestion
* The comparison uses serialized bytes. Therefore, the configured
Redisson codec must produce identical serialized
* bytes for the same holder when storing and comparing it.
*
* <p>
* The {@code HSET} into the recovery map is intentionally placed before
the {@code HDEL} from the active map.
* Redis does not roll back a Lua script on error; a failed {@code HSET}
aborts the script before the {@code HDEL}
* runs, leaving the exchange in the active map. This ordering ensures
that a storage failure never results in
* exchange loss.
*/
--
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]