DATAREDIS-1138 - Fix detection whether XREAD is blocking.

We now correctly check if a BLOCK option is configured using a timeout of zero or higher. Previously we only checked if the configured value is greater than zero and didn't consider that a timeout of zero blocks indefinitely.

Original Pull Request: #528
This commit is contained in:
Mark Paluch
2020-05-05 14:26:41 +02:00
committed by Christoph Strobl
parent def86fcf57
commit f4676edbd2
4 changed files with 49 additions and 6 deletions

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.connection.stream;
import static org.assertj.core.api.Assertions.*;
import java.time.Duration;
import org.junit.Test;
/**
* Unit tests for {@link StreamReadOptions}.
*
* @author Mark Paluch
*/
public class StreamReadOptionsUnitTests {
@Test // DATAREDIS-1138
public void shouldConsiderBlocking() {
assertThat(StreamReadOptions.empty().isBlocking()).isFalse();
assertThat(StreamReadOptions.empty().block(Duration.ofSeconds(1)).isBlocking()).isTrue();
assertThat(StreamReadOptions.empty().block(Duration.ZERO).isBlocking()).isTrue();
}
}