From 859004bef4fbbb3b2cf274b21f8247ba8268ff23 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 13 Nov 2018 16:42:12 +0100 Subject: [PATCH] Issue #3103 Fixed buffer leak Only warn if HttpClient setters are called after start Signed-off-by: Greg Wilkins --- .../main/java/org/eclipse/jetty/client/HttpClient.java | 10 ++++------ .../org/eclipse/jetty/client/ResponseNotifier.java | 6 ------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index b8b0af8da08..5fb4b861360 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -18,7 +18,6 @@ package org.eclipse.jetty.client; -import java.io.IOException; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.CookieStore; @@ -71,7 +70,6 @@ import org.eclipse.jetty.util.SocketAddressResolver; import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.ContainerLifeCycle; -import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -646,7 +644,7 @@ public class HttpClient extends ContainerLifeCycle public void setByteBufferPool(ByteBufferPool byteBufferPool) { if (isStarted()) - throw new IllegalStateException(getState()); + LOG.warn("Calling setByteBufferPool() while started is deprecated"); updateBean(this.byteBufferPool, byteBufferPool); this.byteBufferPool = byteBufferPool; } @@ -800,7 +798,7 @@ public class HttpClient extends ContainerLifeCycle public void setExecutor(Executor executor) { if (isStarted()) - throw new IllegalStateException(getState()); + LOG.warn("Calling setExecutor() while started is deprecated"); updateBean(this.executor, executor); this.executor = executor; } @@ -819,7 +817,7 @@ public class HttpClient extends ContainerLifeCycle public void setScheduler(Scheduler scheduler) { if (isStarted()) - throw new IllegalStateException(getState()); + LOG.warn("Calling setScheduler() while started is deprecated"); updateBean(this.scheduler, scheduler); this.scheduler = scheduler; } @@ -838,7 +836,7 @@ public class HttpClient extends ContainerLifeCycle public void setSocketAddressResolver(SocketAddressResolver resolver) { if (isStarted()) - throw new IllegalStateException(getState()); + LOG.warn("Calling setSocketAddressResolver() while started is deprecated"); updateBean(this.resolver, resolver); this.resolver = resolver; } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/ResponseNotifier.java b/jetty-client/src/main/java/org/eclipse/jetty/client/ResponseNotifier.java index e879fd56d88..e4c2ffe3f69 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/ResponseNotifier.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/ResponseNotifier.java @@ -30,7 +30,6 @@ import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.CountingCallback; -import org.eclipse.jetty.util.Retainable; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -122,13 +121,8 @@ public class ResponseNotifier else { CountingCallback counter = new CountingCallback(callback, contentListeners.size()); - Retainable retainable = callback instanceof Retainable ? (Retainable)callback : null; for (Response.AsyncContentListener listener : contentListeners) - { - if (retainable != null) - retainable.retain(); notifyContent(listener, response, buffer.slice(), counter); - } } }