@@ -119,35 +119,41 @@ LettuceResult newLettuceResult(Future<?> resultHolder) {
119
119
return newLettuceResult (resultHolder , (val ) -> val );
120
120
}
121
121
122
- <T > LettuceResult newLettuceResult (Future <T > resultHolder , Converter <T , ?> converter ) {
122
+ @ SuppressWarnings ("unchecked" )
123
+ <T , R > LettuceResult <T , R > newLettuceResult (Future <T > resultHolder , Converter <T , ?> converter ) {
123
124
124
- return LettuceResultBuilder .forResponse (resultHolder ).mappedWith (converter )
125
+ return LettuceResultBuilder .forResponse (resultHolder ).mappedWith (( Converter ) converter )
125
126
.convertPipelineAndTxResults (convertPipelineAndTxResults ).build ();
126
127
}
127
128
128
- <T > LettuceResult newLettuceResult (Future <T > resultHolder , Converter <T , ?> converter , Supplier <?> defaultValue ) {
129
+ @ SuppressWarnings ("unchecked" )
130
+ <T , R > LettuceResult <T , R > newLettuceResult (Future <T > resultHolder , Converter <T , R > converter ,
131
+ Supplier <?> defaultValue ) {
129
132
130
- return LettuceResultBuilder .forResponse (resultHolder ).mappedWith (converter )
133
+ return LettuceResultBuilder .forResponse (resultHolder ).mappedWith (( Converter ) converter )
131
134
.convertPipelineAndTxResults (convertPipelineAndTxResults ).defaultNullTo (defaultValue ).build ();
132
135
}
133
136
134
137
LettuceStatusResult newLettuceStatusResult (Future <?> resultHolder ) {
135
138
return new LettuceStatusResult (resultHolder );
136
139
}
137
140
138
- LettuceTxResult newLettuceTxResult (Object resultHolder ) {
141
+ < T > LettuceTxResult < T , Object > newLettuceTxResult (T resultHolder ) {
139
142
return newLettuceTxResult (resultHolder , (val ) -> val );
140
143
}
141
144
142
- <T > LettuceTxResult <T > newLettuceTxResult (Object resultHolder , Converter converter ) {
145
+ @ SuppressWarnings ("unchecked" )
146
+ <T > LettuceTxResult <T , Object > newLettuceTxResult (T resultHolder , Converter <T , ?> converter ) {
143
147
144
- return LettuceResultBuilder .forResponse (resultHolder ).mappedWith (converter )
148
+ return LettuceResultBuilder .forResponse (resultHolder ).mappedWith (( Converter ) converter )
145
149
.convertPipelineAndTxResults (convertPipelineAndTxResults ).buildTxResult ();
146
150
}
147
151
148
- <T > LettuceTxResult <T > newLettuceTxResult (Object resultHolder , Converter converter , Supplier <?> defaultValue ) {
152
+ @ SuppressWarnings ("unchecked" )
153
+ <T > LettuceTxResult <T , Object > newLettuceTxResult (T resultHolder , Converter <T , ?> converter ,
154
+ Supplier <?> defaultValue ) {
149
155
150
- return LettuceResultBuilder .forResponse (resultHolder ).mappedWith (converter )
156
+ return LettuceResultBuilder .forResponse (resultHolder ).mappedWith (( Converter ) converter )
151
157
.convertPipelineAndTxResults (convertPipelineAndTxResults ).defaultNullTo (defaultValue ).buildTxResult ();
152
158
}
153
159
@@ -558,7 +564,7 @@ public byte[] echo(byte[] message) {
558
564
return null ;
559
565
}
560
566
if (isQueueing ()) {
561
- transaction (new LettuceTxResult (getConnection ().echo (message )));
567
+ transaction (new LettuceTxResult <> (getConnection ().echo (message )));
562
568
return null ;
563
569
}
564
570
return getConnection ().echo (message );
@@ -575,7 +581,7 @@ public String ping() {
575
581
return null ;
576
582
}
577
583
if (isQueueing ()) {
578
- transaction (new LettuceTxResult (getConnection ().ping ()));
584
+ transaction (new LettuceTxResult <> (getConnection ().ping ()));
579
585
return null ;
580
586
}
581
587
return getConnection ().ping ();
@@ -589,10 +595,10 @@ public void discard() {
589
595
isMulti = false ;
590
596
try {
591
597
if (isPipelined ()) {
592
- pipeline (new LettuceStatusResult ((( RedisAsyncCommands ) getAsyncDedicatedConnection () ).discard ()));
598
+ pipeline (new LettuceStatusResult (getAsyncDedicatedRedisCommands ( ).discard ()));
593
599
return ;
594
600
}
595
- (( RedisCommands ) getDedicatedConnection () ).discard ();
601
+ getDedicatedRedisCommands ( ).discard ();
596
602
} catch (Exception ex ) {
597
603
throw convertLettuceAccessException (ex );
598
604
} finally {
@@ -608,7 +614,7 @@ public List<Object> exec() {
608
614
609
615
try {
610
616
if (isPipelined ()) {
611
- RedisFuture <TransactionResult > exec = (( RedisAsyncCommands ) getAsyncDedicatedConnection () ).exec ();
617
+ RedisFuture <TransactionResult > exec = getAsyncDedicatedRedisCommands ( ).exec ();
612
618
613
619
LettuceTransactionResultConverter resultConverter = new LettuceTransactionResultConverter (
614
620
new LinkedList <>(txResults ), LettuceConverters .exceptionConverter ());
@@ -618,7 +624,7 @@ public List<Object> exec() {
618
624
return null ;
619
625
}
620
626
621
- TransactionResult transactionResult = (( RedisCommands ) getDedicatedConnection ()).exec ();
627
+ TransactionResult transactionResult = (getDedicatedRedisCommands ()).exec ();
622
628
List <Object > results = LettuceConverters .transactionResultUnwrapper ().convert (transactionResult );
623
629
return convertPipelineAndTxResults
624
630
? new LettuceTransactionResultConverter (txResults , LettuceConverters .exceptionConverter ()).convert (results )
@@ -641,7 +647,7 @@ public void multi() {
641
647
((RedisAsyncCommands ) getAsyncDedicatedConnection ()).multi ();
642
648
return ;
643
649
}
644
- (( RedisCommands ) getDedicatedConnection ()).multi ();
650
+ (getDedicatedRedisCommands ()).multi ();
645
651
} catch (Exception ex ) {
646
652
throw convertLettuceAccessException (ex );
647
653
}
@@ -678,10 +684,10 @@ public void unwatch() {
678
684
return ;
679
685
}
680
686
if (isQueueing ()) {
681
- transaction (new LettuceTxStatusResult ((( RedisAsyncCommands ) getDedicatedConnection () ).unwatch ()));
687
+ transaction (new LettuceTxStatusResult (getDedicatedRedisCommands ( ).unwatch ()));
682
688
return ;
683
689
}
684
- (( RedisCommands ) getDedicatedConnection () ).unwatch ();
690
+ getDedicatedRedisCommands ( ).unwatch ();
685
691
} catch (Exception ex ) {
686
692
throw convertLettuceAccessException (ex );
687
693
}
@@ -694,14 +700,14 @@ public void watch(byte[]... keys) {
694
700
}
695
701
try {
696
702
if (isPipelined ()) {
697
- pipeline (new LettuceStatusResult ((( RedisAsyncCommands ) getAsyncDedicatedConnection ()) .watch (( Object []) keys )));
703
+ pipeline (new LettuceStatusResult (getAsyncDedicatedRedisCommands () .watch (keys )));
698
704
return ;
699
705
}
700
706
if (isQueueing ()) {
701
- transaction (new LettuceTxStatusResult ((( RedisAsyncCommands ) getDedicatedConnection ()) .watch (( Object []) keys )));
707
+ transaction (new LettuceTxStatusResult (getDedicatedRedisCommands () .watch (keys )));
702
708
return ;
703
709
}
704
- (( RedisCommands ) getDedicatedConnection ()) .watch (( Object []) keys );
710
+ getDedicatedRedisCommands () .watch (keys );
705
711
} catch (Exception ex ) {
706
712
throw convertLettuceAccessException (ex );
707
713
}
@@ -854,6 +860,11 @@ protected RedisClusterCommands<byte[], byte[]> getConnection() {
854
860
return getDedicatedConnection ();
855
861
}
856
862
863
+ @ SuppressWarnings ("unchecked" )
864
+ private RedisAsyncCommands <byte [], byte []> getAsyncDedicatedRedisCommands () {
865
+ return (RedisAsyncCommands ) getAsyncDedicatedConnection ();
866
+ }
867
+
857
868
protected RedisClusterAsyncCommands <byte [], byte []> getAsyncDedicatedConnection () {
858
869
859
870
if (asyncDedicatedConn == null ) {
@@ -876,6 +887,11 @@ protected RedisClusterAsyncCommands<byte[], byte[]> getAsyncDedicatedConnection(
876
887
String .format ("%s is not a supported connection type." , asyncDedicatedConn .getClass ().getName ()));
877
888
}
878
889
890
+ @ SuppressWarnings ("unchecked" )
891
+ private RedisCommands <byte [], byte []> getDedicatedRedisCommands () {
892
+ return (RedisCommands ) getDedicatedConnection ();
893
+ }
894
+
879
895
RedisClusterCommands <byte [], byte []> getDedicatedConnection () {
880
896
881
897
if (asyncDedicatedConn == null ) {
@@ -898,6 +914,7 @@ RedisClusterCommands<byte[], byte[]> getDedicatedConnection() {
898
914
String .format ("%s is not a supported connection type." , asyncDedicatedConn .getClass ().getName ()));
899
915
}
900
916
917
+ @ SuppressWarnings ("unchecked" )
901
918
protected StatefulConnection <byte [], byte []> doGetAsyncDedicatedConnection () {
902
919
return connectionProvider .getConnection (StatefulConnection .class );
903
920
}
0 commit comments