diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java index 44745204851..26d8bcc3b92 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java @@ -65,7 +65,7 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async // While we are making progress and have not changed connection while (progress && connection==this) { - LOG.debug("while open={} more={} buffering={} progress={}",_endp.isOpen(),_parser.isMoreInBuffer(),_endp.isBufferingInput(),progress); + LOG.debug("while open={} more={} progress={}",_endp.isOpen(),_parser.isMoreInBuffer(),progress); progress=false; HttpExchange exchange=_exchange; @@ -142,13 +142,14 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async progress=true; } } + catch (ThreadDeath e) + { + throw e; + } catch (Throwable e) { LOG.debug("Failure on " + _exchange, e); - if (e instanceof ThreadDeath) - throw (ThreadDeath)e; - failed = true; synchronized (this) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java index c02e156911b..d10d81c7b32 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java @@ -59,11 +59,10 @@ public class BlockingHttpConnection extends AbstractHttpConnection { boolean failed = false; - // While we are making progress and have not changed connection while (_endp.isOpen() && connection==this) { - LOG.debug("open={} more={} buffering={}",_endp.isOpen(),_parser.isMoreInBuffer(),_endp.isBufferingInput()); + LOG.debug("open={} more={}",_endp.isOpen(),_parser.isMoreInBuffer()); HttpExchange exchange; synchronized (this) @@ -141,15 +140,15 @@ public class BlockingHttpConnection extends AbstractHttpConnection { LOG.debug("parsed"); } - + } + catch (ThreadDeath e) + { + throw e; } catch (Throwable e) { LOG.debug("Failure on " + _exchange, e); - if (e instanceof ThreadDeath) - throw (ThreadDeath)e; - failed = true; synchronized (this) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index 3a5eb61d29f..a896b23f69a 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -273,7 +273,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector ((SelectChannelEndPoint)_endp).setConnection(sslConnection); _endp=sslConnection.getSslEndPoint(); - sslConnection.setConnection(connection); + sslConnection.getSslEndPoint().setConnection(connection); LOG.debug("upgrade {} to {} for {}",this,sslConnection,connection); } @@ -404,11 +404,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector return _endp.isBlocking(); } - public boolean isBufferred() - { - return _endp.isBufferred(); - } - public boolean blockReadable(long millisecs) throws IOException { return _endp.blockReadable(millisecs); @@ -429,11 +424,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector return _endp.getTransport(); } - public boolean isBufferingInput() - { - return _endp.isBufferingInput(); - } - public boolean isBufferingOutput() { return _endp.isBufferingOutput(); diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 70cb9ad1f57..24758c91c01 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -299,7 +299,9 @@ public class HttpParser implements Parser ex=e; } - if (filled < 0 ) + if (filled>0) + progress++; + else if (filled < 0 ) { _persistent=false; @@ -1193,7 +1195,7 @@ public class HttpParser implements Parser { if (!_endp.isBlocking()) { - if (_endp.isBufferingInput() && parseNext()>0) + if (parseNext()>0) continue; if (!_endp.blockReadable(maxIdleTime)) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java index 1571ed9dafa..d11f1bc2303 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.io; import org.eclipse.jetty.util.thread.Timeout; -public interface AsyncEndPoint extends EndPoint +public interface AsyncEndPoint extends ConnectedEndPoint { /* ------------------------------------------------------------ */ /** @@ -50,14 +50,6 @@ public interface AsyncEndPoint extends EndPoint */ public boolean hasProgressed(); - - /* ------------------------------------------------------------ */ - public Connection getConnection(); - - /* ------------------------------------------------------------ */ - public void setConnection(Connection connection); - - /* ------------------------------------------------------------ */ /** */ diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java index fcae2f99fda..93c7940ba9d 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java @@ -363,24 +363,12 @@ public class ByteArrayEndPoint implements ConnectedEndPoint { } - /* ------------------------------------------------------------ */ - public boolean isBufferingInput() - { - return false; - } - /* ------------------------------------------------------------ */ public boolean isBufferingOutput() { return false; } - /* ------------------------------------------------------------ */ - public boolean isBufferred() - { - return false; - } - /* ------------------------------------------------------------ */ /** * @return the growOutput diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java index 6940991f387..0d388127ce8 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java @@ -122,13 +122,9 @@ public interface EndPoint */ public int getRemotePort(); - /* ------------------------------------------------------------ */ public boolean isBlocking(); - /* ------------------------------------------------------------ */ - public boolean isBufferred(); - /* ------------------------------------------------------------ */ public boolean blockReadable(long millisecs) throws IOException; @@ -144,12 +140,6 @@ public interface EndPoint */ public Object getTransport(); - /* ------------------------------------------------------------ */ - /** - * @return True if the endpoint has some buffered input data - */ - public boolean isBufferingInput(); - /* ------------------------------------------------------------ */ /** * @return True if the endpoint has some buffered output data @@ -163,7 +153,6 @@ public interface EndPoint */ public void flush() throws IOException; - /* ------------------------------------------------------------ */ /** Get the max idle time in ms. *

The max idle time is the time the endpoint can be idle before diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/bio/StreamEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/bio/StreamEndPoint.java index 2782ef8f8ed..98a85c7ba06 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/bio/StreamEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/bio/StreamEndPoint.java @@ -296,7 +296,6 @@ public class StreamEndPoint implements EndPoint _out=out; } - /* ------------------------------------------------------------ */ public void flush() throws IOException @@ -305,24 +304,12 @@ public class StreamEndPoint implements EndPoint _out.flush(); } - /* ------------------------------------------------------------ */ - public boolean isBufferingInput() - { - return false; - } - /* ------------------------------------------------------------ */ public boolean isBufferingOutput() { return false; } - /* ------------------------------------------------------------ */ - public boolean isBufferred() - { - return false; - } - /* ------------------------------------------------------------ */ public int getMaxIdleTime() { diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java index 63b00817e5e..058fd55f68a 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java @@ -510,25 +510,13 @@ public class ChannelEndPoint implements EndPoint throws IOException { } - - /* ------------------------------------------------------------ */ - public boolean isBufferingInput() - { - return false; - } - + /* ------------------------------------------------------------ */ public boolean isBufferingOutput() { return false; } - /* ------------------------------------------------------------ */ - public boolean isBufferred() - { - return false; - } - /* ------------------------------------------------------------ */ public int getMaxIdleTime() { diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 7972a19b341..59350938c36 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -41,9 +41,9 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo private final SelectorManager _manager; private SelectionKey _key; private final Runnable _handler = new Runnable() - { - public void run() { handle(); } - }; + { + public void run() { handle(); } + }; /** The desired value for {@link SelectionKey#interestOps()} */ private int _interestOps; @@ -65,7 +65,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo /** true if the last write operation succeed and wrote all offered bytes */ private volatile boolean _writable = true; - /** True if a thread has is blocked in {@link #blockReadable(long)} */ private boolean _readBlocked; @@ -630,8 +629,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo } finally { - dispatched=!undispatch(); - if (!_ishut && isInputShutdown() && isOpen()) { _ishut=true; @@ -639,10 +636,12 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo { _connection.onInputShutdown(); } + catch(ThreadDeath e) + { + throw e; + } catch(Throwable x) { - if (x instanceof ThreadDeath) - throw (ThreadDeath)x; LOG.warn("onInputShutdown failed", x); try{close();} catch(IOException e2){LOG.ignore(e2);} @@ -652,6 +651,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo updateKey(); } } + dispatched=!undispatch(); } } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index 6ce552281f8..259ffd5bae7 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -507,11 +507,12 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { LOG.ignore(e); } + catch(ThreadDeath e) + { + throw e; + } catch (Throwable e) { - if (e instanceof ThreadDeath) - throw (ThreadDeath)e; - if (isRunning()) LOG.warn(e); else diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index 14c04d25ce9..73b71676bf2 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -64,6 +64,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection private AsyncEndPoint _aEndp; private boolean _allowRenegotiate=true; private boolean _handshook; + private boolean _ishut; private boolean _oshut; /* ------------------------------------------------------------ */ @@ -98,12 +99,6 @@ public class SslConnection extends AbstractConnection implements AsyncConnection _aEndp=(AsyncEndPoint)endp; } - /* ------------------------------------------------------------ */ - public synchronized void setConnection(AsyncConnection connection) - { - _connection=connection; - } - /* ------------------------------------------------------------ */ public synchronized AsyncConnection getConnection() { @@ -198,7 +193,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection { // handle the delegate connection AsyncConnection next = (AsyncConnection)_connection.handle(); - if (next!=_connection && next==null) + if (next!=_connection && next!=null) { _connection=next; progress=true; @@ -211,6 +206,25 @@ public class SslConnection extends AbstractConnection implements AsyncConnection finally { releaseBuffers(); + + if (!_ishut && _sslEndPoint.isInputShutdown() && _sslEndPoint.isOpen()) + { + _ishut=true; + try + { + _connection.onInputShutdown(); + } + catch(ThreadDeath e) + { + throw e; + } + catch(Throwable x) + { + LOG.warn("onInputShutdown failed", x); + try{_endp.close();} + catch(IOException e2){LOG.ignore(e2);} + } + } } return this; @@ -681,18 +695,6 @@ public class SslConnection extends AbstractConnection implements AsyncConnection return _endp; } - public boolean isBufferingInput() - { - synchronized (this) - { - if (_unwrapBuf!=null && _unwrapBuf.hasContent()) - return true; - if (_inbound!=null && _inbound.hasContent()) - return true; - } - return false; - } - public boolean isBufferingOutput() { synchronized (this) @@ -781,11 +783,6 @@ public class SslConnection extends AbstractConnection implements AsyncConnection return false; } - public boolean isBufferred() - { - return true; - } - public int getMaxIdleTime() { return _aEndp.getMaxIdleTime(); diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointSslTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointSslTest.java index bb08e4de2b7..dad39ac900f 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointSslTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/nio/SelectChannelEndPointSslTest.java @@ -49,7 +49,7 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest SslConnection connection = new SslConnection(engine,endpoint); AsyncConnection delegate = super.newConnection(channel,connection.getSslEndPoint()); - connection.setConnection(delegate); + connection.getSslEndPoint().setConnection(delegate); return connection; } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java index 2f8b9c239dd..a55b8f1309a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java @@ -472,11 +472,12 @@ public abstract class AbstractHttpConnection extends AbstractConnection _request.setHandled(true); _response.sendError(e.getStatus(), e.getReason()); } + catch(ThreadDeath e) + { + throw e; + } catch (Throwable e) { - if (e instanceof ThreadDeath) - throw (ThreadDeath)e; - LOG.warn(String.valueOf(_uri),e); error=true; _request.setHandled(true); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java index 25e94d976ce..a2686185344 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java @@ -557,7 +557,7 @@ public class AsyncContinuation implements AsyncContext, Continuation protected void scheduleDispatch() { EndPoint endp=_connection.getEndPoint(); - if (!endp.isBlocking()) + if (endp instanceof AsyncEndPoint) { ((AsyncEndPoint)endp).asyncDispatch(); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java index 2cad672343f..217a3ab8eb6 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java @@ -309,12 +309,13 @@ public class HashSessionManager extends AbstractSessionManager } } } + catch(ThreadDeath e) + { + throw e; + } catch (Throwable t) { - if (t instanceof ThreadDeath) - throw ((ThreadDeath)t); - else - __log.warn("Problem scavenging sessions", t); + __log.warn("Problem scavenging sessions", t); } finally { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java index f3e1bf57370..fc8a8933ca9 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java @@ -299,21 +299,21 @@ public class JDBCSessionManager extends AbstractSessionManager } @Override - public void setAttribute (String name, Object value) + public void setAttribute (String name, Object value) { super.setAttribute(name, value); _dirty=true; } @Override - public void removeAttribute (String name) + public void removeAttribute (String name) { super.removeAttribute(name); _dirty=true; } @Override - protected void cookieSet() + protected void cookieSet() { _data.setCookieSet(_data.getAccessed()); } @@ -805,12 +805,13 @@ public class JDBCSessionManager extends AbstractSessionManager } } } + catch(ThreadDeath e) + { + throw e; + } catch (Throwable t) { - if (t instanceof ThreadDeath) - throw ((ThreadDeath)t); - else - LOG.warn("Problem expiring sessions", t); + LOG.warn("Problem expiring sessions", t); } finally { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java index 6f3de548f18..7fd6a27432b 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java @@ -559,7 +559,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements SslConnection connection = new SslConnection(engine,endpoint); AsyncConnection delegate = super.newConnection(channel,connection.getSslEndPoint()); - connection.setConnection(delegate); + connection.getSslEndPoint().setConnection(delegate); connection.setAllowRenegotiate(_sslContextFactory.isAllowRenegotiate()); return connection; } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java index 17e9cff811a..6e550c29be2 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java @@ -113,7 +113,7 @@ public class SslContextFactoryTest assertTrue(cf.getSslContext()!=null); } - @Test + @Test(expected=java.security.UnrecoverableKeyException.class) public void testResourceTsResourceKsWrongPW() throws Exception { Resource keystoreResource = Resource.newSystemResource("keystore"); @@ -126,18 +126,12 @@ public class SslContextFactoryTest cf.setKeyManagerPassword("wrong_keypwd"); cf.setTrustStorePassword("storepwd"); - try - { - ((StdErrLog)Log.getLogger(AbstractLifeCycle.class)).setHideStacks(true); - cf.start(); - Assert.fail(); - } - catch(java.security.UnrecoverableKeyException e) - { - } + ((StdErrLog)Log.getLogger(AbstractLifeCycle.class)).setHideStacks(true); + cf.start(); + Assert.fail(); } - @Test + @Test(expected=java.io.IOException.class) public void testResourceTsWrongPWResourceKs() throws Exception { Resource keystoreResource = Resource.newSystemResource("keystore"); @@ -150,14 +144,8 @@ public class SslContextFactoryTest cf.setKeyManagerPassword("keypwd"); cf.setTrustStorePassword("wrong_storepwd"); - try - { - ((StdErrLog)Log.getLogger(AbstractLifeCycle.class)).setHideStacks(true); - cf.start(); - Assert.fail(); - } - catch(IOException e) - { - } + ((StdErrLog)Log.getLogger(AbstractLifeCycle.class)).setHideStacks(true); + cf.start(); + Assert.fail(); } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java index 9196d6c65c1..710ace67388 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java @@ -131,7 +131,7 @@ public class WebSocketParserD13 implements WebSocketParser int filled=-1; // Loop until a datagram call back or can't fill anymore - while(!progress && (!_endp.isInputShutdown()||_endp.isBufferingInput()||_buffer.length()>0)) + while(!progress && (!_endp.isInputShutdown()||_buffer.length()>0)) { int available=_buffer.length(); diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index c14e8046964..17183308cec 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -1120,7 +1120,6 @@ public class XmlConfiguration @SuppressWarnings("unchecked") public static void main(final String[] args) throws Exception { - final AtomicReference exception = new AtomicReference(); AccessController.doPrivileged(new PrivilegedAction()