@@ -696,7 +696,7 @@ public void notifyDrainQueuedCommands(HasQueuedCommands queuedCommands) {
696
696
logger .debug ("{} notifyQueuedCommands adding {} command(s) to buffer" , logPrefix (), commands .size ());
697
697
}
698
698
699
- commands . addAll ( drainCommands (disconnectedBuffer ) );
699
+ drainCommands (disconnectedBuffer , commands );
700
700
701
701
for (RedisCommand <?, ?, ?> command : commands ) {
702
702
@@ -745,8 +745,8 @@ protected <T> T doExclusive(Supplier<T> supplier) {
745
745
746
746
List <RedisCommand <?, ?, ?>> target = new ArrayList <>(disconnectedBuffer .size () + commandBuffer .size ());
747
747
748
- target . addAll ( drainCommands (disconnectedBuffer ) );
749
- target . addAll ( drainCommands (commandBuffer ) );
748
+ drainCommands (disconnectedBuffer , target );
749
+ drainCommands (commandBuffer , target );
750
750
751
751
return target ;
752
752
}
@@ -769,9 +769,26 @@ protected <T> T doExclusive(Supplier<T> supplier) {
769
769
}
770
770
}
771
771
772
+ drainCommands (source , target );
772
773
return target ;
773
774
}
774
775
776
+ /**
777
+ * Drain commands from a queue and return only active commands.
778
+ *
779
+ * @param source the source queue.
780
+ */
781
+ private static void drainCommands (Queue <? extends RedisCommand <?, ?, ?>> source , Collection <RedisCommand <?, ?, ?>> target ) {
782
+
783
+ RedisCommand <?, ?, ?> cmd ;
784
+ while ((cmd = source .poll ()) != null ) {
785
+
786
+ if (!cmd .isDone () && !ActivationCommand .isActivationCommand (cmd )) {
787
+ target .add (cmd );
788
+ }
789
+ }
790
+ }
791
+
775
792
private void cancelBufferedCommands (String message ) {
776
793
cancelCommands (message , doExclusive (this ::drainCommands ), RedisCommand ::cancel );
777
794
}
0 commit comments