Fixed - an error should be thrown if merge(), compute(), computeIfAbsent() and computeIfPresent() of RMap used in batch #4229

pull/4239/head
Nikita Koksharov 3 years ago
parent 370afbf358
commit 45a312ea26

@ -28,10 +28,13 @@ import org.redisson.client.protocol.RedisCommands;
import org.redisson.client.protocol.convertor.NumberConvertor;
import org.redisson.client.protocol.decoder.MapValueDecoder;
import org.redisson.command.CommandAsyncExecutor;
import org.redisson.command.CommandBatchService;
import org.redisson.connection.decoder.MapGetAllDecoder;
import org.redisson.iterator.RedissonMapIterator;
import org.redisson.mapreduce.RedissonMapReduce;
import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.reactive.CommandReactiveBatchService;
import org.redisson.rx.CommandRxBatchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -139,6 +142,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkKey(key);
checkValue(value);
Objects.requireNonNull(remappingFunction);
@ -165,6 +174,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkKey(key);
checkValue(value);
Objects.requireNonNull(remappingFunction);
@ -208,6 +223,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkKey(key);
Objects.requireNonNull(remappingFunction);
@ -264,6 +285,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkKey(key);
Objects.requireNonNull(remappingFunction);
@ -288,6 +315,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkKey(key);
Objects.requireNonNull(mappingFunction);
@ -330,6 +363,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkKey(key);
Objects.requireNonNull(mappingFunction);
@ -353,6 +392,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkKey(key);
Objects.requireNonNull(remappingFunction);
@ -408,6 +453,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkKey(key);
Objects.requireNonNull(remappingFunction);

Loading…
Cancel
Save