eclipse-ee4j / eclipse-ee4j/jersey
org.glassfish.jersey.jdkhttp.JdkHttpServerFactory is leaking sun.net.httpserver.HttpConnection if POST to a non-exist endponit
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
Step to reproduce:
1\. create a http server using JdkHttpServerFactory.createHttpServer
2\. curl -v --data "aaa=bbb" [http://localhost:8006/path/to/non/exist/endpoint](http://localhost:8006/path/to/non/exist/endpoint) for several times.
3\. if using apache bench to send a bunch of requests, sooner the target jvm will start to do fullgc.
In our production server, the heap dump tell us that over 300k HttpConnection(sun.net.httpserver.ServerImpl#reqConnections) objects can never be garbage collected.
Further investigation shows that in org.glassfish.jersey.server.ServerRuntime#process, a NotFoundException is thrown if the endpoint is not found, therefore in nowhere has the related HttpConnection object been released.
#### Environment
mac
#### Affected Versions
[2.24.1]
Contributor guide
Research direction
Reproduce the repeated POST requests against JdkHttpServerFactory.createHttpServer, then inspect ServerRuntime#process and the NotFoundException path alongside sun.net.httpserver.HttpConnection and ServerImpl#reqConnections. Done means nonexistent POST endpoints no longer leave HttpConnection objects retained and repeated requests no longer drive unbounded connection growth or full GCs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100