From daf61cd2942abe93e6f3d728e5220691d08a9372 Mon Sep 17 00:00:00 2001 From: Denis Nedelyaev Date: Thu, 30 Mar 2017 04:15:32 +0300 Subject: [PATCH] Fix memory leak in GzipHandler (#1429) Looks like this leak shows itself only with asynchronous responses. Some relevant info: http://www.devguli.com/blog/eng/java-deflater-and-outofmemoryerror/ Signed-off-by: Denis Nedelyaev --- .../org/eclipse/jetty/server/handler/gzip/GzipHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java index 783afd2bd64..d645c8dcf5e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipHandler.java @@ -542,9 +542,13 @@ public class GzipHandler extends HandlerWrapper implements GzipFactory @Override public void recycle(Deflater deflater) { - deflater.reset(); if (_deflater.get()==null) + { + deflater.reset(); _deflater.set(deflater); + } + else + deflater.end(); } /* ------------------------------------------------------------ */