[PR] Avoid infinite loop in DeltaManager with invalid batch si ze [tomcat]
lihongyi87 (via GitHub) <[email protected]>
| Newsgroups | gmane.comp.jakarta.tomcat.devel |
|---|---|
| Message-ID | <[email protected]> |
lihongyi87 opened a new pull request, #1042:
URL: https://github.com/apache/tomcat/pull/1042
## Problem
When `sendAllSessions` is `false` and `sendAllSessionsSize` is configured to zero or a negative value, the batch loop in `handleGET_ALL_SESSIONS` never terminates:
```java
for (int i = 0; i < currentSessions.length; i += getSendAllSessionsSize()) {
```
- With `sendAllSessionsSize == 0`: `i` never advances, so the loop runs indefinitely, sending empty session arrays and sleeping on each iteration. This blocks the cluster receiver thread on the master node and prevents `EVT_ALL_SESSION_TRANSFERCOMPLETE` from ever being sent.
- With `sendAllSessionsSize < 0`: `i` decreases, and `new Session[len]` throws `NegativeArraySizeException`.
The `setSendAllSessionsSize` setter performs no validation, and the documentation (`cluster-manager.xml`) does not state a minimum value.
## Fix
When `sendAllSessionsSize` is not positive, fall back to sending all sessions in a single batch (the same behaviour as `sendAllSessions == true`):
```java
if (isSendAllSessions() || getSendAllSessionsSize() <= 0) {
```
This is a one-line change at the point of use, keeping the setter unmodified for consistency with the rest of `DeltaManager`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]