https://issues.apache.org/bugzilla/show_bug.cgi?id=48046

           Summary: wrong implementation of peek() method of
                    JIoEndpoint.WorkerStack class
           Product: Tomcat 6
           Version: 6.0.20
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Connectors
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: qingyang...@qunar.com


/**
         * 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:

        /**
         * 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;
        }

Though obviously wrong, the peek() method has not been invoked in the whole
source code base of Tomcat. But what if future version makes use of peek()
method?? So, please correct it. It is so easy.

-- 
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: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to