From f8b2979a8f8202ea3b670a724ca4b0a224d85e43 Mon Sep 17 00:00:00 2001
From: Sergiu Prodan
Date: Thu, 6 Oct 2016 17:10:37 +0300
Subject: [PATCH 1/3] Issue #295 Ensure Jetty Client use of Deflater calls
.end() to avoid memory leak (#986)
* Issue #295 Ensure Jetty Client use of Inflater calls .end() to avoid memory leak
Signed-off-by: Sergiu Prodan
---
.../org/eclipse/jetty/client/GZIPContentDecoder.java | 9 ++++++++-
.../java/org/eclipse/jetty/client/HttpReceiver.java | 11 +++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/GZIPContentDecoder.java b/jetty-client/src/main/java/org/eclipse/jetty/client/GZIPContentDecoder.java
index 8bae3b8a993..2ee10aa9a48 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/GZIPContentDecoder.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/GZIPContentDecoder.java
@@ -25,11 +25,12 @@ import java.util.zip.Inflater;
import java.util.zip.ZipException;
import org.eclipse.jetty.util.BufferUtil;
+import org.eclipse.jetty.util.component.Destroyable;
/**
* {@link ContentDecoder} for the "gzip" encoding.
*/
-public class GZIPContentDecoder implements ContentDecoder
+public class GZIPContentDecoder implements ContentDecoder, Destroyable
{
private final Inflater inflater = new Inflater(true);
private final byte[] bytes;
@@ -322,6 +323,12 @@ public class GZIPContentDecoder implements ContentDecoder
flags = 0;
}
+ @Override
+ public void destroy()
+ {
+ inflater.end();
+ }
+
protected boolean isFinished()
{
return state == State.INITIAL;
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java
index 02a6825b32b..bacab1aa2f8 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java
@@ -37,6 +37,7 @@ import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.CountingCallback;
+import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -465,6 +466,7 @@ public abstract class HttpReceiver
*/
protected void reset()
{
+ destroyDecoder(decoder);
decoder = null;
}
@@ -477,9 +479,18 @@ public abstract class HttpReceiver
*/
protected void dispose()
{
+ destroyDecoder(decoder);
decoder = null;
}
+ private static void destroyDecoder(ContentDecoder decoder)
+ {
+ if (decoder instanceof Destroyable)
+ {
+ ((Destroyable)decoder).destroy();
+ }
+ }
+
public boolean abort(HttpExchange exchange, Throwable failure)
{
// Update the state to avoid more response processing.
From 91e5fb2ce5a66e33c4a9e628975977777b2e0975 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Wed, 19 Oct 2016 08:51:45 -0700
Subject: [PATCH 2/3] Adding jacoco report generation and publishing
---
Jenkinsfile | 8 +++++++-
pom.xml | 25 +++++++++++++++++++++++--
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 8bc326a5a85..8871fc98ddc 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -52,7 +52,13 @@ node('linux') {
// Run test phase / ignore test failures
sh "mvn -B install -Dmaven.test.failure.ignore=true"
// Report failures in the jenkins UI
- step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
+ step([$class: 'JUnitResultArchiver',
+ testResults: '**/target/surefire-reports/TEST-*.xml'])
+ // Collect up the jacoco execution results
+ step([$class: 'JacocoPublisher',
+ execPattern:'target/jacoco*.exec',
+ classPattern: 'target/classes',
+ sourcePattern: 'src/main/java'])
}
if(isUnstable())
{
diff --git a/pom.xml b/pom.xml
index d258efb6c72..d0fb1e0fb72 100644
--- a/pom.xml
+++ b/pom.xml
@@ -171,6 +171,27 @@
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.7.7.201606060606
+
+
+ jacoco-initialize
+ initialize
+
+ prepare-agent
+
+
+
+ jacoco-site
+ package
+
+ report
+
+
+
+
org.apache.maven.plugins
maven-pmd-plugin
@@ -270,9 +291,9 @@
maven-surefire-plugin
2.17
- -showversion -Xmx1g -Xms1g -XX:+PrintGCDetails
+ @{argLine} -showversion -Xmx1g -Xms1g -XX:+PrintGCDetails
false
- random
+ 1