users@grizzly.java.net

howto configure java.nio.Buffer capacity in Grizzly

From: Sergey Armishev <Sergey.Armishev_at_Netgear.com>
Date: Tue, 2 Jul 2013 18:57:58 +0000

We have an Exception that from time to time thrown when our code flushes the data to the output stream. How can I configure this capacity parameter? Our Grizzly environment
 Grizzly 1.0.40 running on Linux-3.5.0-34-generic under JDK version: 1.6.0_27-Sun Microsystems Inc

Code that generates Exception

    protected void writeMessage(String msg, HttpServletResponse response) throws IOException {
        if( response == null) {
            log.info("response is null");
            return;
        }

        if( msg == null) {
            log.info("GOT EMPTY MESSAGE ");
            msg = "";
        }
        response.setContentLength(msg.getBytes().length);
        response.setStatus(HttpServletResponse.SC_OK);
        PrintWriter writer = response.getWriter();
        writer.write(msg);
        writer.flush();// that line that generates Exception at com.fourhomemedia.portal.messagequeue.PortalQueue.writeMessage(PortalQueue.java:268)
    }

An Exception stack trace
[#|2013-07-01T12:31:04.238-0700|WARNING|sun-appserver2.1|javax.enterprise.system.stream.err|_ThreadID=35;_ThreadName=httpSSLWorkerThread-8443-18;_RequestID=bff5d22c-bef6-4f67-95ce-7e7d939e98a6;|
java.lang.IllegalArgumentException
        at java.nio.Buffer.limit(Buffer.java:266)
        at sun.security.ssl.EngineOutputRecord.addMAC(EngineOutputRecord.java:132)
        at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:301)
        at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:268)
        at sun.security.ssl.EngineWriter.writeRecord(EngineWriter.java:185)
        at sun.security.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1202)
        at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1172)
        at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1087)
        at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:469)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLUtils.wrap(SSLUtils.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLOutputWriter.flushChannel(SSLOutputWriter.java:75)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLAsyncOutputBuffer.flushChannel(SSLAsyncOutputBuffer.java:83)
        at com.sun.enterprise.web.connector.grizzly.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:205)
        at com.sun.enterprise.web.connector.grizzly.SocketChannelOutputBuffer.flush(SocketChannelOutputBuffer.java:183)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.action(DefaultProcessorTask.java:1100)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:151)
        at org.apache.coyote.Response.action(Response.java:237)
        at org.apache.coyote.tomcat5.OutputBuffer.doFlush(OutputBuffer.java:381)
        at org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:351)
        at org.apache.coyote.tomcat5.CoyoteWriter.flush(CoyoteWriter.java:151)
        at com.fourhomemedia.portal.messagequeue.PortalQueue.writeMessage(PortalQueue.java:268)

Java Buffer.java code that throws an exception
    public final Buffer limit(int newLimit) {
        if ((newLimit > capacity) || (newLimit < 0))
            throw new IllegalArgumentException(); // that is line 266 from Exception at java.nio.Buffer.limit(Buffer.java:266)
        limit = newLimit;
        if (position > limit) position = limit;
        if (mark > limit) mark = -1;
        return this;
    }

Thanks,
Sergey Armishev


This e-mail, including attachments, may include confidential
and/or proprietary information, and may be used only by the
person or entity to which it is addressed.
If the reader of this e-mail is not the intended recipient or his or
her authorized agent, the reader is hereby notified that any
dissemination, distribution or copying of this e-mail is prohibited.
If you have received this e-mail in error, please notify the sender
by replying to this message and delete this e-mail immediately