Fix thread leak/invasion

Jersey/Jetty, at least in the 3.1 version line, creates one thread for each HTTP request. This behavior was introduced with #5372 and seems not present in the 2.x or 3.x versions of Jersey.

From the javadoc of `java.util.Timer`:
```
Implementation note: All constructors start a timer thread.
...
After the last live reference to a Timer object goes away and all outstanding tasks have completed execution, the timer's task execution thread terminates gracefully (and becomes subject to garbage collection). However, this can take arbitrarily long to occur.
```
It is fair to assume that "arbitrarily long" may also mean _never_, in case GC never runs.

This change replaces the timer & thread per request with a `ScheduledExecutorService` instance per `JettyHttpContainer`.

Also changed the set-timeout mechanism to use `System.nanoTime()` instead of `System.currentTimeMillis()`, because the latter is prone to wall-clock drift and can result into wrong timeout values.

Fixes #5588

Signed-off-by: Robert Stupp <snazy@snazy.de>
1 file changed
tree: 5679644096aed2559958a955a49967c55e326a86
  1. .github/
  2. archetypes/
  3. bom/
  4. bundles/
  5. connectors/
  6. containers/
  7. core-client/
  8. core-common/
  9. core-server/
  10. docs/
  11. etc/
  12. examples/
  13. ext/
  14. incubator/
  15. inject/
  16. media/
  17. security/
  18. test-framework/
  19. tests/
  20. tools/
  21. .gitignore
  22. .travis.yml
  23. CONTRIBUTING.md
  24. LICENSE.md
  25. NOTICE.md
  26. pom.xml
  27. README.md
README.md

Build Status  EPL-2.0  GPL+CPE-2.0

About Jersey

Jersey is a REST framework that provides JAX-RS Reference Implementation and more. Jersey provides its own APIs that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development. Jersey also exposes numerous extension SPIs so that developers may extend Jersey to best suit their needs.

Goals of Jersey project can be summarized in the following points:

  • Track the JAX-RS API and provide regular releases of production quality Reference Implementations that ships with GlassFish;
  • Provide APIs to extend Jersey & Build a community of users and developers; and finally
  • Make it easy to build RESTful Web services utilising Java and the Java Virtual Machine.

Licensing and Governance

Jersey is licensed under a dual license - EPL 2.0 and GPL 2.0 with Class-path Exception. That means you can choose which one of the two suits your needs better and use it under those terms.

We use contribution policy, which means we can only accept contributions under the terms of ECA.

More Information on Jersey

See the Jersey website to access Jersey documentation. If you run into any issues or have questions, ask at jersey-dev@eclipse.org (need to subscribe first), StackOverflow or file an issue on Jersey GitHub Project. You can follow us on Twitter, too.