From 4a9265d4b402b45a14fb96b97eb86b0b18b5c187 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Sat, 3 Nov 2018 17:53:32 +0100 Subject: [PATCH] backports from 10.0.x websocket refactor Signed-off-by: Greg Wilkins --- .../java/org/eclipse/jetty/client/HttpClient.java | 3 ++- .../java/org/eclipse/jetty/io/ChannelEndPoint.java | 13 ++++++------- .../org/eclipse/jetty/util/IteratingCallback.java | 10 +++++----- 3 files changed, 13 insertions(+), 13 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 308e79daf6c..e22b3dc7194 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 @@ -212,8 +212,8 @@ public class HttpClient extends ContainerLifeCycle QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setName(name); executor = threadPool; + addBean(executor); } - addBean(executor); if (byteBufferPool == null) byteBufferPool = new MappedByteBufferPool(2048, @@ -796,6 +796,7 @@ public class HttpClient extends ContainerLifeCycle */ public void setExecutor(Executor executor) { + updateBean(this.executor, executor); this.executor = executor; } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java index ed6a761c041..0421176298f 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java @@ -229,29 +229,28 @@ public abstract class ChannelEndPoint extends AbstractEndPoint implements Manage return -1; int pos=BufferUtil.flipToFill(buffer); + int filled; try { - int filled = _channel.read(buffer); - if (LOG.isDebugEnabled()) // Avoid boxing of variable 'filled' - LOG.debug("filled {} {}", filled, this); - + filled = _channel.read(buffer); if (filled>0) notIdle(); else if (filled==-1) shutdownInput(); - - return filled; } catch(IOException e) { LOG.debug(e); shutdownInput(); - return -1; + filled = -1; } finally { BufferUtil.flipToFlush(buffer,pos); } + if (LOG.isDebugEnabled()) + LOG.debug("filled {} {}", filled, BufferUtil.toDetailString(buffer)); + return filled; } @Override diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java b/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java index 4fb91db63ec..bdbfc5f9db1 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java @@ -18,7 +18,7 @@ package org.eclipse.jetty.util; -import java.nio.channels.ClosedChannelException; +import java.io.IOException; import org.eclipse.jetty.util.thread.Locker; @@ -403,7 +403,7 @@ public abstract class IteratingCallback implements Callback public void close() { - boolean failure=false; + String failure=null; try(Locker.Lock lock = _locker.lock()) { switch (_state) @@ -418,13 +418,13 @@ public abstract class IteratingCallback implements Callback break; default: + failure=String.format("Close %s in state %s",this,_state); _state=State.CLOSED; - failure=true; } } - if(failure) - onCompleteFailure(new ClosedChannelException()); + if(failure!=null) + onCompleteFailure(new IOException(failure)); } /*