diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 717cb11d3ef..1008773e5ff 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -104,11 +104,11 @@ public class ResourceHandler extends Handler.Wrapper protected HttpContent.Factory newHttpContentFactory() { - HttpContent.Factory contentFactory = new ResourceHttpContentFactory(ResourceFactory.of(_resourceBase), _mimeTypes); + HttpContent.Factory contentFactory = new ResourceHttpContentFactory(ResourceFactory.of(getBaseResource()), getMimeTypes()); contentFactory = new FileMappingHttpContentFactory(contentFactory); contentFactory = new StaticHttpContentFactory(contentFactory, getStyleSheet()); - contentFactory = new PreCompressedHttpContentFactory(contentFactory, _resourceService.getPrecompressedFormats()); - contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, Duration.ofSeconds(1).toMillis(), _byteBufferPool); + contentFactory = new PreCompressedHttpContentFactory(contentFactory, getPrecompressedFormats()); + contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, Duration.ofSeconds(1).toMillis(), getByteBufferPool()); return contentFactory; } @@ -156,6 +156,11 @@ public class ResourceHandler extends Handler.Wrapper return _resourceBase; } + public ByteBufferPool getByteBufferPool() + { + return _byteBufferPool; + } + /** * @return the cacheControl header to set on all static content. */ diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java index 9a766474040..41c5e720ea0 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java @@ -47,6 +47,7 @@ import org.eclipse.jetty.http.content.FileMappingHttpContentFactory; import org.eclipse.jetty.http.content.HttpContent; import org.eclipse.jetty.http.content.PreCompressedHttpContentFactory; import org.eclipse.jetty.http.content.ResourceHttpContentFactory; +import org.eclipse.jetty.http.content.StaticHttpContentFactory; import org.eclipse.jetty.http.content.ValidatingCachingHttpContentFactory; import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.server.Handler; @@ -665,11 +666,11 @@ public class ResourceHandlerTest @Override protected HttpContent.Factory newHttpContentFactory() { - // For testing the cache should be configured to validate the entry on every request. HttpContent.Factory contentFactory = new ResourceHttpContentFactory(ResourceFactory.of(getBaseResource()), getMimeTypes()); - contentFactory = new PreCompressedHttpContentFactory(contentFactory, getPrecompressedFormats()); contentFactory = new FileMappingHttpContentFactory(contentFactory); - contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, 0, _local.getByteBufferPool()); + contentFactory = new StaticHttpContentFactory(contentFactory, getStyleSheet()); + contentFactory = new PreCompressedHttpContentFactory(contentFactory, getPrecompressedFormats()); + contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, 0, getByteBufferPool()); return contentFactory; } };