jetty / jetty/jetty.project

Jetty 12.1.6 ResourceHandler not respecting start of byte range request when setUseFileMapping is true

Open
#14,536 6 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
Java
Stars
4.1k
Forks
2k
Avg merge
3d 56m
Merged PRs (30d)
48

Description

**Jetty version(s)**
12.1.6, but fails as far back as 12.1.4

**Jetty Environment**
jetty-12 only

**HTTP version**
Tested on http2

**Java version/vendor** `(use: java -version)`
Java 21 and 25

**OS type/version**
OSX: Darwin Kernel Version 25.2.0 on Apple Silicon

**Description**
When using the Resource Handler to serve up static assets and `setUseFileMapping` is true, requests with a byte range not starting at 0, e.g., `range: "bytes=15032-49184"`, the server attempts to send the bytes starting from 0 resulting in a `java.io.IOException: written 49185 > 34153 content-length`

Requesting a byte range starting at 0, works as expected.

Setting `setUseFileMapping` to false resolves the issue.

**How to reproduce?**
Use a ResourceHandler to server up static assets and `setUseFileMapping` to true. Then request a byte range **not** starting at 0.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with Jetty 12's ResourceHandler, setUseFileMapping enabled, and an HTTP/2 byte-range request whose range does not start at 0. Trace the file-mapping path and verify that the response begins at the requested offset; done means nonzero ranges return the requested bytes without the content-length exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.