Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Negative maxlen for XAddOptions is ignored #2982

Closed
Assignees
Labels
@jinkshower

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);
}

image

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    AltStyle によって変換されたページ (->オリジナル) /