Closed
Description
This issue refers to a comment in #2936
As we now can use XAddOptions in streamOperations,
XAddOptions options = XAddOptions.maxlen(-1);
redisTemplate.opsForStream("myStream", Map.of("key", "value"), options);
This executes without throwing an error or warning the client. Instead, the result is that the maxlen option is not applied.
IMO, this is because the XAddOptions hasMaxlen() method gets called before every time XAddOptions is used, and it checks maxlen > 0, which results in ignoring negative values for maxlen.
- Reproducible code
@ParameterizedRedisTest
void addMinusMaxlenDoesNotThrowsException() {
K key = keyFactory.instance();
HV value = hashValueFactory.instance();
XAddOptions options = XAddOptions.maxlen(-1).approximateTrimming(false);
assertDoesNotThrow(() -> redisTemplate.opsForStream().add(StreamRecords.objectBacked(value).withStreamKey(key), options));
assertThat(redisTemplate.opsForStream().range(key, Range.unbounded())).hasSize(1);
}