diff --git a/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 717af7e57..6c34f8209 100644 --- a/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -15,27 +15,6 @@ */ package org.redisson.spring.data.connection; -import static org.redisson.client.protocol.RedisCommands.LRANGE; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.BiConsumer; - import org.redisson.Redisson; import org.redisson.SlotCallback; import org.redisson.api.BatchOptions; @@ -45,25 +24,14 @@ import org.redisson.api.RFuture; import org.redisson.api.RedissonClient; import org.redisson.client.RedisClient; import org.redisson.client.RedisException; -import org.redisson.client.codec.ByteArrayCodec; -import org.redisson.client.codec.Codec; -import org.redisson.client.codec.DoubleCodec; -import org.redisson.client.codec.LongCodec; -import org.redisson.client.codec.StringCodec; +import org.redisson.client.codec.*; import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.RedisStrictCommand; import org.redisson.client.protocol.convertor.BooleanReplayConvertor; import org.redisson.client.protocol.convertor.DoubleReplayConvertor; import org.redisson.client.protocol.convertor.VoidReplayConvertor; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.ListScanResult; -import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder; -import org.redisson.client.protocol.decoder.LongMultiDecoder; -import org.redisson.client.protocol.decoder.MapScanResult; -import org.redisson.client.protocol.decoder.ObjectListReplayDecoder; -import org.redisson.client.protocol.decoder.ObjectSetReplayDecoder; -import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; +import org.redisson.client.protocol.decoder.*; import org.redisson.command.CommandAsyncService; import org.redisson.command.CommandBatchService; import org.redisson.connection.MasterSlaveEntry; @@ -72,23 +40,23 @@ import org.redisson.misc.RedissonPromise; import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.redis.RedisSystemException; -import org.springframework.data.redis.connection.AbstractRedisConnection; -import org.springframework.data.redis.connection.DataType; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.data.redis.connection.RedisPipelineException; -import org.springframework.data.redis.connection.RedisSubscribedConnectionException; -import org.springframework.data.redis.connection.ReturnType; -import org.springframework.data.redis.connection.SortParameters; -import org.springframework.data.redis.connection.Subscription; -import org.springframework.data.redis.core.Cursor; -import org.springframework.data.redis.core.KeyBoundCursor; -import org.springframework.data.redis.core.ScanCursor; -import org.springframework.data.redis.core.ScanIteration; -import org.springframework.data.redis.core.ScanOptions; +import org.springframework.data.redis.connection.*; +import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.types.RedisClientInfo; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.math.BigDecimal; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiConsumer; + +import static org.redisson.client.protocol.RedisCommands.LRANGE; + /** * Redisson connection * @@ -1272,7 +1240,7 @@ public class RedissonConnection extends AbstractRedisConnection { return write(destKey, StringCodec.INSTANCE, ZINTERSTORE, args.toArray()); } - private static final RedisCommand> ZSCAN = new RedisCommand>("ZSCAN", new ListMultiDecoder(new LongMultiDecoder(), new ScoredSortedListReplayDecoder(), new ListScanResultReplayDecoder())); + private static final RedisCommand> ZSCAN = new RedisCommand<>("ZSCAN", new ListMultiDecoder2(new ListScanResultReplayDecoder(), new ScoredSortedListReplayDecoder())); @Override public Cursor zScan(byte[] key, ScanOptions options) { diff --git a/redisson-spring-data/redisson-spring-data-17/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-17/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index b8c7268b1..7d48b7b90 100644 --- a/redisson-spring-data/redisson-spring-data-17/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-17/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -56,14 +56,7 @@ import org.redisson.client.protocol.RedisStrictCommand; import org.redisson.client.protocol.convertor.BooleanReplayConvertor; import org.redisson.client.protocol.convertor.DoubleReplayConvertor; import org.redisson.client.protocol.convertor.VoidReplayConvertor; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.ListScanResult; -import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder; -import org.redisson.client.protocol.decoder.LongMultiDecoder; -import org.redisson.client.protocol.decoder.MapScanResult; -import org.redisson.client.protocol.decoder.ObjectListReplayDecoder; -import org.redisson.client.protocol.decoder.ObjectSetReplayDecoder; -import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; +import org.redisson.client.protocol.decoder.*; import org.redisson.command.CommandAsyncService; import org.redisson.command.CommandBatchService; import org.redisson.connection.MasterSlaveEntry; @@ -1304,7 +1297,7 @@ public class RedissonConnection extends AbstractRedisConnection { return write(destKey, StringCodec.INSTANCE, ZINTERSTORE, args.toArray()); } - private static final RedisCommand> ZSCAN = new RedisCommand>("ZSCAN", new ListMultiDecoder(new LongMultiDecoder(), new ScoredSortedListReplayDecoder(), new ListScanResultReplayDecoder())); + private static final RedisCommand> ZSCAN = new RedisCommand<>("ZSCAN", new ListMultiDecoder2(new ListScanResultReplayDecoder(), new ScoredSortedListReplayDecoder())); @Override public Cursor zScan(byte[] key, ScanOptions options) { diff --git a/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java b/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java index 9f49b22b8..d8c729249 100644 --- a/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java +++ b/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java @@ -15,20 +15,15 @@ */ package org.redisson.spring.data.connection; -import java.util.ArrayList; -import java.util.List; - import org.redisson.client.handler.State; import org.redisson.client.protocol.Decoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; import org.redisson.client.protocol.decoder.MultiDecoder; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; +import java.util.ArrayList; +import java.util.List; + /** * * @author Nikita Koksharov @@ -49,7 +44,7 @@ public class GeoResultsDecoder implements MultiDecoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; + return null; } @Override diff --git a/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java b/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java deleted file mode 100644 index aaddd80be..000000000 --- a/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.spring.data.connection; - -import java.util.ArrayList; -import java.util.List; - -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.MultiDecoder; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Point; -import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; - -/** - * - * @author Nikita Koksharov - * - */ -public class GeoResultsDistanceDecoder implements MultiDecoder>> { - - @Override - public Decoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; - } - - @Override - public GeoResults> decode(List parts, State state) { - List>> result = new ArrayList>>(); - for (Object object : parts) { - List vals = ((List) object); - - GeoLocation location = new GeoLocation((byte[])vals.get(0), (Point)vals.get(1)); - result.add(new GeoResult>(location, null)); - } - return new GeoResults>(result); - } - -} diff --git a/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index a7622bbab..98347aabe 100644 --- a/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -57,17 +57,7 @@ import org.redisson.client.protocol.RedisStrictCommand; import org.redisson.client.protocol.convertor.BooleanReplayConvertor; import org.redisson.client.protocol.convertor.DoubleReplayConvertor; import org.redisson.client.protocol.convertor.VoidReplayConvertor; -import org.redisson.client.protocol.decoder.CodecDecoder; -import org.redisson.client.protocol.decoder.GeoDistanceDecoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.ListScanResult; -import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder; -import org.redisson.client.protocol.decoder.LongMultiDecoder; -import org.redisson.client.protocol.decoder.MapScanResult; -import org.redisson.client.protocol.decoder.MultiDecoder; -import org.redisson.client.protocol.decoder.ObjectListReplayDecoder; -import org.redisson.client.protocol.decoder.ObjectSetReplayDecoder; -import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; +import org.redisson.client.protocol.decoder.*; import org.redisson.command.CommandAsyncService; import org.redisson.command.CommandBatchService; import org.redisson.connection.MasterSlaveEntry; @@ -1323,7 +1313,7 @@ public class RedissonConnection extends AbstractRedisConnection { return write(destKey, StringCodec.INSTANCE, ZINTERSTORE, args.toArray()); } - private static final RedisCommand> ZSCAN = new RedisCommand>("ZSCAN", new ListMultiDecoder(new LongMultiDecoder(), new ScoredSortedListReplayDecoder(), new ListScanResultReplayDecoder())); + private static final RedisCommand> ZSCAN = new RedisCommand<>("ZSCAN", new ListMultiDecoder2(new ListScanResultReplayDecoder(), new ScoredSortedListReplayDecoder())); @Override public Cursor zScan(byte[] key, ScanOptions options) { @@ -2041,7 +2031,7 @@ public class RedissonConnection extends AbstractRedisConnection { params.add(key); params.addAll(Arrays.asList(members)); - MultiDecoder> decoder = new ListMultiDecoder(new PointDecoder(), new ObjectListReplayDecoder2(ListMultiDecoder.RESET)); + MultiDecoder> decoder = new ListMultiDecoder2(new ObjectListReplayDecoder2(), new PointDecoder()); RedisCommand> command = new RedisCommand>("GEOPOS", decoder); return read(key, StringCodec.INSTANCE, command, params.toArray()); } @@ -2050,8 +2040,8 @@ public class RedissonConnection extends AbstractRedisConnection { return BigDecimal.valueOf(longitude).toPlainString(); } - private final MultiDecoder>> postitionDecoder = new ListMultiDecoder(new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoResultsDecoder()); - + private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); + @Override public GeoResults> geoRadius(byte[] key, Circle within) { RedisCommand>> command = new RedisCommand>>("GEORADIUS", new GeoResultsDecoder()); @@ -2074,7 +2064,7 @@ public class RedissonConnection extends AbstractRedisConnection { command = new RedisCommand>>("GEORADIUS", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(within.getRadius().getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(within.getRadius().getMetric()), new GeoDistanceDecoder()); command = new RedisCommand>>("GEORADIUS", distanceDecoder); params.add("WITHDIST"); } @@ -2116,7 +2106,7 @@ public class RedissonConnection extends AbstractRedisConnection { command = new RedisCommand>>("GEORADIUSBYMEMBER", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(radius.getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(radius.getMetric()), new GeoDistanceDecoder()); command = new RedisCommand>>("GEORADIUSBYMEMBER", distanceDecoder); params.add("WITHDIST"); } diff --git a/redisson-spring-data/redisson-spring-data-18/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-18/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index ee2b0ce01..b507ba37c 100644 --- a/redisson-spring-data/redisson-spring-data-18/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-18/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -3,6 +3,10 @@ package org.redisson.spring.data.connection; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; +import org.springframework.data.geo.*; +import org.springframework.data.redis.connection.RedisGeoCommands; + +import java.util.List; public class RedissonConnectionTest extends BaseConnectionTest { @@ -16,7 +20,55 @@ public class RedissonConnectionTest extends BaseConnectionTest { connection.set("key".getBytes(), "value".getBytes()); assertThat(connection.get("key".getBytes())).isEqualTo("value".getBytes()); } - + + @Test + public void testGeoPos() { + connection.geoAdd("key1".getBytes(), new Point(13.361389, 38.115556), "value1".getBytes()); + connection.geoAdd("key1".getBytes(), new Point(15.087269, 37.502669), "value2".getBytes()); + + List s = connection.geoPos("key1".getBytes(), "value1".getBytes(), "value2".getBytes()); + assertThat(s).hasSize(2); + + List se = connection.geoPos("key2".getBytes(), "value1".getBytes(), "value2".getBytes()); + assertThat(se).isEmpty(); + } + + @Test + public void testRadius() { + connection.geoAdd("key1".getBytes(), new Point(13.361389, 38.115556), "value1".getBytes()); + connection.geoAdd("key1".getBytes(), new Point(15.087269, 37.502669), "value2".getBytes()); + + GeoResults> l = connection.geoRadius("key1".getBytes(), new Circle(new Point(15, 37), new Distance(200, RedisGeoCommands.DistanceUnit.KILOMETERS))); + assertThat(l.getContent()).hasSize(2); + assertThat(l.getContent().get(0).getContent().getName()).isEqualTo("value1".getBytes()); + assertThat(l.getContent().get(1).getContent().getName()).isEqualTo("value2".getBytes()); + } + + @Test + public void testRadiusWithCoords() { + connection.geoAdd("key1".getBytes(), new Point(13.361389, 38.115556), "value1".getBytes()); + connection.geoAdd("key1".getBytes(), new Point(15.087269, 37.502669), "value2".getBytes()); + + GeoResults> l = connection.geoRadius("key1".getBytes(), + new Circle(new Point(15, 37), new Distance(200, RedisGeoCommands.DistanceUnit.KILOMETERS)), + RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs().includeCoordinates()); + + assertThat(l.getContent()).hasSize(2); + assertThat(l.getContent().get(0).getContent().getName()).isEqualTo("value1".getBytes()); + assertThat(l.getContent().get(0).getContent().getPoint().toString()).isEqualTo(new Point(13.361389, 38.115556).toString()); + assertThat(l.getContent().get(1).getContent().getName()).isEqualTo("value2".getBytes()); + assertThat(l.getContent().get(1).getContent().getPoint().toString()).isEqualTo(new Point(15.087267, 37.502668).toString()); + + GeoResults> l2 = connection.geoRadius("key1".getBytes(), + new Circle(new Point(15, 37), new Distance(200, RedisGeoCommands.DistanceUnit.KILOMETERS)), + RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs()); + + assertThat(l2.getContent()).hasSize(2); + assertThat(l2.getContent().get(0).getContent().getName()).isEqualTo("value1".getBytes()); + assertThat(l2.getContent().get(1).getContent().getName()).isEqualTo("value2".getBytes()); + + } + @Test public void testHSetGet() { assertThat(connection.hSet("key".getBytes(), "field".getBytes(), "value".getBytes())).isTrue(); diff --git a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/ByteBufferGeoResultsDecoder.java b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/ByteBufferGeoResultsDecoder.java index a76a7f6a7..d59c34ebb 100644 --- a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/ByteBufferGeoResultsDecoder.java +++ b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/ByteBufferGeoResultsDecoder.java @@ -15,21 +15,16 @@ */ package org.redisson.spring.data.connection; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - import org.redisson.client.handler.State; import org.redisson.client.protocol.Decoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; import org.redisson.client.protocol.decoder.MultiDecoder; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + /** * * @author Nikita Koksharov @@ -50,7 +45,7 @@ public class ByteBufferGeoResultsDecoder implements MultiDecoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; + return null; } @Override diff --git a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java index 9f49b22b8..d8c729249 100644 --- a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java +++ b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java @@ -15,20 +15,15 @@ */ package org.redisson.spring.data.connection; -import java.util.ArrayList; -import java.util.List; - import org.redisson.client.handler.State; import org.redisson.client.protocol.Decoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; import org.redisson.client.protocol.decoder.MultiDecoder; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; +import java.util.ArrayList; +import java.util.List; + /** * * @author Nikita Koksharov @@ -49,7 +44,7 @@ public class GeoResultsDecoder implements MultiDecoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; + return null; } @Override diff --git a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java deleted file mode 100644 index aaddd80be..000000000 --- a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.spring.data.connection; - -import java.util.ArrayList; -import java.util.List; - -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.MultiDecoder; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Point; -import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; - -/** - * - * @author Nikita Koksharov - * - */ -public class GeoResultsDistanceDecoder implements MultiDecoder>> { - - @Override - public Decoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; - } - - @Override - public GeoResults> decode(List parts, State state) { - List>> result = new ArrayList>>(); - for (Object object : parts) { - List vals = ((List) object); - - GeoLocation location = new GeoLocation((byte[])vals.get(0), (Point)vals.get(1)); - result.add(new GeoResult>(location, null)); - } - return new GeoResults>(result); - } - -} diff --git a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 8120222d6..991db16e9 100644 --- a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -15,28 +15,6 @@ */ package org.redisson.spring.data.connection; -import static org.redisson.client.protocol.RedisCommands.LRANGE; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.BiConsumer; - import org.redisson.Redisson; import org.redisson.SlotCallback; import org.redisson.api.BatchOptions; @@ -46,28 +24,14 @@ import org.redisson.api.RFuture; import org.redisson.api.RedissonClient; import org.redisson.client.RedisClient; import org.redisson.client.RedisException; -import org.redisson.client.codec.ByteArrayCodec; -import org.redisson.client.codec.Codec; -import org.redisson.client.codec.DoubleCodec; -import org.redisson.client.codec.LongCodec; -import org.redisson.client.codec.StringCodec; +import org.redisson.client.codec.*; import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.RedisStrictCommand; import org.redisson.client.protocol.convertor.BooleanReplayConvertor; import org.redisson.client.protocol.convertor.DoubleReplayConvertor; import org.redisson.client.protocol.convertor.VoidReplayConvertor; -import org.redisson.client.protocol.decoder.CodecDecoder; -import org.redisson.client.protocol.decoder.GeoDistanceDecoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.ListScanResult; -import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder; -import org.redisson.client.protocol.decoder.LongMultiDecoder; -import org.redisson.client.protocol.decoder.MapScanResult; -import org.redisson.client.protocol.decoder.MultiDecoder; -import org.redisson.client.protocol.decoder.ObjectListReplayDecoder; -import org.redisson.client.protocol.decoder.ObjectSetReplayDecoder; -import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; +import org.redisson.client.protocol.decoder.*; import org.redisson.command.CommandAsyncService; import org.redisson.command.CommandBatchService; import org.redisson.connection.MasterSlaveEntry; @@ -75,31 +39,27 @@ import org.redisson.misc.RPromise; import org.redisson.misc.RedissonPromise; import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.geo.Circle; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.RedisSystemException; -import org.springframework.data.redis.connection.AbstractRedisConnection; -import org.springframework.data.redis.connection.DataType; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.data.redis.connection.RedisNode; -import org.springframework.data.redis.connection.RedisPipelineException; -import org.springframework.data.redis.connection.RedisSubscribedConnectionException; -import org.springframework.data.redis.connection.ReturnType; -import org.springframework.data.redis.connection.SortParameters; -import org.springframework.data.redis.connection.Subscription; -import org.springframework.data.redis.core.Cursor; -import org.springframework.data.redis.core.KeyBoundCursor; -import org.springframework.data.redis.core.ScanCursor; -import org.springframework.data.redis.core.ScanIteration; -import org.springframework.data.redis.core.ScanOptions; +import org.springframework.data.redis.connection.*; +import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.types.Expiration; import org.springframework.data.redis.core.types.RedisClientInfo; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.math.BigDecimal; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiConsumer; + +import static org.redisson.client.protocol.RedisCommands.LRANGE; + /** * Redisson connection * @@ -1336,7 +1296,7 @@ public class RedissonConnection extends AbstractRedisConnection { return write(destKey, StringCodec.INSTANCE, ZINTERSTORE, args.toArray()); } - private static final RedisCommand> ZSCAN = new RedisCommand>("ZSCAN", new ListMultiDecoder(new LongMultiDecoder(), new ScoredSortedListReplayDecoder(), new ListScanResultReplayDecoder())); + private static final RedisCommand> ZSCAN = new RedisCommand<>("ZSCAN", new ListMultiDecoder2(new ListScanResultReplayDecoder(), new ScoredSortedListReplayDecoder())); @Override public Cursor zScan(byte[] key, ScanOptions options) { @@ -2050,7 +2010,7 @@ public class RedissonConnection extends AbstractRedisConnection { return read(key, StringCodec.INSTANCE, GEOHASH, params.toArray()); } - private final MultiDecoder> geoDecoder = new ListMultiDecoder(new PointDecoder(), new ObjectListReplayDecoder2(ListMultiDecoder.RESET)); + private final MultiDecoder> geoDecoder = new ListMultiDecoder2(new ObjectListReplayDecoder2(), new PointDecoder()); @Override public List geoPos(byte[] key, byte[]... members) { @@ -2066,7 +2026,7 @@ public class RedissonConnection extends AbstractRedisConnection { return BigDecimal.valueOf(longitude).toPlainString(); } - private final MultiDecoder>> postitionDecoder = new ListMultiDecoder(new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoResultsDecoder()); + private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); @Override public GeoResults> geoRadius(byte[] key, Circle within) { @@ -2090,7 +2050,7 @@ public class RedissonConnection extends AbstractRedisConnection { command = new RedisCommand>>("GEORADIUS", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(within.getRadius().getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(within.getRadius().getMetric()), new GeoDistanceDecoder()); command = new RedisCommand>>("GEORADIUS", distanceDecoder); params.add("WITHDIST"); } @@ -2132,7 +2092,7 @@ public class RedissonConnection extends AbstractRedisConnection { command = new RedisCommand>>("GEORADIUSBYMEMBER", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(radius.getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(radius.getMetric()), new GeoDistanceDecoder()); command = new RedisCommand>>("GEORADIUSBYMEMBER", distanceDecoder); params.add("WITHDIST"); } diff --git a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java index 6fa32bf30..f660488fb 100644 --- a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java +++ b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java @@ -15,30 +15,15 @@ */ package org.redisson.spring.data.connection; -import java.math.BigDecimal; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import org.reactivestreams.Publisher; import org.redisson.client.codec.ByteArrayCodec; import org.redisson.client.codec.DoubleCodec; import org.redisson.client.codec.StringCodec; import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommands; -import org.redisson.client.protocol.decoder.CodecDecoder; -import org.redisson.client.protocol.decoder.GeoDistanceDecoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.MultiDecoder; -import org.redisson.client.protocol.decoder.ObjectListReplayDecoder; +import org.redisson.client.protocol.decoder.*; import org.redisson.reactive.CommandReactiveExecutor; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.connection.ReactiveGeoCommands; import org.springframework.data.redis.connection.ReactiveRedisConnection.CommandResponse; import org.springframework.data.redis.connection.ReactiveRedisConnection.MultiValueResponse; @@ -47,10 +32,16 @@ import org.springframework.data.redis.connection.RedisGeoCommands; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs; import org.springframework.util.Assert; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import java.math.BigDecimal; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + /** * * @author Nikita Koksharov @@ -126,7 +117,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements }); } - private final MultiDecoder> geoDecoder = new ListMultiDecoder(new PointDecoder(), new ObjectListReplayDecoder2(ListMultiDecoder.RESET)); + private final MultiDecoder> geoDecoder = new ListMultiDecoder2(new ObjectListReplayDecoder2(), new PointDecoder()); @Override public Flux> geoPos(Publisher commands) { @@ -147,7 +138,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements }); } - private final MultiDecoder>> postitionDecoder = new ListMultiDecoder(new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoResultsDecoder()); + private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); @Override public Flux>>>> geoRadius( @@ -173,7 +164,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements cmd = new RedisCommand>>("GEORADIUS", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new ByteBufferGeoResultsDecoder(command.getDistance().getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); cmd = new RedisCommand>>("GEORADIUS", distanceDecoder); params.add("WITHDIST"); } @@ -215,7 +206,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements cmd = new RedisCommand>>("GEORADIUSBYMEMBER", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new ByteBufferGeoResultsDecoder(command.getDistance().getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); cmd = new RedisCommand>>("GEORADIUSBYMEMBER", distanceDecoder); params.add("WITHDIST"); } diff --git a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/ByteBufferGeoResultsDecoder.java b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/ByteBufferGeoResultsDecoder.java index a76a7f6a7..d59c34ebb 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/ByteBufferGeoResultsDecoder.java +++ b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/ByteBufferGeoResultsDecoder.java @@ -15,21 +15,16 @@ */ package org.redisson.spring.data.connection; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - import org.redisson.client.handler.State; import org.redisson.client.protocol.Decoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; import org.redisson.client.protocol.decoder.MultiDecoder; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + /** * * @author Nikita Koksharov @@ -50,7 +45,7 @@ public class ByteBufferGeoResultsDecoder implements MultiDecoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; + return null; } @Override diff --git a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java index 9f49b22b8..d8c729249 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java +++ b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/GeoResultsDecoder.java @@ -15,20 +15,15 @@ */ package org.redisson.spring.data.connection; -import java.util.ArrayList; -import java.util.List; - import org.redisson.client.handler.State; import org.redisson.client.protocol.Decoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; import org.redisson.client.protocol.decoder.MultiDecoder; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; +import java.util.ArrayList; +import java.util.List; + /** * * @author Nikita Koksharov @@ -49,7 +44,7 @@ public class GeoResultsDecoder implements MultiDecoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; + return null; } @Override diff --git a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java deleted file mode 100644 index aaddd80be..000000000 --- a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/GeoResultsDistanceDecoder.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.spring.data.connection; - -import java.util.ArrayList; -import java.util.List; - -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.MultiDecoder; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Point; -import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; - -/** - * - * @author Nikita Koksharov - * - */ -public class GeoResultsDistanceDecoder implements MultiDecoder>> { - - @Override - public Decoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; - } - - @Override - public GeoResults> decode(List parts, State state) { - List>> result = new ArrayList>>(); - for (Object object : parts) { - List vals = ((List) object); - - GeoLocation location = new GeoLocation((byte[])vals.get(0), (Point)vals.get(1)); - result.add(new GeoResult>(location, null)); - } - return new GeoResults>(result); - } - -} diff --git a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index c7ef6914a..168d113e1 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -57,17 +57,7 @@ import org.redisson.client.protocol.RedisStrictCommand; import org.redisson.client.protocol.convertor.BooleanReplayConvertor; import org.redisson.client.protocol.convertor.DoubleReplayConvertor; import org.redisson.client.protocol.convertor.VoidReplayConvertor; -import org.redisson.client.protocol.decoder.CodecDecoder; -import org.redisson.client.protocol.decoder.GeoDistanceDecoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.ListScanResult; -import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder; -import org.redisson.client.protocol.decoder.LongMultiDecoder; -import org.redisson.client.protocol.decoder.MapScanResult; -import org.redisson.client.protocol.decoder.MultiDecoder; -import org.redisson.client.protocol.decoder.ObjectListReplayDecoder; -import org.redisson.client.protocol.decoder.ObjectSetReplayDecoder; -import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; +import org.redisson.client.protocol.decoder.*; import org.redisson.command.CommandAsyncService; import org.redisson.command.CommandBatchService; import org.redisson.connection.MasterSlaveEntry; @@ -1336,8 +1326,8 @@ public class RedissonConnection extends AbstractRedisConnection { return write(destKey, StringCodec.INSTANCE, ZINTERSTORE, args.toArray()); } - private static final RedisCommand> ZSCAN = new RedisCommand>("ZSCAN", new ListMultiDecoder(new LongMultiDecoder(), new ScoredSortedListReplayDecoder(), new ListScanResultReplayDecoder())); - + private static final RedisCommand> ZSCAN = new RedisCommand<>("ZSCAN", new ListMultiDecoder2(new ListScanResultReplayDecoder(), new ScoredSortedListReplayDecoder())); + @Override public Cursor zScan(byte[] key, ScanOptions options) { return new KeyBoundCursor(key, 0, options) { @@ -2050,7 +2040,7 @@ public class RedissonConnection extends AbstractRedisConnection { return read(key, StringCodec.INSTANCE, GEOHASH, params.toArray()); } - private final MultiDecoder> geoDecoder = new ListMultiDecoder(new PointDecoder(), new ObjectListReplayDecoder2(ListMultiDecoder.RESET)); + private final MultiDecoder> geoDecoder = new ListMultiDecoder2(new ObjectListReplayDecoder2(), new PointDecoder()); @Override public List geoPos(byte[] key, byte[]... members) { @@ -2066,7 +2056,7 @@ public class RedissonConnection extends AbstractRedisConnection { return BigDecimal.valueOf(longitude).toPlainString(); } - private final MultiDecoder>> postitionDecoder = new ListMultiDecoder(new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoResultsDecoder()); + private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); @Override public GeoResults> geoRadius(byte[] key, Circle within) { @@ -2090,7 +2080,7 @@ public class RedissonConnection extends AbstractRedisConnection { command = new RedisCommand>>("GEORADIUS", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(within.getRadius().getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(within.getRadius().getMetric()), new GeoDistanceDecoder()); command = new RedisCommand>>("GEORADIUS", distanceDecoder); params.add("WITHDIST"); } @@ -2132,7 +2122,7 @@ public class RedissonConnection extends AbstractRedisConnection { command = new RedisCommand>>("GEORADIUSBYMEMBER", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoResultsDecoder(radius.getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new GeoResultsDecoder(radius.getMetric()), new GeoDistanceDecoder()); command = new RedisCommand>>("GEORADIUSBYMEMBER", distanceDecoder); params.add("WITHDIST"); } diff --git a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java index 6fa32bf30..f660488fb 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java +++ b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveGeoCommands.java @@ -15,30 +15,15 @@ */ package org.redisson.spring.data.connection; -import java.math.BigDecimal; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import org.reactivestreams.Publisher; import org.redisson.client.codec.ByteArrayCodec; import org.redisson.client.codec.DoubleCodec; import org.redisson.client.codec.StringCodec; import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommands; -import org.redisson.client.protocol.decoder.CodecDecoder; -import org.redisson.client.protocol.decoder.GeoDistanceDecoder; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.MultiDecoder; -import org.redisson.client.protocol.decoder.ObjectListReplayDecoder; +import org.redisson.client.protocol.decoder.*; import org.redisson.reactive.CommandReactiveExecutor; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.GeoResults; -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.connection.ReactiveGeoCommands; import org.springframework.data.redis.connection.ReactiveRedisConnection.CommandResponse; import org.springframework.data.redis.connection.ReactiveRedisConnection.MultiValueResponse; @@ -47,10 +32,16 @@ import org.springframework.data.redis.connection.RedisGeoCommands; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs; import org.springframework.util.Assert; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import java.math.BigDecimal; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + /** * * @author Nikita Koksharov @@ -126,7 +117,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements }); } - private final MultiDecoder> geoDecoder = new ListMultiDecoder(new PointDecoder(), new ObjectListReplayDecoder2(ListMultiDecoder.RESET)); + private final MultiDecoder> geoDecoder = new ListMultiDecoder2(new ObjectListReplayDecoder2(), new PointDecoder()); @Override public Flux> geoPos(Publisher commands) { @@ -147,7 +138,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements }); } - private final MultiDecoder>> postitionDecoder = new ListMultiDecoder(new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoResultsDecoder()); + private final MultiDecoder>> postitionDecoder = new ListMultiDecoder2(new GeoResultsDecoder(), new CodecDecoder(), new PointDecoder(), new ObjectListReplayDecoder()); @Override public Flux>>>> geoRadius( @@ -173,7 +164,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements cmd = new RedisCommand>>("GEORADIUS", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new ByteBufferGeoResultsDecoder(command.getDistance().getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); cmd = new RedisCommand>>("GEORADIUS", distanceDecoder); params.add("WITHDIST"); } @@ -215,7 +206,7 @@ public class RedissonReactiveGeoCommands extends RedissonBaseReactive implements cmd = new RedisCommand>>("GEORADIUSBYMEMBER", postitionDecoder); params.add("WITHCOORD"); } else { - MultiDecoder>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new ByteBufferGeoResultsDecoder(command.getDistance().getMetric())); + MultiDecoder>> distanceDecoder = new ListMultiDecoder2(new ByteBufferGeoResultsDecoder(command.getDistance().getMetric()), new GeoDistanceDecoder()); cmd = new RedisCommand>>("GEORADIUSBYMEMBER", distanceDecoder); params.add("WITHDIST"); } diff --git a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveZSetCommands.java b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveZSetCommands.java index f8c74d591..ed3fa990e 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveZSetCommands.java +++ b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveZSetCommands.java @@ -34,11 +34,7 @@ import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.RedisStrictCommand; import org.redisson.client.protocol.convertor.DoubleNullSafeReplayConvertor; -import org.redisson.client.protocol.decoder.ListMultiDecoder; -import org.redisson.client.protocol.decoder.ListScanResult; -import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder; -import org.redisson.client.protocol.decoder.LongMultiDecoder; -import org.redisson.client.protocol.decoder.ObjectSetReplayDecoder; +import org.redisson.client.protocol.decoder.*; import org.redisson.reactive.CommandReactiveExecutor; import org.redisson.reactive.SetReactiveIterator; import org.springframework.data.domain.Range; @@ -258,8 +254,7 @@ public class RedissonReactiveZSetCommands extends RedissonBaseReactive implement }); } - private static final RedisCommand> ZSCAN = new RedisCommand>("ZSCAN", - new ListMultiDecoder(new LongMultiDecoder(), new ScoredSortedListReplayDecoder(), new ListScanResultReplayDecoder())); + private static final RedisCommand> ZSCAN = new RedisCommand<>("ZSCAN", new ListMultiDecoder2(new ScoredSortedSetScanDecoder(), new ScoredSortedSetScanReplayDecoder())); @Override public Flux>> zScan(Publisher commands) { diff --git a/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index cb2e811fa..4f9a4e3a8 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -4,6 +4,9 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.springframework.data.redis.connection.RedisStringCommands.SetOption; +import org.springframework.data.redis.connection.RedisZSetCommands; +import org.springframework.data.redis.core.Cursor; +import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; public class RedissonConnectionTest extends BaseConnectionTest { @@ -30,5 +33,18 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(connection.hSet("key".getBytes(), "field".getBytes(), "value".getBytes())).isTrue(); assertThat(connection.hGet("key".getBytes(), "field".getBytes())).isEqualTo("value".getBytes()); } + + @Test + public void testZScan() { + connection.zAdd("key".getBytes(), 1, "value1".getBytes()); + connection.zAdd("key".getBytes(), 2, "value2".getBytes()); + + Cursor t = connection.zScan("key".getBytes(), ScanOptions.scanOptions().build()); + assertThat(t.hasNext()).isTrue(); + assertThat(t.next().getValue()).isEqualTo("value1".getBytes()); + assertThat(t.hasNext()).isTrue(); + assertThat(t.next().getValue()).isEqualTo("value2".getBytes()); + } + } diff --git a/redisson/src/main/java/org/redisson/client/handler/State.java b/redisson/src/main/java/org/redisson/client/handler/State.java index 9aa5f4629..b74fa6424 100644 --- a/redisson/src/main/java/org/redisson/client/handler/State.java +++ b/redisson/src/main/java/org/redisson/client/handler/State.java @@ -15,8 +15,6 @@ */ package org.redisson.client.handler; -import org.redisson.client.protocol.decoder.DecoderState; - /** * * @author Nikita Koksharov @@ -25,7 +23,6 @@ import org.redisson.client.protocol.decoder.DecoderState; public class State { private int batchIndex; - private DecoderState decoderState; private int level = -1; @@ -51,20 +48,9 @@ public class State { return batchIndex; } - @Deprecated - public T getDecoderState() { - return (T) decoderState; - } - @Deprecated - public void setDecoderState(DecoderState decoderState) { - this.decoderState = decoderState; - } - @Override public String toString() { - return "State [batchIndex=" + batchIndex + ", decoderState=" + decoderState + ", level=" + level + "]"; + return "State [batchIndex=" + batchIndex + ", level=" + level + "]"; } - - } diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/DecoderState.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/DecoderState.java deleted file mode 100644 index 3a6624cdb..000000000 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/DecoderState.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.client.protocol.decoder; - -/** - * - * @author Nikita Koksharov - * - */ -@Deprecated -public interface DecoderState { - - DecoderState copy(); - -} diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/GeoMapReplayDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/GeoMapReplayDecoder.java deleted file mode 100644 index d85c1f50a..000000000 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/GeoMapReplayDecoder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.client.protocol.decoder; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; - -/** - * - * @author Nikita Koksharov - * - */ -@Deprecated -public class GeoMapReplayDecoder implements MultiDecoder> { - - @Override - public Decoder getDecoder(int paramNum, State state) { - return ListMultiDecoder.RESET; - } - - @Override - public Map decode(List parts, State state) { - Map result = new LinkedHashMap(parts.size()); - for (Object object : parts) { - List vals = (List) object; - result.put(vals.get(0), vals.get(1)); - } - return result; - } - -} diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/ListMultiDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/ListMultiDecoder.java deleted file mode 100644 index cd9fbeb97..000000000 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/ListMultiDecoder.java +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.client.protocol.decoder; - -import java.io.IOException; -import java.util.List; - -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; - -import io.netty.buffer.ByteBuf; - -/** - * - * @author Nikita Koksharov - * - * @param type - */ -@Deprecated -public class ListMultiDecoder implements MultiDecoder { - - public static final Decoder RESET = new Decoder() { - @Override - public Object decode(ByteBuf buf, State state) throws IOException { - return null; - } - }; - - public static final Decoder RESET_1 = new Decoder() { - @Override - public Object decode(ByteBuf buf, State state) throws IOException { - return null; - } - }; - - public static final Decoder RESET_INDEX = new Decoder() { - @Override - public Object decode(ByteBuf buf, State state) throws IOException { - return null; - } - }; - - private final MultiDecoder[] decoders; - - public static class NestedDecoderState implements DecoderState { - - int index = -1; - int partsIndex = -1; - - public NestedDecoderState() { - } - - public NestedDecoderState(int index) { - super(); - this.index = index; - } - - public void setIndex(int index) { - this.index = index; - } - - public void resetPartsIndex() { - partsIndex = -1; - } - - public int incPartsIndex() { - return ++partsIndex; - } - - public int getPartsIndex() { - return partsIndex; - } - - public int incIndex() { - return ++index; - } - - public int getIndex() { - return index; - } - - @Override - public DecoderState copy() { - return new NestedDecoderState(index); - } - - @Override - public String toString() { - return "NestedDecoderState [index=" + index + "]"; - } - - } - - protected final NestedDecoderState getDecoder(State state) { - NestedDecoderState ds = state.getDecoderState(); - if (ds == null) { - ds = new NestedDecoderState(); - state.setDecoderState(ds); - } - return ds; - } - - public ListMultiDecoder(MultiDecoder... decoders) { - this.decoders = decoders; - } - - private Integer fixedIndex; - - public ListMultiDecoder(Integer fixedIndex, MultiDecoder... decoders) { - this.fixedIndex = fixedIndex; - this.decoders = decoders; - } - - @Override - public Decoder getDecoder(int paramNum, State state) { - if (paramNum == 0) { - NestedDecoderState s = getDecoder(state); - if (fixedIndex != null) { - s.setIndex(fixedIndex); - } else { - s.incIndex(); - } - s.resetPartsIndex(); - } - - int index = getDecoder(state).getIndex(); - if (index == -1) { - getDecoder(state).setIndex(0); - index = 0; - } - - Decoder decoder = decoders[index].getDecoder(paramNum, state); - if (decoder == RESET) { - NestedDecoderState s = getDecoder(state); - s.setIndex(0); - int ind = s.getIndex(); - return decoders[ind].getDecoder(paramNum, state); - } - if (decoder == RESET_1) { - NestedDecoderState s = getDecoder(state); - s.setIndex(1); - int ind = s.getIndex(); - return decoders[ind].getDecoder(paramNum, state); - } - return decoder; - } - - @Override - public Object decode(List parts, State state) { - NestedDecoderState s = getDecoder(state); - int index = s.getIndex(); - index += s.incPartsIndex(); - - if (fixedIndex != null && parts.isEmpty()) { - s.resetPartsIndex(); - } - - if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { - return decoders[decoders.length-1].decode(parts, state); - } - - Object res = decoders[index].decode(parts, state); - if (res == null) { - index = s.incIndex() + s.getPartsIndex(); - return decoders[index].decode(parts, state); - } - - // TODO refactor it! - Decoder decoder = decoders[index].getDecoder(0, state); - if (decoder == RESET_INDEX) { - s.setIndex(-1); - } - - return res; - } - -} diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/Long2MultiDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/Long2MultiDecoder.java index dd8ca6ca2..ce12adf3d 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/Long2MultiDecoder.java +++ b/redisson/src/main/java/org/redisson/client/protocol/decoder/Long2MultiDecoder.java @@ -17,14 +17,21 @@ package org.redisson.client.protocol.decoder; import java.util.List; +import org.redisson.client.codec.LongCodec; import org.redisson.client.handler.State; +import org.redisson.client.protocol.Decoder; /** * * @author Nikita Koksharov * */ -public class Long2MultiDecoder extends LongMultiDecoder { +public class Long2MultiDecoder implements MultiDecoder { + + @Override + public Decoder getDecoder(int paramNum, State state) { + return LongCodec.INSTANCE.getValueDecoder(); + } @Override public Object decode(List parts, State state) { diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/LongMultiDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/LongMultiDecoder.java deleted file mode 100644 index 3b9d6c81d..000000000 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/LongMultiDecoder.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.client.protocol.decoder; - -import java.util.List; - -import org.redisson.client.codec.LongCodec; -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; - -/** - * - * @author Nikita Koksharov - * - */ -@Deprecated -public class LongMultiDecoder implements MultiDecoder { - - @Override - public Decoder getDecoder(int paramNum, State state) { - return LongCodec.INSTANCE.getValueDecoder(); - } - - @Override - public Object decode(List parts, State state) { - return null; - } - -} diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/ObjectListDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/ObjectListDecoder.java deleted file mode 100644 index 15f11e1ab..000000000 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/ObjectListDecoder.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.client.protocol.decoder; - -import java.util.List; - -import org.redisson.client.codec.Codec; -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; - -/** - * - * @author Nikita Koksharov - * - * @param type - */ -@Deprecated -public class ObjectListDecoder implements MultiDecoder> { - - private Codec codec; - - public ObjectListDecoder(Codec codec) { - super(); - this.codec = codec; - } - - @Override - public Decoder getDecoder(int paramNum, State state) { - return codec.getMapKeyDecoder(); - } - - @SuppressWarnings("unchecked") - @Override - public List decode(List parts, State state) { - return (List) parts; - } - -} diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/ObjectMapJoinDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/ObjectMapJoinDecoder.java deleted file mode 100644 index c18d7da6e..000000000 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/ObjectMapJoinDecoder.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.client.protocol.decoder; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; - -/** - * - * @author Nikita Koksharov - * - */ -@Deprecated -public class ObjectMapJoinDecoder implements MultiDecoder> { - - @Override - public Map decode(List parts, State state) { - Map result = new LinkedHashMap(parts.size()); - for (int i = 0; i < parts.size(); i++) { - result.putAll((Map) parts.get(i)); - } - return result; - } - - @Override - public Decoder getDecoder(int paramNum, State state) { - return null; - } - -} diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/StreamInfoMapDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/StreamInfoMapDecoder.java deleted file mode 100644 index 30e87a8be..000000000 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/StreamInfoMapDecoder.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2013-2019 Nikita Koksharov - * - * 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 - * - * http://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.redisson.client.protocol.decoder; - -import java.util.List; - -import org.redisson.client.codec.Codec; -import org.redisson.client.handler.State; -import org.redisson.client.protocol.Decoder; - -/** - * - * @author Nikita Koksharov - * - */ -@Deprecated -public class StreamInfoMapDecoder implements MultiDecoder { - - boolean hasNonZeroLevel = false; - final StreamInfoDecoder streamInfo = new StreamInfoDecoder(); - final ObjectMapDecoder decoder; - - public StreamInfoMapDecoder(Codec codec) { - decoder = new ObjectMapDecoder(codec, false); - } - - @Override - public Decoder getDecoder(int paramNum, State state) { - if (state.getLevel() > 0) { - hasNonZeroLevel = true; - } - if (state.getLevel() == 2) { - return decoder.getDecoder(paramNum, state); - } - return null; - } - - @Override - public Object decode(List parts, State state) { - if (hasNonZeroLevel) { - return decoder.decode(parts, state); - } - return streamInfo.decode(parts, state); - } - -} diff --git a/redisson/src/main/java/org/redisson/codec/DefaultReferenceCodecProvider.java b/redisson/src/main/java/org/redisson/codec/DefaultReferenceCodecProvider.java index f6602036f..da25cf4ba 100644 --- a/redisson/src/main/java/org/redisson/codec/DefaultReferenceCodecProvider.java +++ b/redisson/src/main/java/org/redisson/codec/DefaultReferenceCodecProvider.java @@ -38,7 +38,7 @@ public class DefaultReferenceCodecProvider implements ReferenceCodecProvider { Codec codec = codecCache.get(codecClass); if (codec == null) { try { - codec = codecClass.newInstance(); + codec = codecClass.getDeclaredConstructor().newInstance(); codecCache.putIfAbsent(codecClass, codec); } catch (Exception ex) { throw new RuntimeException(ex);