@@ -337,7 +337,7 @@ public Long getMaxlen() {
337
337
* @since 2.3
338
338
*/
339
339
public boolean hasMaxlen () {
340
- return maxlen != null && maxlen > 0 ;
340
+ return maxlen != null ;
341
341
}
342
342
343
343
/**
@@ -685,7 +685,7 @@ default Mono<PendingMessagesSummary> xPending(ByteBuffer key, String groupName)
685
685
Assert .notNull (key , "Key must not be null" );
686
686
Assert .notNull (groupName , "GroupName must not be null" );
687
687
688
- return xPendingSummary (Mono .just (new PendingRecordsCommand (key , groupName , null , Range . unbounded (), null ))).next ()
688
+ return xPendingSummary (Mono .just (PendingRecordsCommand . pending (key , groupName ))).next ()
689
689
.map (CommandResponse ::getOutput );
690
690
}
691
691
@@ -726,7 +726,7 @@ default Mono<PendingMessages> xPending(ByteBuffer key, Consumer consumer) {
726
726
*/
727
727
@ Nullable
728
728
default Mono <PendingMessages > xPending (ByteBuffer key , String groupName , String consumerName ) {
729
- return xPending (Mono .just (new PendingRecordsCommand (key , groupName , consumerName , Range . unbounded (), null ))).next ()
729
+ return xPending (Mono .just (PendingRecordsCommand . pending (key , groupName ). consumer ( consumerName ))).next ()
730
730
.map (CommandResponse ::getOutput );
731
731
}
732
732
@@ -743,7 +743,7 @@ default Mono<PendingMessages> xPending(ByteBuffer key, String groupName, String
743
743
* @since 2.3
744
744
*/
745
745
default Mono <PendingMessages > xPending (ByteBuffer key , String groupName , Range <?> range , Long count ) {
746
- return xPending (Mono .just (new PendingRecordsCommand (key , groupName , null , range , count ))).next ()
746
+ return xPending (Mono .just (PendingRecordsCommand . pending (key , groupName ). range ( range , count ))).next ()
747
747
.map (CommandResponse ::getOutput );
748
748
}
749
749
@@ -779,8 +779,8 @@ default Mono<PendingMessages> xPending(ByteBuffer key, Consumer consumer, Range<
779
779
*/
780
780
default Mono <PendingMessages > xPending (ByteBuffer key , String groupName , String consumerName , Range <?> range ,
781
781
Long count ) {
782
- return xPending (Mono .just (new PendingRecordsCommand (key , groupName , consumerName , range , count ))). next ( )
783
- .map (CommandResponse ::getOutput );
782
+ return xPending (Mono .just (PendingRecordsCommand . pending (key , groupName ). consumer ( consumerName ). range ( range , count )))
783
+ .next (). map (CommandResponse ::getOutput );
784
784
}
785
785
786
786
/**
@@ -832,9 +832,15 @@ static PendingRecordsCommand pending(ByteBuffer key, String groupName) {
832
832
/**
833
833
* Create new {@link PendingRecordsCommand} with given {@link Range} and limit.
834
834
*
835
+ * @param range must not be {@literal null}.
836
+ * @param count the max number of messages to return. Must not be negative.
835
837
* @return new instance of {@link XPendingOptions}.
836
838
*/
837
- public PendingRecordsCommand range (Range <String > range , Long count ) {
839
+ public PendingRecordsCommand range (Range <?> range , Long count ) {
840
+
841
+ Assert .notNull (range , "Range must not be null" );
842
+ Assert .isTrue (count > -1 , "Count must not be negative" );
843
+
838
844
return new PendingRecordsCommand (getKey (), groupName , consumerName , range , count );
839
845
}
840
846
@@ -886,7 +892,7 @@ public boolean hasConsumer() {
886
892
* @return {@literal true} count is set.
887
893
*/
888
894
public boolean isLimited () {
889
- return count != null && count > - 1 ;
895
+ return count != null ;
890
896
}
891
897
}
892
898
0 commit comments