Forum Stats

  • 3,837,920 Users
  • 2,262,309 Discussions
  • 7,900,433 Comments

Discussions

Glassfish 4 HeapBuffer has already been disposed

Glassfish 4.0 Build 89

Apache/2.2.15

I have a servlet to provide images from our filestore. If an image is requested bigger than ~1.7Mb it is either truncated, corrupted, or missing. The status code of the request is always 200 OK.

The following stack trace occurs:

[2017-02-17T10:10:08.528+0000] [glassfish 4.0] [WARNING] [] [org.glassfish.grizzly.ProcessorExecutor] [tid: _ThreadID=45 _ThreadName=jk-connector(3)] [timeMillis: 1487326208528] [levelValue: 900] [[  Error during Processor execution. Connection=TCPNIOConnection{localSocketAddress={/127.0.0.1:8010}, peerSocketAddress={/127.0.0.1:57892}} ioEvent=WRITE [email protected]2d4f3a4java.lang.IllegalStateException: HeapBuffer has already been disposed    at org.glassfish.grizzly.memory.HeapBuffer.checkDispose(HeapBuffer.java:802)    at org.glassfish.grizzly.memory.HeapBuffer.position(HeapBuffer.java:188)    at org.glassfish.grizzly.memory.BuffersBuffer.get(BuffersBuffer.java:881)    at org.glassfish.grizzly.memory.BuffersBuffer.get(BuffersBuffer.java:59)    at org.glassfish.grizzly.memory.BuffersBuffer.get(BuffersBuffer.java:869)    at org.glassfish.grizzly.memory.BuffersBuffer.get(BuffersBuffer.java:842)    at org.glassfish.grizzly.memory.BuffersBuffer.get(BuffersBuffer.java:59)    at org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter.fillByteBuffer(TCPNIOAsyncQueueWriter.java:206)    at org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter.writeComposite0(TCPNIOAsyncQueueWriter.java:151)    at org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter.write0(TCPNIOAsyncQueueWriter.java:80)    at org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.processAsync(AbstractNIOAsyncQueueWriter.java:458)    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:110)    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)    at java.lang.Thread.run(Thread.java:745)]]

Sample code snippet:

        //String pathJpg derived from database call (not shown here)        File file = new File(pathJpg);        String mime = "image/jpeg";                response.setContentLengthLong(file.length());        response.setContentType(mime);        FileInputStream in = new FileInputStream(file);        try {            byte[] buf = new byte[1024];            int count;            while ((count = in.read(buf)) >= 0) {                response.getOutputStream().write(buf);            }        }        finally {            in.close();        }

Calls to this servlet are being done via dynamically altering the src tag of an image upon clicking a button

Others have previous reported similar issues and it was registered as a bug, but it appears unresolved:

https://java.net/jira/browse/GLASSFISH-21192

Occurs irrespective of our Byte Buffer Type (Default DIRECT, but occurs with HEAP also) and irrespective of byte buffer sizes, chunking mode, compression or similar.

I have also tried replacing the grizzly jars in the Glassfish mq/lib folder with the latest versions - this also made no difference

I'm out of ideas, so any suggestions would be appreciated

This discussion has been closed.