@@ -335,7 +335,7 @@ public Long getMaxlen() {
335
335
* @since 2.3
336
336
*/
337
337
public boolean hasMaxlen () {
338
- return maxlen != null && maxlen > 0 ;
338
+ return maxlen != null ;
339
339
}
340
340
341
341
/**
@@ -654,7 +654,7 @@ default Mono<PendingMessagesSummary> xPending(ByteBuffer key, String groupName)
654
654
Assert .notNull (key , "Key must not be null" );
655
655
Assert .notNull (groupName , "GroupName must not be null" );
656
656
657
- return xPendingSummary (Mono .just (new PendingRecordsCommand (key , groupName , null , Range . unbounded (), null ))).next ()
657
+ return xPendingSummary (Mono .just (PendingRecordsCommand . pending (key , groupName ))).next ()
658
658
.map (CommandResponse ::getOutput );
659
659
}
660
660
@@ -695,7 +695,7 @@ default Mono<PendingMessages> xPending(ByteBuffer key, Consumer consumer) {
695
695
*/
696
696
@ Nullable
697
697
default Mono <PendingMessages > xPending (ByteBuffer key , String groupName , String consumerName ) {
698
- return xPending (Mono .just (new PendingRecordsCommand (key , groupName , consumerName , Range . unbounded (), null ))).next ()
698
+ return xPending (Mono .just (PendingRecordsCommand . pending (key , groupName ). consumer ( consumerName ))).next ()
699
699
.map (CommandResponse ::getOutput );
700
700
}
701
701
@@ -712,7 +712,7 @@ default Mono<PendingMessages> xPending(ByteBuffer key, String groupName, String
712
712
* @since 2.3
713
713
*/
714
714
default Mono <PendingMessages > xPending (ByteBuffer key , String groupName , Range <?> range , Long count ) {
715
- return xPending (Mono .just (new PendingRecordsCommand (key , groupName , null , range , count ))).next ()
715
+ return xPending (Mono .just (PendingRecordsCommand . pending (key , groupName ). range ( range , count ))).next ()
716
716
.map (CommandResponse ::getOutput );
717
717
}
718
718
@@ -748,8 +748,8 @@ default Mono<PendingMessages> xPending(ByteBuffer key, Consumer consumer, Range<
748
748
*/
749
749
default Mono <PendingMessages > xPending (ByteBuffer key , String groupName , String consumerName , Range <?> range ,
750
750
Long count ) {
751
- return xPending (Mono .just (new PendingRecordsCommand (key , groupName , consumerName , range , count ))). next ( )
752
- .map (CommandResponse ::getOutput );
751
+ return xPending (Mono .just (PendingRecordsCommand . pending (key , groupName ). consumer ( consumerName ). range ( range , count )))
752
+ .next (). map (CommandResponse ::getOutput );
753
753
}
754
754
755
755
/**
@@ -801,9 +801,15 @@ static PendingRecordsCommand pending(ByteBuffer key, String groupName) {
801
801
/**
802
802
* Create new {@link PendingRecordsCommand} with given {@link Range} and limit.
803
803
*
804
+ * @param range must not be {@literal null}.
805
+ * @param count the max number of messages to return. Must not be negative.
804
806
* @return new instance of {@link XPendingOptions}.
805
807
*/
806
- public PendingRecordsCommand range (Range <String > range , Long count ) {
808
+ public PendingRecordsCommand range (Range <?> range , Long count ) {
809
+
810
+ Assert .notNull (range , "Range must not be null" );
811
+ Assert .isTrue (count > -1 , "Count must not be negative" );
812
+
807
813
return new PendingRecordsCommand (getKey (), groupName , consumerName , range , count );
808
814
}
809
815
@@ -855,7 +861,7 @@ public boolean hasConsumer() {
855
861
* @return {@literal true} count is set.
856
862
*/
857
863
public boolean isLimited () {
858
- return count != null && count > - 1 ;
864
+ return count != null ;
859
865
}
860
866
}
861
867
0 commit comments