users@grizzly.java.net

Loop in filterchain -> http.server -> filterchain

From: David Cheney <dcheney_at_peaxy.net>
Date: Tue, 5 Nov 2013 16:50:12 -0800

I have an unhappy glassfish.grizzly.http.server.HttpServer. Operations
from multiple browsers will sometimes cause it to throw the
MaxHeaderCountExceededException detailed below - not the loop that looks
like a bunch of MimeHeader are being added. A 'grep -R MimeHeader
our_entire_source_tree' identifies only grizzly-http-2.2.19.jar and
javaee-api-7.0.jar. Once the exception has been thrown it seems that the
server throws the exception on many - if not every - call.

The environment is grissly 2.2.19 and jersey 1.1.7 on Centos 6.4

Anyone have any insights into this, or suggestions on how to chase this?

Basic setup:

        HttpServer server = new HttpServer();
        listener.setSecure(secure);
        listener.registerAddOn(new WebSocketAddOn());
        server.addListener(listener);
        ServerConfiguration config = server.getServerConfiguration();
        ResourceConfig rc = new ClassNamesResourceConfig(
                my1.class,
                my2.class,
                ...
        );
        Map<String, Object> props = rc.getProperties();
        props.put(JSONConfiguration.FEATURE_POJO_MAPPING, true);
        rc.setPropertiesAndFeatures(props);
        HttpHandler handler =
ContainerFactory.createContainer(HttpHandler.class, rc);
        config.addHttpHandler(handler, HF_API_ROOT);
        config.addHttpHandler(new StaticHttpHandler(HF_WEB_PATH), "/");

and the exceptions:

Nov 05, 2013 3:54:47 PM
org.glassfish.grizzly.http.server.filecache.FileCache get
WARNING: File Cache exception
org.glassfish.grizzly.http.util.MimeHeaders$MaxHeaderCountExceededException:
Illegal attempt to exceed the configured maximum number of headers: 100
        at
org.glassfish.grizzly.http.util.MimeHeaders.createHeader(MimeHeaders.java:330)
        at
org.glassfish.grizzly.http.util.MimeHeaders.addValue(MimeHeaders.java:365)
        at
org.glassfish.grizzly.http.HttpHeader.addHeader(HttpHeader.java:680)
        at
org.glassfish.grizzly.http.HttpResponsePacket.addHeader(HttpResponsePacket.java:456)
        at
org.glassfish.grizzly.http.server.filecache.FileCache.addCachingHeaders(FileCache.java:881)
        at
org.glassfish.grizzly.http.server.filecache.FileCache.makeResponse(FileCache.java:386)
        at
org.glassfish.grizzly.http.server.filecache.FileCache.get(FileCache.java:261)
        at
org.glassfish.grizzly.http.server.FileCacheFilter.handleRead(FileCacheFilter.java:83)
        at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
        at
org.glassfish.grizzly.filterchain.FilterChainContext$1.run(FilterChainContext.java:182)
        at
org.glassfish.grizzly.filterchain.FilterChainContext.resume(FilterChainContext.java:206)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.finish(FileCacheFilter.java:114)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.onError(FileCacheFilter.java:110)
        at
org.glassfish.grizzly.asyncqueue.TaskQueue.notifyWritePossible(TaskQueue.java:175)
        at
org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.notifyWritePossible(AbstractNIOAsyncQueueWriter.java:126)
        at
org.glassfish.grizzly.http.server.FileCacheFilter.handleRead(FileCacheFilter.java:100)
        at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
        at
org.glassfish.grizzly.filterchain.FilterChainContext$1.run(FilterChainContext.java:182)
        at
org.glassfish.grizzly.filterchain.FilterChainContext.resume(FilterChainContext.java:206)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.finish(FileCacheFilter.java:114)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.onError(FileCacheFilter.java:110)
        at
org.glassfish.grizzly.asyncqueue.TaskQueue.notifyWritePossible(TaskQueue.java:175)
        at
org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.notifyWritePossible(AbstractNIOAsyncQueueWriter.java:126)
        at
org.glassfish.grizzly.http.server.FileCacheFilter.handleRead(FileCacheFilter.java:100)
        at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)

and the pattern continues for many lines, followed by:

        at
org.glassfish.grizzly.filterchain.FilterChainContext$1.run(FilterChainContext.java:182)
        at
org.glassfish.grizzly.filterchain.FilterChainContext.resume(FilterChainContext.java:206)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.finish(FileCacheFilter.java:114)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.onError(FileCacheFilter.java:110)
        at
org.glassfish.grizzly.asyncqueue.TaskQueue.onClose(TaskQueue.java:298)
        at
org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.onClose(AbstractNIOAsyncQueueWriter.java:538)
        at
org.glassfish.grizzly.nio.transport.TCPNIOTransport.closeConnection(TCPNIOTransport.java:547)
        at
org.glassfish.grizzly.nio.NIOConnection$2.run(NIOConnection.java:445)
        at
org.glassfish.grizzly.nio.DefaultSelectorHandler$RunnableTask.run(DefaultSelectorHandler.java:557)
        at
org.glassfish.grizzly.nio.DefaultSelectorHandler.processPendingTaskQueue(DefaultSelectorHandler.java:295)
        at
org.glassfish.grizzly.nio.DefaultSelectorHandler.processPendingTasks(DefaultSelectorHandler.java:286)
        at
org.glassfish.grizzly.nio.DefaultSelectorHandler.preSelect(DefaultSelectorHandler.java:100)
        at
org.glassfish.grizzly.nio.SelectorRunner.doSelect(SelectorRunner.java:321)
        at
org.glassfish.grizzly.nio.SelectorRunner.run(SelectorRunner.java:264)
        at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:567)
        at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547)
        at java.lang.Thread.run(Unknown Source)

Nov 05, 2013 3:54:47 PM org.glassfish.grizzly.http.server.HttpHandler
doHandle
WARNING: service exception
java.lang.NullPointerException
        at
org.glassfish.grizzly.filterchain.FilterChainContext.getMemoryManager(FilterChainContext.java:781)
        at
org.glassfish.grizzly.http.server.StaticHttpHandler$NonBlockingDownloadHandler.<init>(StaticHttpHandler.java:504)
        at
org.glassfish.grizzly.http.server.StaticHttpHandler.sendUsingBuffers(StaticHttpHandler.java:246)
        at
org.glassfish.grizzly.http.server.StaticHttpHandler.sendFile(StaticHttpHandler.java:232)
        at
org.glassfish.grizzly.http.server.StaticHttpHandler.handle(StaticHttpHandler.java:406)
        at
org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
        at
org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164)
        at
org.glassfish.grizzly.http.server.HttpHandlerChain.service(HttpHandlerChain.java:196)
        at
org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164)
        at
org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:175)
        at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
        at
org.glassfish.grizzly.filterchain.FilterChainContext$1.run(FilterChainContext.java:182)
        at
org.glassfish.grizzly.filterchain.FilterChainContext.resume(FilterChainContext.java:206)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.finish(FileCacheFilter.java:114)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.onError(FileCacheFilter.java:110)
        at
org.glassfish.grizzly.asyncqueue.TaskQueue.notifyWritePossible(TaskQueue.java:175)
        at
org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.notifyWritePossible(AbstractNIOAsyncQueueWriter.java:126)
        at
org.glassfish.grizzly.http.server.FileCacheFilter.handleRead(FileCacheFilter.java:100)
        at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)

etc etc etc same pattern, til:

        at
org.glassfish.grizzly.filterchain.FilterChainContext.resume(FilterChainContext.java:206)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.finish(FileCacheFilter.java:114)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.onError(FileCacheFilter.java:110)
        at
org.glassfish.grizzly.asyncqueue.TaskQueue.onClose(TaskQueue.java:298)
        at
org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.onClose(AbstractNIOAsyncQueueWriter.java:538)
        at
org.glassfish.grizzly.nio.transport.TCPNIOTransport.closeConnection(TCPNIOTransport.java:547)
        at
org.glassfish.grizzly.nio.NIOConnection$2.run(NIOConnection.java:445)
        at
org.glassfish.grizzly.nio.DefaultSelectorHandler$RunnableTask.run(DefaultSelectorHandler.java:557)
        at
org.glassfish.grizzly.nio.DefaultSelectorHandler.processPendingTaskQueue(DefaultSelectorHandler.java:295)
        at
org.glassfish.grizzly.nio.DefaultSelectorHandler.processPendingTasks(DefaultSelectorHandler.java:286)
        at
org.glassfish.grizzly.nio.DefaultSelectorHandler.preSelect(DefaultSelectorHandler.java:100)
        at
org.glassfish.grizzly.nio.SelectorRunner.doSelect(SelectorRunner.java:321)
        at
org.glassfish.grizzly.nio.SelectorRunner.run(SelectorRunner.java:264)
        at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:567)
        at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547)
        at java.lang.Thread.run(Unknown Source)

and after more of the same, concludes:

Nov 05, 2013 3:54:47 PM
org.glassfish.grizzly.http.server.filecache.FileCache get
WARNING: File Cache exception
org.glassfish.grizzly.http.util.MimeHeaders$MaxHeaderCountExceededException:
Illegal attempt to exceed the configured maximum number of headers: 100
        at
org.glassfish.grizzly.http.util.MimeHeaders.createHeader(MimeHeaders.java:330)
        at
org.glassfish.grizzly.http.util.MimeHeaders.addValue(MimeHeaders.java:365)
        at
org.glassfish.grizzly.http.HttpHeader.addHeader(HttpHeader.java:680)
        at
org.glassfish.grizzly.http.HttpResponsePacket.addHeader(HttpResponsePacket.java:456)
        at
org.glassfish.grizzly.http.server.filecache.FileCache.addCachingHeaders(FileCache.java:881)
        at
org.glassfish.grizzly.http.server.filecache.FileCache.makeResponse(FileCache.java:386)
        at
org.glassfish.grizzly.http.server.filecache.FileCache.get(FileCache.java:261)
        at
org.glassfish.grizzly.http.server.FileCacheFilter.handleRead(FileCacheFilter.java:83)
        at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
        at
org.glassfish.grizzly.filterchain.FilterChainContext$1.run(FilterChainContext.java:182)
        at
org.glassfish.grizzly.filterchain.FilterChainContext.resume(FilterChainContext.java:206)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.finish(FileCacheFilter.java:114)
        at
org.glassfish.grizzly.http.server.FileCacheFilter$1.onWritePossible(FileCacheFilter.java:105)
        at
org.glassfish.grizzly.asyncqueue.TaskQueue.doNotify(TaskQueue.java:236)
        at
org.glassfish.grizzly.asyncqueue.TaskQueue.releaseSpaceAndNotify(TaskQueue.java:118)
        at
org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.processAsync(AbstractNIOAsyncQueueWriter.java:401)
        at
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:108)
        at
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
        at
org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:770)
        at
org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        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:567)
        at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547)
        at java.lang.Thread.run(Unknown Source)

thanks!
Dave