https://issues.apache.org/bugzilla/show_bug.cgi?id=48060
Summary: wrong implementation of peek() method of
JIoEndpoint.WorkerStack class
Product: Tomcat 7
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
AssignedTo: [email protected]
ReportedBy: [email protected]
/**
* Get the first object out of the queue, Return null if the queue
* is empty.
*/
public Worker peek() {
return workers[end];
}
should be:
/**
* Get the first object out of the queue, Return null if the queue
* is empty.
*/
public Worker peek() {
if (end > 0) {
return workers[end - 1];
}
return null;
}
please refer to the pop() method (apart from pop()'s side effect, pop() and
peek() should return the same result):
/**
* Get the first object out of the queue. Return null if the queue
* is empty.
*/
public Worker pop() {
if (end > 0) {
return workers[--end];
}
return null;
}
'end' denotes the index beyond the last element, not the index of the last
element itself. That is why the variable of 'end' is assigned a zero value at
first.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]