ZimbraLog.imap.info("input request too long");
    public void handleInput(ByteBuffer buffer, boolean matched) throws IOException {        if (mState == ConnectionState.CLOSED) {            ZimbraLog.imap.info(OzUtil.byteBufferDebugDump("input arrived on closed connection", buffer, false));            mCurrentData.clear();            return;        }                        mCurrentData.add(buffer);        if (!matched)            return;        mCurrentData.trim(mConnection.getMatcher().trailingTrimLength());        if (mState == ConnectionState.READLITERAL) {            mCurrentRequestData.add(mCurrentData.array());            /*			 * at the end of a literal there is more of the command or there is			 * just CRLF (which is the empty part of the command)			 */            gotoReadLineState(false);            return;        } else if (mState == ConnectionState.READLINE && mAuthenticator != null) {            boolean authFinished = true;            try {                if (mCurrentData.overflowed()) {                    sendBAD(mAuthenticator.mTag, "AUTHENTICATE failed: request too long");                    gotoReadLineState(true);                    return;                } else if (mCurrentData.size() == 1 && mCurrentData.get(0) == '*') {                    // 6.2.2: "If the client wishes to cancel an authentication exchange, it issues a line                    //         consisting of a single "*".  If the server receives such a response, it MUST                    //         reject the AUTHENTICATE command by sending a tagged BAD response."                    sendBAD(mAuthenticator.mTag, "AUTHENTICATE aborted");                    gotoReadLineState(true);                    return;                }                mCurrentRequestData.add(mCurrentData.toAsciiString());                OzImapRequest req = new OzImapRequest(mAuthenticator.mTag, mCurrentRequestData, mSession);                if (continueAuthentication(req))                    gotoReadLineState(true);                else                    gotoClosedState(true);                return;            } finally {                if (authFinished)                    mAuthenticator = null;            }        } else if (mState == ConnectionState.READLINE) {            if (mCurrentData.overflowed()) {                sendUntagged("BAD request too long", true);                gotoReadLineState(true);                return;            }            String line = mCurrentData.toAsciiString();            /*             * Is this the first line of this request? If so, then let's try             * to parse the tag from it so we can report tagged BADs if             * needed. TODO: should we also strip tag here - so we don't             * parse it twice?             */            if (mCurrentRequestData.size() == 0) {                logCommand(line);                try {                    mCurrentRequestTag = OzImapRequest.readTag(line);                } catch (ImapParseException ipe) {                    sendUntagged("BAD " + ipe.getMessage(), true);                    gotoReadLineState(true);                    return;                }            }            /* See if there is a literal at the end of this line. */            ImapLiteral literal;            try {                literal = ImapLiteral.parse(mCurrentRequestTag, line);            } catch (ImapParseException ipe) {                sendBAD(mCurrentRequestTag, ipe.getMessage());                gotoReadLineState(true);                return;            }            /* Add either the literal removed line or a no-literal present at all             * line (ie, it's line in either case) to the request in flight.             */             mCurrentRequestData.add(line);            if (literal.octets() > 0) {                if (literal.blocking()) {                    sendContinuation();                }                gotoReadLiteralState(literal.octets());                return;            } else {                if (processCommand()) {                    gotoReadLineState(true);                } else {                    gotoClosedState(true);                }                return;            }        }        throw new RuntimeException("internal error in IMAP server: bad state " + mState);    }