Skip to content

Commit

Permalink
AMQ-9541 Use limits on all expensive queries and at least the ones wh…
Browse files Browse the repository at this point in the history
…ere there is a setMaxRows on the statement.
  • Loading branch information
jeanouii committed Jul 25, 2024
1 parent 5bc3a1e commit e66d2a0
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.MessageId;
Expand Down Expand Up @@ -431,7 +429,7 @@ public void doMessageIdScan(TransactionContext c, int limit,
PreparedStatement s = null;
ResultSet rs = null;
try {
s = c.getConnection().prepareStatement(this.statements.getFindAllMessageIdsStatement());
s = c.getConnection().prepareStatement(this.limitQuery(this.statements.getFindAllMessageIdsStatement()));
s.setMaxRows(limit);
rs = s.executeQuery();
// jdbc scrollable cursor requires jdbc ver > 1.0 and is often implemented locally so avoid
Expand Down Expand Up @@ -591,7 +589,7 @@ public void doRecoverNextMessages(TransactionContext c, ActiveMQDestination dest
PreparedStatement s = null;
ResultSet rs = null;
try {
s = c.getConnection().prepareStatement(this.statements.getFindDurableSubMessagesStatement());
s = c.getConnection().prepareStatement(this.limitQuery(this.statements.getFindDurableSubMessagesStatement()));
s.setMaxRows(Math.min(maxReturned * 2, maxRows));
s.setString(1, destination.getQualifiedName());
s.setString(2, clientId);
Expand Down Expand Up @@ -625,7 +623,7 @@ public void doRecoverNextMessagesWithPriority(TransactionContext c, ActiveMQDest
PreparedStatement s = null;
ResultSet rs = null;
try {
s = c.getConnection().prepareStatement(this.statements.getFindDurableSubMessagesByPriorityStatement());
s = c.getConnection().prepareStatement(this.limitQuery(this.statements.getFindDurableSubMessagesByPriorityStatement()));
s.setMaxRows(Math.min(maxReturned * 2, maxRows));
s.setString(1, destination.getQualifiedName());
s.setString(2, clientId);
Expand Down

0 comments on commit e66d2a0

Please sign in to comment.