Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--VERSION.txt2
-rw-r--r--aggregates/jetty-all-compact3/pom.xml2
-rw-r--r--aggregates/jetty-all/pom.xml2
-rw-r--r--aggregates/jetty-websocket-all/pom.xml4
-rw-r--r--apache-jsp/pom.xml2
-rw-r--r--apache-jsp/src/main/config/modules/apache-jsp.mod5
-rw-r--r--apache-jstl/pom.xml2
-rw-r--r--apache-jstl/src/main/config/modules/apache-jstl.mod5
-rw-r--r--examples/async-rest/async-rest-jar/pom.xml2
-rw-r--r--examples/async-rest/async-rest-webapp/pom.xml2
-rw-r--r--examples/async-rest/pom.xml2
-rw-r--r--examples/embedded/pom.xml2
-rw-r--r--examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java3
-rw-r--r--examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java3
-rw-r--r--examples/pom.xml2
-rw-r--r--jetty-alpn/jetty-alpn-client/pom.xml2
-rw-r--r--jetty-alpn/jetty-alpn-server/pom.xml2
-rw-r--r--jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn.mod15
-rw-r--r--jetty-alpn/pom.xml2
-rw-r--r--jetty-annotations/pom.xml2
-rw-r--r--jetty-annotations/src/main/config/modules/annotations.mod8
-rw-r--r--jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java6
-rw-r--r--jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java2
-rw-r--r--jetty-ant/pom.xml2
-rw-r--r--jetty-cdi/cdi-core/pom.xml2
-rw-r--r--jetty-cdi/cdi-full-servlet/pom.xml2
-rw-r--r--jetty-cdi/cdi-servlet/pom.xml2
-rw-r--r--jetty-cdi/cdi-servlet/src/main/config/modules/cdi.mod5
-rw-r--r--jetty-cdi/cdi-websocket/pom.xml2
-rw-r--r--jetty-cdi/pom.xml2
-rw-r--r--jetty-cdi/test-cdi-webapp/pom.xml2
-rw-r--r--jetty-client/pom.xml40
-rw-r--r--jetty-client/src/main/config/modules/client.mod5
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java199
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java12
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java31
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java259
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpChannel.java5
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java22
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java169
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java2
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java1
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java1
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java2
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexConnectionPool.java302
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java128
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java213
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/ResponseNotifier.java4
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java3
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java19
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/api/Result.java8
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java54
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java15
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionUpgrader.java (renamed from jetty-start/src/main/java/org/eclipse/jetty/start/graph/Predicate.java)11
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTP.java7
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java11
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java8
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java4
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java36
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java5
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTimeoutTest.java2
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdown.java40
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java105
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java58
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java2
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java2
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTPTest.java90
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java4
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java7
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java14
-rw-r--r--jetty-client/src/test/resources/jetty-logging.properties1
-rw-r--r--jetty-continuation/pom.xml2
-rw-r--r--jetty-deploy/pom.xml2
-rw-r--r--jetty-deploy/src/main/config/modules/deploy.mod5
-rw-r--r--jetty-distribution/pom.xml7
-rw-r--r--jetty-distribution/src/main/resources/modules/hawtio.mod5
-rw-r--r--jetty-distribution/src/main/resources/modules/jamon.mod5
-rw-r--r--jetty-distribution/src/main/resources/modules/jminix.mod5
-rw-r--r--jetty-distribution/src/main/resources/modules/jolokia.mod5
-rw-r--r--jetty-distribution/src/main/resources/modules/jsp.mod5
-rw-r--r--jetty-distribution/src/main/resources/modules/jstl.mod5
-rw-r--r--jetty-distribution/src/main/resources/modules/setuid.mod7
-rw-r--r--jetty-fcgi/fcgi-client/pom.xml2
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpDestinationOverFCGI.java7
-rw-r--r--jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/MultiplexHttpDestinationOverFCGI.java7
-rw-r--r--jetty-fcgi/fcgi-server/pom.xml2
-rw-r--r--jetty-fcgi/fcgi-server/src/main/config/modules/fcgi.mod5
-rw-r--r--jetty-fcgi/pom.xml2
-rw-r--r--jetty-gcloud/gcloud-session-manager/pom.xml2
-rw-r--r--jetty-gcloud/gcloud-session-manager/src/main/config/etc/jetty-gcloud-sessions.xml3
-rw-r--r--jetty-gcloud/gcloud-session-manager/src/main/config/modules/gcloud-sessions.mod5
-rw-r--r--jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java2
-rw-r--r--jetty-gcloud/pom.xml2
-rw-r--r--jetty-http-spi/pom.xml2
-rw-r--r--jetty-http/pom.xml2
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/HttpHeader.java12
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java1
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java1
-rw-r--r--jetty-http2/http2-alpn-tests/pom.xml2
-rw-r--r--jetty-http2/http2-client/pom.xml2
-rw-r--r--jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java13
-rw-r--r--jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java78
-rw-r--r--jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java184
-rw-r--r--jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java18
-rw-r--r--jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java67
-rw-r--r--jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java26
-rw-r--r--jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java22
-rw-r--r--jetty-http2/http2-common/pom.xml2
-rw-r--r--jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java7
-rw-r--r--jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java34
-rw-r--r--jetty-http2/http2-hpack/pom.xml2
-rw-r--r--jetty-http2/http2-http-client-transport/pom.xml2
-rw-r--r--jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpDestinationOverHTTP2.java7
-rw-r--r--jetty-http2/http2-server/pom.xml2
-rw-r--r--jetty-http2/http2-server/src/main/config/modules/http2.mod6
-rw-r--r--jetty-http2/http2-server/src/main/config/modules/http2c.mod9
-rw-r--r--jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java42
-rw-r--r--jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java3
-rw-r--r--jetty-http2/pom.xml2
-rw-r--r--jetty-infinispan/pom.xml2
-rw-r--r--jetty-infinispan/src/main/config/modules/infinispan.mod6
-rw-r--r--jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java4
-rw-r--r--jetty-io/pom.xml2
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java260
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java161
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java310
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java4
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java2
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java2
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java61
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java267
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java72
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/SocketChannelEndPoint.java81
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java49
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java10
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java13
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java3
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java15
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/SelectorManagerTest.java17
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/SocketChannelEndPointTest.java (renamed from jetty-io/src/test/java/org/eclipse/jetty/io/ChannelEndPointTest.java)16
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java22
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java48
-rw-r--r--jetty-jaas/pom.xml2
-rw-r--r--jetty-jaas/src/main/config/modules/jaas.mod5
-rw-r--r--jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java2
-rw-r--r--jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java1
-rw-r--r--jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java2
-rw-r--r--jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/PropertyFileLoginModule.java3
-rw-r--r--jetty-jaspi/pom.xml2
-rw-r--r--jetty-jaspi/src/main/config/modules/jaspi.mod5
-rw-r--r--jetty-jaspi/src/test/java/org/eclipse/jetty/security/jaspi/JaspiTest.java44
-rw-r--r--jetty-jmx/pom.xml2
-rw-r--r--jetty-jmx/src/main/config/modules/jmx-remote.mod5
-rw-r--r--jetty-jmx/src/main/config/modules/jmx.mod6
-rw-r--r--jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java17
-rw-r--r--jetty-jndi/pom.xml2
-rw-r--r--jetty-jndi/src/main/config/modules/jndi.mod5
-rw-r--r--jetty-jspc-maven-plugin/pom.xml2
-rw-r--r--jetty-maven-plugin/pom.xml2
-rw-r--r--jetty-monitor/pom.xml2
-rw-r--r--jetty-monitor/src/main/config/modules/monitor.mod6
-rw-r--r--jetty-nosql/pom.xml2
-rw-r--r--jetty-nosql/src/main/config/modules/nosql.mod5
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java3
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java4
-rw-r--r--jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java2
-rw-r--r--jetty-osgi/jetty-osgi-alpn/pom.xml2
-rw-r--r--jetty-osgi/jetty-osgi-boot-jsp/pom.xml2
-rw-r--r--jetty-osgi/jetty-osgi-boot-warurl/pom.xml2
-rw-r--r--jetty-osgi/jetty-osgi-boot/pom.xml2
-rw-r--r--jetty-osgi/jetty-osgi-httpservice/pom.xml2
-rw-r--r--jetty-osgi/pom.xml2
-rw-r--r--jetty-osgi/test-jetty-osgi-context/pom.xml2
-rw-r--r--jetty-osgi/test-jetty-osgi-webapp/pom.xml2
-rw-r--r--jetty-osgi/test-jetty-osgi/pom.xml2
-rw-r--r--jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-testrealm.xml1
-rw-r--r--jetty-overlay-deployer/src/main/config/modules/overlay.mod6
-rw-r--r--jetty-plus/pom.xml2
-rw-r--r--jetty-plus/src/main/config/modules/plus.mod7
-rw-r--r--jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java2
-rw-r--r--jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java2
-rw-r--r--jetty-plus/src/main/java/org/eclipse/jetty/plus/security/DataSourceLoginService.java120
-rw-r--r--jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java3
-rw-r--r--jetty-proxy/pom.xml2
-rw-r--r--jetty-proxy/src/main/config/modules/proxy.mod6
-rw-r--r--jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java54
-rw-r--r--jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java7
-rw-r--r--jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java26
-rw-r--r--jetty-quickstart/pom.xml2
-rw-r--r--jetty-quickstart/src/main/config/modules/quickstart.mod6
-rw-r--r--jetty-rewrite/pom.xml2
-rw-r--r--jetty-rewrite/src/main/config/modules/rewrite.mod6
-rw-r--r--jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml1
-rw-r--r--jetty-runner/pom.xml2
-rw-r--r--jetty-security/pom.xml2
-rw-r--r--jetty-security/src/main/config/modules/security.mod5
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/AbstractLoginService.java248
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java104
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java118
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/MappedLoginService.java375
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java49
-rw-r--r--jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java6
-rw-r--r--jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java3
-rw-r--r--jetty-security/src/test/java/org/eclipse/jetty/security/SpecExampleConstraintTest.java5
-rw-r--r--jetty-security/src/test/java/org/eclipse/jetty/security/TestLoginService.java69
-rw-r--r--jetty-server/pom.xml2
-rw-r--r--jetty-server/src/main/config/etc/jetty-http-forwarded.xml17
-rw-r--r--jetty-server/src/main/config/etc/jetty.xml5
-rw-r--r--jetty-server/src/main/config/modules/continuation.mod7
-rw-r--r--jetty-server/src/main/config/modules/debug.mod7
-rw-r--r--jetty-server/src/main/config/modules/debuglog.mod6
-rw-r--r--jetty-server/src/main/config/modules/ext.mod6
-rw-r--r--jetty-server/src/main/config/modules/gzip.mod7
-rw-r--r--jetty-server/src/main/config/modules/home-base-warning.mod6
-rw-r--r--jetty-server/src/main/config/modules/http-forwarded.mod20
-rw-r--r--jetty-server/src/main/config/modules/http.mod7
-rw-r--r--jetty-server/src/main/config/modules/https.mod6
-rw-r--r--jetty-server/src/main/config/modules/ipaccess.mod6
-rw-r--r--jetty-server/src/main/config/modules/jdbc-sessions.mod6
-rw-r--r--jetty-server/src/main/config/modules/jvm.mod3
-rw-r--r--jetty-server/src/main/config/modules/lowresources.mod7
-rw-r--r--jetty-server/src/main/config/modules/proxy-protocol-ssl.mod9
-rw-r--r--jetty-server/src/main/config/modules/proxy-protocol.mod10
-rw-r--r--jetty-server/src/main/config/modules/requestlog.mod5
-rw-r--r--jetty-server/src/main/config/modules/resources.mod7
-rw-r--r--jetty-server/src/main/config/modules/server.mod5
-rw-r--r--jetty-server/src/main/config/modules/ssl.mod7
-rw-r--r--jetty-server/src/main/config/modules/stats.mod6
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java6
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java2
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/DebugListener.java1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java63
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java225
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java317
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java31
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java15
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/NetworkTrafficServerConnector.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java437
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilder.java198
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/PushBuilderImpl.java122
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Request.java47
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/RequestLogCollection.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Response.java200
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java24
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java15
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/SocketCustomizationListener.java8
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/AbstractHandler.java32
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java35
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/DebugHandler.java1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java217
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerCollection.java1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java2
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java2
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/AbstractHttpTest.java40
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/AsyncRequestReadTest.java10
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java1
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java2
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ExtendedServerTest.java3
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToAsyncCommitBadBehaviourTest.java2
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToAsyncCommitTest.java44
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpManyWaysToCommitTest.java52
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java42
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java2
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java2
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java24
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ThreadStarvationTest.java10
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/handler/DebugHandlerTest.java5
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java1
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SniSslConnectionFactoryTest.java10
-rw-r--r--jetty-servlet/pom.xml8
-rw-r--r--jetty-servlet/src/main/config/modules/servlet.mod5
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/BaseHolder.java2
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java73
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java17
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java2
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java247
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java24
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java4
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/listener/ELContextCleaner.java2
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java307
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncListenerTest.java813
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java195
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletTest.java89
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ErrorPageTest.java1
-rw-r--r--jetty-servlet/src/test/resources/jetty-logging.properties3
-rw-r--r--jetty-servlets/pom.xml2
-rw-r--r--jetty-servlets/src/main/config/modules/servlets.mod9
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java19
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/ThreadStarvationTest.java5
-rw-r--r--jetty-spring/pom.xml2
-rw-r--r--jetty-spring/src/main/config/modules/spring.mod6
-rw-r--r--jetty-start/dependency-reduced-pom.xml83
-rw-r--r--jetty-start/pom.xml34
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java198
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Licensing.java2
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Main.java94
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Module.java148
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/ModuleGraphWriter.java34
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java281
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java18
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/builders/StartDirBuilder.java6
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/builders/StartIniBuilder.java6
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/fileinits/MavenLocalRepoFileInitializer.java4
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/fileinits/UriFileInitializer.java2
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/AllPredicate.java31
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/AndPredicate.java46
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/AnySelectionPredicate.java28
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/CriteriaPredicate.java45
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/CriteriaSetPredicate.java71
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/Graph.java503
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/GraphException.java36
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/NamePredicate.java35
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/Node.java179
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/NodeDepthComparator.java43
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/OnlyTransitivePredicate.java41
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/RegexNamePredicate.java40
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/Selection.java129
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/graph/UniqueCriteriaPredicate.java63
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java11
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ModuleGraphWriterTest.java2
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ModuleTest.java4
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java103
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/PropertyPassingTest.java2
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/TestBadUseCases.java3
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/graph/NodeTest.java75
-rw-r--r--jetty-unixsocket/.gitignore1
-rw-r--r--jetty-unixsocket/pom.xml43
-rw-r--r--jetty-unixsocket/src/main/config/etc/jetty-unixsocket-forwarded.xml17
-rw-r--r--jetty-unixsocket/src/main/config/etc/jetty-unixsocket-http.xml13
-rw-r--r--jetty-unixsocket/src/main/config/etc/jetty-unixsocket-http2c.xml18
-rw-r--r--jetty-unixsocket/src/main/config/etc/jetty-unixsocket-proxy-protocol.xml10
-rw-r--r--jetty-unixsocket/src/main/config/etc/jetty-unixsocket-secure.xml11
-rw-r--r--jetty-unixsocket/src/main/config/etc/jetty-unixsocket.xml25
-rw-r--r--jetty-unixsocket/src/main/config/modules/unixsocket-forwarded.mod24
-rw-r--r--jetty-unixsocket/src/main/config/modules/unixsocket-http.mod14
-rw-r--r--jetty-unixsocket/src/main/config/modules/unixsocket-http2c.mod21
-rw-r--r--jetty-unixsocket/src/main/config/modules/unixsocket-proxy-protocol.mod15
-rw-r--r--jetty-unixsocket/src/main/config/modules/unixsocket-secure.mod17
-rw-r--r--jetty-unixsocket/src/main/config/modules/unixsocket.mod54
-rw-r--r--jetty-unixsocket/src/main/java/org/eclipse/jetty/unixsocket/UnixSocketConnector.java436
-rw-r--r--jetty-unixsocket/src/main/java/org/eclipse/jetty/unixsocket/UnixSocketEndPoint.java74
-rw-r--r--jetty-unixsocket/src/test/java/org/eclipse/jetty/unixsocket/UnixSocketClient.java57
-rw-r--r--jetty-unixsocket/src/test/java/org/eclipse/jetty/unixsocket/UnixSocketServer.java63
-rwxr-xr-xjetty-unixsocket/src/test/resources/haproxybin0 -> 4937496 bytes
-rw-r--r--jetty-unixsocket/src/test/resources/jetty-logging.properties7
-rw-r--r--jetty-util-ajax/pom.xml2
-rw-r--r--jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java2
-rw-r--r--jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONCollectionConvertor.java2
-rw-r--r--jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java4
-rw-r--r--jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactory.java4
-rw-r--r--jetty-util/pom.xml2
-rw-r--r--jetty-util/src/main/config/modules/logging.mod6
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/Callback.java118
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java146
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/MultiPartInputStreamParser.java9
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/Promise.java69
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/TopologicalSort.java185
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java12
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/log/JavaUtilLog.java2
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java4
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java4
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/security/Credential.java40
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutionStrategy.java2
-rw-r--r--jetty-util/src/test/java/org/eclipse/jetty/util/TopologicalSortTest.java203
-rw-r--r--jetty-util/src/test/java/org/eclipse/jetty/util/security/CredentialTest.java79
-rw-r--r--jetty-webapp/pom.xml2
-rw-r--r--jetty-webapp/src/main/config/modules/webapp.mod6
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/AbsoluteOrdering.java95
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java39
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/DiscoveredAnnotation.java2
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java7
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaData.java20
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/Ordering.java464
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/RelativeOrdering.java144
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java2
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java48
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java3
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java62
-rw-r--r--jetty-webapp/src/test/java/org/eclipse/jetty/webapp/OrderingTest.java22
-rw-r--r--jetty-websocket/javax-websocket-client-impl/pom.xml2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/pom.xml2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/config/modules/websocket.mod5
-rw-r--r--jetty-websocket/pom.xml2
-rw-r--r--jetty-websocket/websocket-api/pom.xml2
-rw-r--r--jetty-websocket/websocket-client/pom.xml2
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java29
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java14
-rw-r--r--jetty-websocket/websocket-common/pom.xml2
-rw-r--r--jetty-websocket/websocket-server/pom.xml2
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java2
-rw-r--r--jetty-websocket/websocket-servlet/pom.xml2
-rw-r--r--jetty-xml/pom.xml2
-rw-r--r--jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java16
-rw-r--r--pom.xml5
-rw-r--r--tests/pom.xml2
-rw-r--r--tests/test-continuation/pom.xml2
-rw-r--r--tests/test-continuation/src/test/java/org/eclipse/jetty/continuation/ContinuationsTest.java2
-rw-r--r--tests/test-http-client-transport/pom.xml2
-rw-r--r--tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/AbstractTest.java29
-rw-r--r--tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientLoadTest.java (renamed from jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientLoadTest.java)180
-rw-r--r--tests/test-integration/pom.xml2
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java45
-rw-r--r--tests/test-jmx/jmx-webapp-it/pom.xml2
-rw-r--r--tests/test-jmx/jmx-webapp-it/src/test/java/org/eclipse/jetty/test/jmx/JmxIT.java2
-rw-r--r--tests/test-jmx/jmx-webapp/pom.xml2
-rw-r--r--tests/test-jmx/pom.xml2
-rw-r--r--tests/test-loginservice/pom.xml2
-rw-r--r--tests/test-loginservice/src/test/java/org/eclipse/jetty/DataSourceLoginServiceTest.java6
-rw-r--r--tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java2
-rw-r--r--tests/test-quickstart/pom.xml2
-rw-r--r--tests/test-sessions/pom.xml2
-rw-r--r--tests/test-sessions/test-gcloud-sessions/pom.xml2
-rw-r--r--tests/test-sessions/test-hash-sessions/pom.xml2
-rw-r--r--tests/test-sessions/test-infinispan-sessions/pom.xml2
-rw-r--r--tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java16
-rw-r--r--tests/test-sessions/test-jdbc-sessions/pom.xml6
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClientCrossContextSessionTest.java13
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java9
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ForwardedSessionTest.java7
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java12
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/InvalidationSessionTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java24
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LastAccessTimeTest.java12
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/LocalSessionScavengingTest.java12
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ModifyMaxInactiveIntervalTest.java8
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/NewSessionTest.java12
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/OrphanedSessionTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ProxySerializationTest.java8
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java13
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java8
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SaveIntervalTest.java7
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ServerCrossContextSessionTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionExpiryTest.java15
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionInvalidateAndCreateTest.java9
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionMigrationTest.java11
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java14
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionValueSavingTest.java30
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/StopSessionManagerPreserveSessionTest.java14
-rw-r--r--tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java13
-rw-r--r--tests/test-sessions/test-mongodb-sessions/pom.xml2
-rw-r--r--tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java6
-rw-r--r--tests/test-sessions/test-sessions-common/pom.xml2
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java30
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java35
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java19
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSameNodeLoadTest.java2
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java6
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java4
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java10
-rw-r--r--tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java1
-rw-r--r--tests/test-webapps/pom.xml2
-rw-r--r--tests/test-webapps/test-jaas-webapp/pom.xml2
-rw-r--r--tests/test-webapps/test-jetty-webapp/pom.xml2
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/assembly/embedded-jetty-web-for-webbundle.xml3
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/etc/test-realm.xml2
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml5
-rw-r--r--tests/test-webapps/test-jndi-webapp/pom.xml2
-rw-r--r--tests/test-webapps/test-mock-resources/pom.xml2
-rw-r--r--tests/test-webapps/test-proxy-webapp/pom.xml2
-rw-r--r--tests/test-webapps/test-servlet-spec/pom.xml2
-rw-r--r--tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml2
-rw-r--r--tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml2
-rw-r--r--tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml2
-rw-r--r--tests/test-webapps/test-webapp-rfc2616/pom.xml2
466 files changed, 8409 insertions, 7287 deletions
diff --git a/VERSION.txt b/VERSION.txt
index 8457779e17..57dd1679c5 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1,4 +1,4 @@
-jetty-9.3.7-SNAPSHOT
+jetty-9.4.0-SNAPSHOT
jetty-9.3.6.v20151106 - 06 November 2015
+ 419966 Add ContentProvider that submits multipart/form-data.
diff --git a/aggregates/jetty-all-compact3/pom.xml b/aggregates/jetty-all-compact3/pom.xml
index 0a23810f4f..c323c8bdcd 100644
--- a/aggregates/jetty-all-compact3/pom.xml
+++ b/aggregates/jetty-all-compact3/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/aggregates/jetty-all/pom.xml b/aggregates/jetty-all/pom.xml
index 01c6a773ff..3e0e91ef96 100644
--- a/aggregates/jetty-all/pom.xml
+++ b/aggregates/jetty-all/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/aggregates/jetty-websocket-all/pom.xml b/aggregates/jetty-websocket-all/pom.xml
index 3c9c2689b8..ee65e2390c 100644
--- a/aggregates/jetty-websocket-all/pom.xml
+++ b/aggregates/jetty-websocket-all/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.1.0-SNAPSHOT</version>
+ <version>9.1.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -24,7 +24,7 @@
</goals>
<configuration>
<excludes>**/MANIFEST.MF</excludes>
- <excludeGroupIds>org.slf4j,org.eclipse.jetty.orbit,org.mortbay.jetty.alpn</excludeGroupIds>
+ <excludeGroupIds>javax.annotations,org.objectweb.asm,javax.servlet,org.slf4j,org.eclipse.jetty.orbit,org.mortbay.jetty.npn</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
diff --git a/apache-jsp/pom.xml b/apache-jsp/pom.xml
index 3bc74c2a81..66ecfd4fcf 100644
--- a/apache-jsp/pom.xml
+++ b/apache-jsp/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apache-jsp</artifactId>
diff --git a/apache-jsp/src/main/config/modules/apache-jsp.mod b/apache-jsp/src/main/config/modules/apache-jsp.mod
index 5123670cb0..c816f61c04 100644
--- a/apache-jsp/src/main/config/modules/apache-jsp.mod
+++ b/apache-jsp/src/main/config/modules/apache-jsp.mod
@@ -1,6 +1,5 @@
-#
-# Apache JSP Module
-#
+[description]
+Enables use of the apache implementation of JSP
[name]
apache-jsp
diff --git a/apache-jstl/pom.xml b/apache-jstl/pom.xml
index 89c935b73b..3396c849aa 100644
--- a/apache-jstl/pom.xml
+++ b/apache-jstl/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apache-jstl</artifactId>
diff --git a/apache-jstl/src/main/config/modules/apache-jstl.mod b/apache-jstl/src/main/config/modules/apache-jstl.mod
index e4a9001a2a..d7c703e7ea 100644
--- a/apache-jstl/src/main/config/modules/apache-jstl.mod
+++ b/apache-jstl/src/main/config/modules/apache-jstl.mod
@@ -1,6 +1,5 @@
-#
-# Apache JSTL
-#
+[description]
+Enables the apache version of JSTL
[name]
apache-jstl
diff --git a/examples/async-rest/async-rest-jar/pom.xml b/examples/async-rest/async-rest-jar/pom.xml
index ad1a25c49b..1d3dc19692 100644
--- a/examples/async-rest/async-rest-jar/pom.xml
+++ b/examples/async-rest/async-rest-jar/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>example-async-rest</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.example-async-rest</groupId>
diff --git a/examples/async-rest/async-rest-webapp/pom.xml b/examples/async-rest/async-rest-webapp/pom.xml
index 5e0769e4f2..52b08a7784 100644
--- a/examples/async-rest/async-rest-webapp/pom.xml
+++ b/examples/async-rest/async-rest-webapp/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>example-async-rest</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.example-async-rest</groupId>
diff --git a/examples/async-rest/pom.xml b/examples/async-rest/pom.xml
index 26b14116a6..3a3f023f0d 100644
--- a/examples/async-rest/pom.xml
+++ b/examples/async-rest/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.examples</groupId>
<artifactId>examples-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/examples/embedded/pom.xml b/examples/embedded/pom.xml
index 1cf806909e..93806b92a4 100644
--- a/examples/embedded/pom.xml
+++ b/examples/embedded/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.examples</groupId>
<artifactId>examples-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java
index e6882556ad..312d0adc7f 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java
@@ -52,9 +52,8 @@ public class OneWebApp
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
File warFile = new File(
- "../../jetty-distribution/target/distribution/test/webapps/test/");
+ "../../tests/test-jmx/jmx-webapp/target/jmx-webapp");
webapp.setWar(warFile.getAbsolutePath());
- webapp.addAliasCheck(new AllowSymLinkAliasChecker());
// A WebAppContext is a ContextHandler as well so it needs to be set to
// the server so it is aware of where to send the appropriate requests.
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java
index f391be7e02..58c177a59f 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java
@@ -62,6 +62,7 @@ public class OneWebAppWithJsp
+ warFile.getAbsolutePath() );
}
webapp.setWar( warFile.getAbsolutePath() );
+ webapp.setExtractWAR(true);
// This webapp will use jsps and jstl. We need to enable the
// AnnotationConfiguration in order to correctly
@@ -100,6 +101,8 @@ public class OneWebAppWithJsp
// Start things up!
server.start();
+
+ server.dumpStdErr();
// The use of server.join() the will make the current thread join and
// wait until the server is done executing.
diff --git a/examples/pom.xml b/examples/pom.xml
index 641240cd77..33883db3bc 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.eclipse.jetty.examples</groupId>
diff --git a/jetty-alpn/jetty-alpn-client/pom.xml b/jetty-alpn/jetty-alpn-client/pom.xml
index e0466a9b3c..5128921e97 100644
--- a/jetty-alpn/jetty-alpn-client/pom.xml
+++ b/jetty-alpn/jetty-alpn-client/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-alpn-client</artifactId>
diff --git a/jetty-alpn/jetty-alpn-server/pom.xml b/jetty-alpn/jetty-alpn-server/pom.xml
index 8aaae0fa10..98fc5250fd 100644
--- a/jetty-alpn/jetty-alpn-server/pom.xml
+++ b/jetty-alpn/jetty-alpn-server/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-alpn-server</artifactId>
diff --git a/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn.mod b/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn.mod
index 7928e64928..10997501ff 100644
--- a/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn.mod
+++ b/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn.mod
@@ -1,11 +1,10 @@
-# ALPN is provided via a -Xbootclasspath that modifies the secure connections
-# in java to support the ALPN layer needed for HTTP/2.
-#
-# This modification has a tight dependency on specific recent updates of
-# Java 1.7 and Java 1.8 (Java versions prior to 1.7u40 are not supported).
-#
-# The alpn module will use an appropriate alpn-boot jar for your
-# specific version of Java.
+[description]
+Enables the ALPN extension to TLS(SSL) by adding modified classes to
+the JVM bootpath.
+This modification has a tight dependency on specific recent updates of
+Java 1.7 and Java 1.8 (Java versions prior to 1.7u40 are not supported).
+The alpn module will use an appropriate alpn-boot jar for your
+specific version of Java.
#
# IMPORTANT: Versions of Java that exist after this module was created are
# not guaranteed to work with existing alpn-boot jars, and might
diff --git a/jetty-alpn/pom.xml b/jetty-alpn/pom.xml
index 888e31b14d..4157d6c746 100644
--- a/jetty-alpn/pom.xml
+++ b/jetty-alpn/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-alpn-parent</artifactId>
diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml
index 842aa11f76..8f432097d1 100644
--- a/jetty-annotations/pom.xml
+++ b/jetty-annotations/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-annotations</artifactId>
diff --git a/jetty-annotations/src/main/config/modules/annotations.mod b/jetty-annotations/src/main/config/modules/annotations.mod
index 65e4654127..4217be54fb 100644
--- a/jetty-annotations/src/main/config/modules/annotations.mod
+++ b/jetty-annotations/src/main/config/modules/annotations.mod
@@ -1,15 +1,11 @@
-#
-# Jetty Annotation Scanning Module
-#
+[description]
+Enables Annotation scanning for deployed webapplications.
[depend]
-# Annotations needs plus, and jndi features
plus
[lib]
-# Annotations needs jetty annotation jars
lib/jetty-annotations-${jetty.version}.jar
-# Need annotation processing jars too
lib/annotations/*.jar
[xml]
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
index 05bebef984..60e42d8c8e 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
@@ -558,7 +558,7 @@ public class AnnotationParser
if (!isParsed(className) || resolver.shouldOverride(className))
{
className = className.replace('.', '/')+".class";
- URL resource = Loader.getResource(this.getClass(), className);
+ URL resource = Loader.getResource(className);
if (resource!= null)
{
Resource r = Resource.newResource(resource);
@@ -593,7 +593,7 @@ public class AnnotationParser
if (!isParsed(cz.getName()) || resolver.shouldOverride(cz.getName()))
{
String nameAsResource = cz.getName().replace('.', '/')+".class";
- URL resource = Loader.getResource(this.getClass(), nameAsResource);
+ URL resource = Loader.getResource(nameAsResource);
if (resource!= null)
{
Resource r = Resource.newResource(resource);
@@ -652,7 +652,7 @@ public class AnnotationParser
if ((resolver == null) || (!resolver.isExcluded(s) && (!isParsed(s) || resolver.shouldOverride(s))))
{
s = s.replace('.', '/')+".class";
- URL resource = Loader.getResource(this.getClass(), s);
+ URL resource = Loader.getResource(s);
if (resource!= null)
{
Resource r = Resource.newResource(resource);
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java
index 6faa9590e3..7cb4dfd861 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java
@@ -201,7 +201,7 @@ public class Util
}
case Type.OBJECT:
{
- return (Loader.loadClass(null, t.getClassName()));
+ return (Loader.loadClass(t.getClassName()));
}
case Type.SHORT:
{
diff --git a/jetty-ant/pom.xml b/jetty-ant/pom.xml
index e9160bf0de..3d97aac00f 100644
--- a/jetty-ant/pom.xml
+++ b/jetty-ant/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-ant</artifactId>
diff --git a/jetty-cdi/cdi-core/pom.xml b/jetty-cdi/cdi-core/pom.xml
index 4ba4e5fcba..ea31517183 100644
--- a/jetty-cdi/cdi-core/pom.xml
+++ b/jetty-cdi/cdi-core/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-core</artifactId>
diff --git a/jetty-cdi/cdi-full-servlet/pom.xml b/jetty-cdi/cdi-full-servlet/pom.xml
index 0c4ef63d11..f8509144da 100644
--- a/jetty-cdi/cdi-full-servlet/pom.xml
+++ b/jetty-cdi/cdi-full-servlet/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-full-servlet</artifactId>
diff --git a/jetty-cdi/cdi-servlet/pom.xml b/jetty-cdi/cdi-servlet/pom.xml
index da05a98b98..e3b0593490 100644
--- a/jetty-cdi/cdi-servlet/pom.xml
+++ b/jetty-cdi/cdi-servlet/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-servlet</artifactId>
diff --git a/jetty-cdi/cdi-servlet/src/main/config/modules/cdi.mod b/jetty-cdi/cdi-servlet/src/main/config/modules/cdi.mod
index ebffb55aed..68a926d62f 100644
--- a/jetty-cdi/cdi-servlet/src/main/config/modules/cdi.mod
+++ b/jetty-cdi/cdi-servlet/src/main/config/modules/cdi.mod
@@ -1,6 +1,5 @@
-#
-# [EXPERIMENTAL] CDI / Weld Jetty module
-#
+[description]
+Experimental CDI/Weld integration
[depend]
deploy
diff --git a/jetty-cdi/cdi-websocket/pom.xml b/jetty-cdi/cdi-websocket/pom.xml
index 409f21c161..07c6a5a7c3 100644
--- a/jetty-cdi/cdi-websocket/pom.xml
+++ b/jetty-cdi/cdi-websocket/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-websocket</artifactId>
diff --git a/jetty-cdi/pom.xml b/jetty-cdi/pom.xml
index a59c9a8867..b1cd311412 100644
--- a/jetty-cdi/pom.xml
+++ b/jetty-cdi/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.cdi</groupId>
diff --git a/jetty-cdi/test-cdi-webapp/pom.xml b/jetty-cdi/test-cdi-webapp/pom.xml
index 9bd9001366..931bfc9fc9 100644
--- a/jetty-cdi/test-cdi-webapp/pom.xml
+++ b/jetty-cdi/test-cdi-webapp/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-cdi-webapp</artifactId>
diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml
index 0dbd98b6c1..9450cdcc99 100644
--- a/jetty-client/pom.xml
+++ b/jetty-client/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -48,6 +48,44 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.4.2</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <shadedClassifierName>hybrid</shadedClassifierName>
+ <artifactSet>
+ <includes>
+ <include>org.eclipse.jetty:jetty-http</include>
+ <include>org.eclipse.jetty:jetty-io</include>
+ <include>org.eclipse.jetty:jetty-util</include>
+ </includes>
+ </artifactSet>
+ <relocations>
+ <relocation>
+ <pattern>org.eclipse.jetty.http</pattern>
+ <shadedPattern>org.eclipse.jetty.client.shaded.http</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.eclipse.jetty.io</pattern>
+ <shadedPattern>org.eclipse.jetty.client.shaded.io</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.eclipse.jetty.util</pattern>
+ <shadedPattern>org.eclipse.jetty.client.shaded.util</shadedPattern>
+ </relocation>
+ </relocations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/jetty-client/src/main/config/modules/client.mod b/jetty-client/src/main/config/modules/client.mod
index 39b58d4e69..e9d13c8c68 100644
--- a/jetty-client/src/main/config/modules/client.mod
+++ b/jetty-client/src/main/config/modules/client.mod
@@ -1,6 +1,5 @@
-#
-# Client Feature
-#
+[description]
+Adds the Jetty HTTP client to the server classpath.
[lib]
lib/jetty-client-${jetty.version}.jar
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java
new file mode 100644
index 0000000000..d3b13b668d
--- /dev/null
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java
@@ -0,0 +1,199 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.client;
+
+import java.util.Collection;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.eclipse.jetty.client.api.Connection;
+import org.eclipse.jetty.client.api.Destination;
+import org.eclipse.jetty.util.Callback;
+import org.eclipse.jetty.util.Promise;
+import org.eclipse.jetty.util.annotation.ManagedAttribute;
+import org.eclipse.jetty.util.component.ContainerLifeCycle;
+import org.eclipse.jetty.util.component.Dumpable;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+
+public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
+{
+ private static final Logger LOG = Log.getLogger(AbstractConnectionPool.class);
+
+ private final AtomicBoolean closed = new AtomicBoolean();
+ private final AtomicInteger connectionCount = new AtomicInteger();
+ private final Destination destination;
+ private final int maxConnections;
+ private final Callback requester;
+
+ protected AbstractConnectionPool(Destination destination, int maxConnections, Callback requester)
+ {
+ this.destination = destination;
+ this.maxConnections = maxConnections;
+ this.requester = requester;
+ }
+
+ @ManagedAttribute(value = "The max number of connections", readonly = true)
+ public int getMaxConnectionCount()
+ {
+ return maxConnections;
+ }
+
+ @ManagedAttribute(value = "The number of connections", readonly = true)
+ public int getConnectionCount()
+ {
+ return connectionCount.get();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return connectionCount.get() == 0;
+ }
+
+ @Override
+ public boolean isClosed()
+ {
+ return closed.get();
+ }
+
+ @Override
+ public Connection acquire()
+ {
+ Connection connection = activate();
+ if (connection == null)
+ connection = tryCreate();
+ return connection;
+ }
+
+ private Connection tryCreate()
+ {
+ while (true)
+ {
+ int current = getConnectionCount();
+ final int next = current + 1;
+
+ if (next > maxConnections)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Max connections {}/{} reached", current, maxConnections);
+ // Try again the idle connections
+ return activate();
+ }
+
+ if (connectionCount.compareAndSet(current, next))
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Connection {}/{} creation", next, maxConnections);
+
+ destination.newConnection(new Promise<Connection>()
+ {
+ @Override
+ public void succeeded(Connection connection)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection);
+ onCreated(connection);
+ proceed();
+ }
+
+ @Override
+ public void failed(Throwable x)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Connection " + next + "/" + maxConnections + " creation failed", x);
+ connectionCount.decrementAndGet();
+ requester.failed(x);
+ }
+ });
+
+ // Try again the idle connections
+ return activate();
+ }
+ }
+ }
+
+ protected abstract void onCreated(Connection connection);
+
+ protected void proceed()
+ {
+ requester.succeeded();
+ }
+
+ protected abstract Connection activate();
+
+ protected Connection active(Connection connection)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Connection active {}", connection);
+ acquired(connection);
+ return connection;
+ }
+
+ protected void acquired(Connection connection)
+ {
+ }
+
+ protected boolean idle(Connection connection, boolean close)
+ {
+ if (close)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Connection idle close {}", connection);
+ return false;
+ }
+ else
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Connection idle {}", connection);
+ return true;
+ }
+ }
+
+ protected void released(Connection connection)
+ {
+ }
+
+ protected void removed(Connection connection)
+ {
+ int pooled = connectionCount.decrementAndGet();
+ if (LOG.isDebugEnabled())
+ LOG.debug("Connection removed {} - pooled: {}", connection, pooled);
+ }
+
+ @Override
+ public void close()
+ {
+ if (closed.compareAndSet(false, true))
+ {
+ connectionCount.set(0);
+ }
+ }
+
+ protected void close(Collection<Connection> connections)
+ {
+ connections.forEach(Connection::close);
+ }
+
+ @Override
+ public String dump()
+ {
+ return ContainerLifeCycle.dump(this);
+ }
+}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java
index f4e9d90f7e..81959031f3 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.SocketException;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.Map;
@@ -31,6 +32,7 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
+import org.eclipse.jetty.io.SocketChannelEndPoint;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
@@ -173,13 +175,15 @@ public abstract class AbstractHttpClientTransport extends ContainerLifeCycle imp
}
@Override
- protected EndPoint newEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey key)
+ protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key)
{
- return new SelectChannelEndPoint(channel, selector, key, getScheduler(), client.getIdleTimeout());
+ SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler());
+ endp.setIdleTimeout(client.getIdleTimeout());
+ return endp;
}
@Override
- public org.eclipse.jetty.io.Connection newConnection(SocketChannel channel, EndPoint endPoint, Object attachment) throws IOException
+ public org.eclipse.jetty.io.Connection newConnection(SelectableChannel channel, EndPoint endPoint, Object attachment) throws IOException
{
@SuppressWarnings("unchecked")
Map<String, Object> context = (Map<String, Object>)attachment;
@@ -188,7 +192,7 @@ public abstract class AbstractHttpClientTransport extends ContainerLifeCycle imp
}
@Override
- protected void connectionFailed(SocketChannel channel, Throwable x, Object attachment)
+ protected void connectionFailed(SelectableChannel channel, Throwable x, Object attachment)
{
@SuppressWarnings("unchecked")
Map<String, Object> context = (Map<String, Object>)attachment;
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
index fc95421a0b..029a388d33 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
@@ -18,17 +18,24 @@
package org.eclipse.jetty.client;
-import org.eclipse.jetty.client.api.Destination;
-import org.eclipse.jetty.util.Callback;
-
-/**
- * @deprecated use {@link DuplexConnectionPool} instead
- */
-@Deprecated
-public class ConnectionPool extends DuplexConnectionPool
+import java.io.Closeable;
+
+import org.eclipse.jetty.client.api.Connection;
+
+public interface ConnectionPool extends Closeable
{
- public ConnectionPool(Destination destination, int maxConnections, Callback requester)
- {
- super(destination, maxConnections, requester);
- }
+ boolean isActive(Connection connection);
+
+ boolean isEmpty();
+
+ boolean isClosed();
+
+ Connection acquire();
+
+ boolean release(Connection connection);
+
+ boolean remove(Connection connection);
+
+ @Override
+ void close();
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java
index dcf74709ce..c22966c372 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/DuplexConnectionPool.java
@@ -18,21 +18,20 @@
package org.eclipse.jetty.client;
-import java.io.Closeable;
import java.io.IOException;
+import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Deque;
+import java.util.HashSet;
import java.util.List;
import java.util.Queue;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.Destination;
-import org.eclipse.jetty.util.BlockingArrayQueue;
import org.eclipse.jetty.util.Callback;
-import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
@@ -42,31 +41,29 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Sweeper;
@ManagedObject("The connection pool")
-public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepable
+public class DuplexConnectionPool extends AbstractConnectionPool implements Dumpable, Sweeper.Sweepable
{
private static final Logger LOG = Log.getLogger(DuplexConnectionPool.class);
- private final AtomicInteger connectionCount = new AtomicInteger();
private final ReentrantLock lock = new ReentrantLock();
- private final Destination destination;
- private final int maxConnections;
- private final Callback requester;
private final Deque<Connection> idleConnections;
- private final Queue<Connection> activeConnections;
+ private final Set<Connection> activeConnections;
public DuplexConnectionPool(Destination destination, int maxConnections, Callback requester)
{
- this.destination = destination;
- this.maxConnections = maxConnections;
- this.requester = requester;
- this.idleConnections = new LinkedBlockingDeque<>(maxConnections);
- this.activeConnections = new BlockingArrayQueue<>(maxConnections);
+ super(destination, maxConnections, requester);
+ this.idleConnections = new ArrayDeque<>(maxConnections);
+ this.activeConnections = new HashSet<>(maxConnections);
}
- @ManagedAttribute(value = "The number of connections", readonly = true)
- public int getConnectionCount()
+ protected void lock()
{
- return connectionCount.get();
+ lock.lock();
+ }
+
+ protected void unlock()
+ {
+ lock.unlock();
}
@ManagedAttribute(value = "The number of idle connections", readonly = true)
@@ -102,139 +99,76 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa
return idleConnections;
}
- public Queue<Connection> getActiveConnections()
+ public Collection<Connection> getActiveConnections()
{
return activeConnections;
}
- public Connection acquire()
- {
- Connection connection = activateIdle();
- if (connection == null)
- connection = tryCreate();
- return connection;
- }
-
- private Connection tryCreate()
+ @Override
+ public boolean isActive(Connection connection)
{
- while (true)
+ lock();
+ try
{
- int current = getConnectionCount();
- final int next = current + 1;
-
- if (next > maxConnections)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Max connections {}/{} reached", current, maxConnections);
- // Try again the idle connections
- return activateIdle();
- }
-
- if (connectionCount.compareAndSet(current, next))
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Connection {}/{} creation", next, maxConnections);
-
- destination.newConnection(new Promise<Connection>()
- {
- @Override
- public void succeeded(Connection connection)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection);
-
- idleCreated(connection);
-
- proceed();
- }
-
- @Override
- public void failed(Throwable x)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Connection " + next + "/" + maxConnections + " creation failed", x);
-
- connectionCount.decrementAndGet();
-
- requester.failed(x);
- }
- });
-
- // Try again the idle connections
- return activateIdle();
- }
+ return activeConnections.contains(connection);
+ }
+ finally
+ {
+ unlock();
}
}
- protected void proceed()
- {
- requester.succeeded();
- }
-
- protected void idleCreated(Connection connection)
+ @Override
+ protected void onCreated(Connection connection)
{
- boolean idle;
lock();
try
{
// Use "cold" new connections as last.
- idle = idleConnections.offerLast(connection);
+ idleConnections.offer(connection);
}
finally
{
unlock();
}
- idle(connection, idle);
+ idle(connection, false);
}
- private Connection activateIdle()
+ @Override
+ protected Connection activate()
{
- boolean acquired;
Connection connection;
lock();
try
{
- connection = idleConnections.pollFirst();
+ connection = idleConnections.poll();
if (connection == null)
return null;
- acquired = activeConnections.offer(connection);
+ activeConnections.add(connection);
}
finally
{
unlock();
}
- if (acquired)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Connection active {}", connection);
- acquired(connection);
- return connection;
- }
- else
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Connection active overflow {}", connection);
- connection.close();
- return null;
- }
- }
-
- protected void acquired(Connection connection)
- {
+ return active(connection);
}
public boolean release(Connection connection)
{
- boolean idle;
+ boolean closed = isClosed();
lock();
try
{
if (!activeConnections.remove(connection))
return false;
- // Make sure we use "hot" connections first.
- idle = offerIdle(connection);
+
+ if (!closed)
+ {
+ // Make sure we use "hot" connections first.
+ deactivate(connection);
+ }
}
finally
{
@@ -242,35 +176,14 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa
}
released(connection);
- return idle(connection, idle);
+ return idle(connection, closed);
}
- protected boolean offerIdle(Connection connection)
+ protected boolean deactivate(Connection connection)
{
return idleConnections.offerFirst(connection);
}
- protected boolean idle(Connection connection, boolean idle)
- {
- if (idle)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Connection idle {}", connection);
- return true;
- }
- else
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Connection idle overflow {}", connection);
- connection.close();
- return false;
- }
- }
-
- protected void released(Connection connection)
- {
- }
-
public boolean remove(Connection connection)
{
return remove(connection, false);
@@ -295,55 +208,21 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa
released(connection);
boolean removed = activeRemoved || idleRemoved || force;
if (removed)
- {
- int pooled = connectionCount.decrementAndGet();
- if (LOG.isDebugEnabled())
- LOG.debug("Connection removed {} - pooled: {}", connection, pooled);
- }
+ removed(connection);
return removed;
}
- public boolean isActive(Connection connection)
- {
- lock();
- try
- {
- return activeConnections.contains(connection);
- }
- finally
- {
- unlock();
- }
- }
-
- public boolean isIdle(Connection connection)
- {
- lock();
- try
- {
- return idleConnections.contains(connection);
- }
- finally
- {
- unlock();
- }
- }
-
- public boolean isEmpty()
- {
- return connectionCount.get() == 0;
- }
-
public void close()
{
- List<Connection> idles = new ArrayList<>();
- List<Connection> actives = new ArrayList<>();
+ super.close();
+
+ List<Connection> connections = new ArrayList<>();
lock();
try
{
- idles.addAll(idleConnections);
+ connections.addAll(idleConnections);
idleConnections.clear();
- actives.addAll(activeConnections);
+ connections.addAll(activeConnections);
activeConnections.clear();
}
finally
@@ -351,32 +230,18 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa
unlock();
}
- connectionCount.set(0);
-
- for (Connection connection : idles)
- connection.close();
-
- // A bit drastic, but we cannot wait for all requests to complete
- for (Connection connection : actives)
- connection.close();
- }
-
- @Override
- public String dump()
- {
- return ContainerLifeCycle.dump(this);
+ close(connections);
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
- List<Connection> actives = new ArrayList<>();
- List<Connection> idles = new ArrayList<>();
+ List<Connection> connections = new ArrayList<>();
lock();
try
{
- actives.addAll(activeConnections);
- idles.addAll(idleConnections);
+ connections.addAll(activeConnections);
+ connections.addAll(idleConnections);
}
finally
{
@@ -384,7 +249,7 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa
}
ContainerLifeCycle.dumpObject(out, this);
- ContainerLifeCycle.dump(out, indent, actives, idles);
+ ContainerLifeCycle.dump(out, indent, connections);
}
@Override
@@ -422,16 +287,6 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa
return false;
}
- protected void lock()
- {
- lock.lock();
- }
-
- protected void unlock()
- {
- lock.unlock();
- }
-
@Override
public String toString()
{
@@ -450,8 +305,8 @@ public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepa
return String.format("%s[c=%d/%d,a=%d,i=%d]",
getClass().getSimpleName(),
- connectionCount.get(),
- maxConnections,
+ getConnectionCount(),
+ getMaxConnectionCount(),
activeSize,
idleSize);
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpChannel.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpChannel.java
index d493a9e200..09dd2fb3ad 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpChannel.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpChannel.java
@@ -129,6 +129,11 @@ public abstract class HttpChannel
return getHttpReceiver().abort(exchange, failure);
}
+ public Result exchangeTerminating(HttpExchange exchange, Result result)
+ {
+ return result;
+ }
+
public void exchangeTerminated(HttpExchange exchange, Result result)
{
disassociate(exchange);
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 8c97c77afe..cbf15b6fff 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
@@ -524,15 +524,12 @@ public class HttpClient extends ContainerLifeCycle
*/
public List<Destination> getDestinations()
{
- return new ArrayList<Destination>(destinations.values());
+ return new ArrayList<>(destinations.values());
}
protected void send(final HttpRequest request, List<Response.ResponseListener> listeners)
{
String scheme = request.getScheme().toLowerCase(Locale.ENGLISH);
- if (!HttpScheme.HTTP.is(scheme) && !HttpScheme.HTTPS.is(scheme))
- throw new IllegalArgumentException("Invalid protocol " + scheme);
-
String host = request.getHost().toLowerCase(Locale.ENGLISH);
HttpDestination destination = destinationFor(scheme, host, request.getPort());
destination.send(request, listeners);
@@ -1040,12 +1037,25 @@ public class HttpClient extends ContainerLifeCycle
protected int normalizePort(String scheme, int port)
{
- return port > 0 ? port : HttpScheme.HTTPS.is(scheme) ? 443 : 80;
+ if (port > 0)
+ return port;
+ else if (isSchemeSecure(scheme))
+ return 443;
+ else
+ return 80;
}
public boolean isDefaultPort(String scheme, int port)
{
- return HttpScheme.HTTPS.is(scheme) ? port == 443 : port == 80;
+ if (isSchemeSecure(scheme))
+ return port == 443;
+ else
+ return port == 80;
+ }
+
+ public boolean isSchemeSecure(String scheme)
+ {
+ return HttpScheme.HTTPS.is(scheme) || HttpScheme.WSS.is(scheme);
}
private class ContentDecoderFactorySet implements Set<ContentDecoder.Factory>
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
index 9031562db2..58eaee5ef5 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
@@ -22,19 +22,21 @@ import java.io.Closeable;
import java.io.IOException;
import java.nio.channels.AsynchronousCloseException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.RejectedExecutionException;
import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.Destination;
+import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.BlockingArrayQueue;
+import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
@@ -42,9 +44,10 @@ import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.util.thread.Sweeper;
@ManagedObject
-public abstract class HttpDestination extends ContainerLifeCycle implements Destination, Closeable, Dumpable
+public abstract class HttpDestination extends ContainerLifeCycle implements Destination, Closeable, Callback, Dumpable
{
protected static final Logger LOG = Log.getLogger(HttpDestination.class);
@@ -56,6 +59,7 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
private final ProxyConfiguration.Proxy proxy;
private final ClientConnectionFactory connectionFactory;
private final HttpField hostField;
+ private ConnectionPool connectionPool;
public HttpDestination(HttpClient client, Origin origin)
{
@@ -76,7 +80,7 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
}
else
{
- if (HttpScheme.HTTPS.is(getScheme()))
+ if (isSecure())
connectionFactory = newSslClientConnectionFactory(connectionFactory);
}
this.connectionFactory = connectionFactory;
@@ -87,6 +91,29 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
hostField = new HttpField(HttpHeader.HOST, host);
}
+ @Override
+ protected void doStart() throws Exception
+ {
+ this.connectionPool = newConnectionPool(client);
+ addBean(connectionPool);
+ super.doStart();
+ Sweeper sweeper = client.getBean(Sweeper.class);
+ if (sweeper != null && connectionPool instanceof Sweeper.Sweepable)
+ sweeper.offer((Sweeper.Sweepable)connectionPool);
+ }
+
+ @Override
+ protected void doStop() throws Exception
+ {
+ Sweeper sweeper = client.getBean(Sweeper.class);
+ if (sweeper != null && connectionPool instanceof Sweeper.Sweepable)
+ sweeper.remove((Sweeper.Sweepable)connectionPool);
+ super.doStop();
+ removeBean(connectionPool);
+ }
+
+ protected abstract ConnectionPool newConnectionPool(HttpClient client);
+
protected Queue<HttpExchange> newExchangeQueue(HttpClient client)
{
return new BlockingArrayQueue<>(client.getMaxRequestsQueuedPerDestination());
@@ -97,6 +124,11 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
return new SslClientConnectionFactory(client.getSslContextFactory(), client.getByteBufferPool(), client.getExecutor(), connectionFactory);
}
+ public boolean isSecure()
+ {
+ return client.isSchemeSecure(getScheme());
+ }
+
public HttpClient getHttpClient()
{
return client;
@@ -171,6 +203,24 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
return hostField;
}
+ @ManagedAttribute(value = "The connection pool", readonly = true)
+ public ConnectionPool getConnectionPool()
+ {
+ return connectionPool;
+ }
+
+ @Override
+ public void succeeded()
+ {
+ send();
+ }
+
+ @Override
+ public void failed(Throwable x)
+ {
+ abort(x);
+ }
+
protected void send(HttpRequest request, List<Response.ResponseListener> listeners)
{
if (!getScheme().equalsIgnoreCase(request.getScheme()))
@@ -217,7 +267,59 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
return queue.offer(exchange);
}
- public abstract void send();
+ public void send()
+ {
+ if (getHttpExchanges().isEmpty())
+ return;
+ process();
+ }
+
+ private void process()
+ {
+ Connection connection = connectionPool.acquire();
+ if (connection != null)
+ process(connection);
+ }
+
+ public void process(final Connection connection)
+ {
+ HttpClient client = getHttpClient();
+ final HttpExchange exchange = getHttpExchanges().poll();
+ if (LOG.isDebugEnabled())
+ LOG.debug("Processing exchange {} on {} of {}", exchange, connection, this);
+ if (exchange == null)
+ {
+ if (!connectionPool.release(connection))
+ connection.close();
+
+ if (!client.isRunning())
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("{} is stopping", client);
+ connection.close();
+ }
+ }
+ else
+ {
+ final Request request = exchange.getRequest();
+ Throwable cause = request.getAbortCause();
+ if (cause != null)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Aborted before processing {}: {}", exchange, cause);
+ // It may happen that the request is aborted before the exchange
+ // is created. Aborting the exchange a second time will result in
+ // a no-operation, so we just abort here to cover that edge case.
+ exchange.abort(cause);
+ }
+ else
+ {
+ send(connection, exchange);
+ }
+ }
+ }
+
+ protected abstract void send(Connection connection, HttpExchange exchange);
public void newConnection(Promise<Connection> promise)
{
@@ -239,14 +341,67 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
abort(new AsynchronousCloseException());
if (LOG.isDebugEnabled())
LOG.debug("Closed {}", this);
+ connectionPool.close();
}
public void release(Connection connection)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("Released {}", connection);
+ HttpClient client = getHttpClient();
+ if (client.isRunning())
+ {
+ if (connectionPool.isActive(connection))
+ {
+ if (connectionPool.release(connection))
+ send();
+ else
+ connection.close();
+ }
+ else
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Released explicit {}", connection);
+ }
+ }
+ else
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("{} is stopped", client);
+ connection.close();
+ }
+ }
+
+ public boolean remove(Connection connection)
+ {
+ return connectionPool.remove(connection);
}
public void close(Connection connection)
{
+ boolean removed = remove(connection);
+
+ if (getHttpExchanges().isEmpty())
+ {
+ if (getHttpClient().isRemoveIdleDestinations() && connectionPool.isEmpty())
+ {
+ // There is a race condition between this thread removing the destination
+ // and another thread queueing a request to this same destination.
+ // If this destination is removed, but the request queued, a new connection
+ // will be opened, the exchange will be executed and eventually the connection
+ // will idle timeout and be closed. Meanwhile a new destination will be created
+ // in HttpClient and will be used for other requests.
+ getHttpClient().removeDestination(this);
+ }
+ }
+ else
+ {
+ // We need to execute queued requests even if this connection failed.
+ // We may create a connection that is not needed, but it will eventually
+ // idle timeout, so no worries.
+ if (removed)
+ process();
+ }
}
/**
@@ -274,6 +429,7 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
public void dump(Appendable out, String indent) throws IOException
{
ContainerLifeCycle.dumpObject(out, toString());
+ ContainerLifeCycle.dump(out, indent, Collections.singletonList(connectionPool));
}
public String asString()
@@ -284,11 +440,12 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
@Override
public String toString()
{
- return String.format("%s[%s]%x%s,queue=%d",
+ return String.format("%s[%s]%x%s,queue=%d,pool=%s",
HttpDestination.class.getSimpleName(),
asString(),
hashCode(),
proxy == null ? "" : "(via " + proxy + ")",
- exchanges.size());
+ exchanges.size(),
+ connectionPool);
}
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java
index bd9abbe546..2a92a5d42a 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpProxy.java
@@ -107,7 +107,7 @@ public class HttpProxy extends ProxyConfiguration.Proxy
public void succeeded(Connection connection)
{
HttpDestination destination = (HttpDestination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY);
- if (HttpScheme.HTTPS.is(destination.getScheme()))
+ if (destination.isSecure())
{
SslContextFactory sslContextFactory = destination.getHttpClient().getSslContextFactory();
if (sslContextFactory != null)
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 2fb444130c..04bdf62731 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
@@ -437,6 +437,7 @@ public abstract class HttpReceiver
if (result != null)
{
+ result = channel.exchangeTerminating(exchange, result);
boolean ordered = getHttpDestination().getHttpClient().isStrictEventOrdering();
if (!ordered)
channel.exchangeTerminated(exchange, result);
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java
index 5417a122e8..25fd7d9487 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java
@@ -376,6 +376,7 @@ public abstract class HttpSender implements AsyncContentProvider.Listener
}
else
{
+ result = channel.exchangeTerminating(exchange, result);
HttpDestination destination = getHttpChannel().getHttpDestination();
boolean ordered = destination.getHttpClient().isStrictEventOrdering();
if (!ordered)
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java
index 7762af09f9..f5d3b98580 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java
@@ -25,7 +25,7 @@ import org.eclipse.jetty.util.LeakDetector;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-public class LeakTrackingConnectionPool extends ConnectionPool
+public class LeakTrackingConnectionPool extends DuplexConnectionPool
{
private static final Logger LOG = Log.getLogger(LeakTrackingConnectionPool.class);
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexConnectionPool.java
new file mode 100644
index 0000000000..88561bb75b
--- /dev/null
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexConnectionPool.java
@@ -0,0 +1,302 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.client;
+
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.stream.Collectors;
+
+import org.eclipse.jetty.client.api.Connection;
+import org.eclipse.jetty.util.Callback;
+import org.eclipse.jetty.util.component.ContainerLifeCycle;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+
+public class MultiplexConnectionPool extends AbstractConnectionPool
+{
+ private static final Logger LOG = Log.getLogger(MultiplexConnectionPool.class);
+
+ private final ReentrantLock lock = new ReentrantLock();
+ private final int maxMultiplexed;
+ private final Deque<Holder> idleConnections;
+ private final Map<Connection, Holder> muxedConnections;
+ private final Map<Connection, Holder> busyConnections;
+
+ public MultiplexConnectionPool(HttpDestination destination, int maxConnections, Callback requester, int maxMultiplexed)
+ {
+ super(destination, maxConnections, requester);
+ this.maxMultiplexed = maxMultiplexed;
+ this.idleConnections = new ArrayDeque<>(maxConnections);
+ this.muxedConnections = new HashMap<>(maxConnections);
+ this.busyConnections = new HashMap<>(maxConnections);
+ }
+
+ protected void lock()
+ {
+ lock.lock();
+ }
+
+ protected void unlock()
+ {
+ lock.unlock();
+ }
+
+ @Override
+ public boolean isActive(Connection connection)
+ {
+ lock();
+ try
+ {
+ if (muxedConnections.containsKey(connection))
+ return true;
+ if (busyConnections.containsKey(connection))
+ return true;
+ return false;
+ }
+ finally
+ {
+ unlock();
+ }
+ }
+
+ @Override
+ protected void onCreated(Connection connection)
+ {
+ lock();
+ try
+ {
+ // Use "cold" connections as last.
+ idleConnections.offer(new Holder(connection));
+ }
+ finally
+ {
+ unlock();
+ }
+
+ idle(connection, false);
+ }
+
+ @Override
+ protected Connection activate()
+ {
+ Holder holder;
+ lock();
+ try
+ {
+ while (true)
+ {
+ if (muxedConnections.isEmpty())
+ {
+ holder = idleConnections.poll();
+ if (holder == null)
+ return null;
+ muxedConnections.put(holder.connection, holder);
+ }
+ else
+ {
+ holder = muxedConnections.values().iterator().next();
+ }
+
+ if (holder.count < maxMultiplexed)
+ {
+ ++holder.count;
+ break;
+ }
+ else
+ {
+ muxedConnections.remove(holder.connection);
+ busyConnections.put(holder.connection, holder);
+ }
+ }
+ }
+ finally
+ {
+ unlock();
+ }
+
+ return active(holder.connection);
+ }
+
+ @Override
+ public boolean release(Connection connection)
+ {
+ boolean closed = isClosed();
+ boolean idle = false;
+ Holder holder;
+ lock();
+ try
+ {
+ holder = muxedConnections.get(connection);
+ if (holder != null)
+ {
+ int count = --holder.count;
+ if (count == 0)
+ {
+ muxedConnections.remove(connection);
+ if (!closed)
+ {
+ idleConnections.offerFirst(holder);
+ idle = true;
+ }
+ }
+ }
+ else
+ {
+ holder = busyConnections.remove(connection);
+ if (holder != null)
+ {
+ int count = --holder.count;
+ if (!closed)
+ {
+ if (count == 0)
+ {
+ idleConnections.offerFirst(holder);
+ idle = true;
+ }
+ else
+ {
+ muxedConnections.put(connection, holder);
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ unlock();
+ }
+
+ if (holder == null)
+ return false;
+
+ released(connection);
+ if (idle || closed)
+ return idle(connection, closed);
+ return true;
+ }
+
+ @Override
+ public boolean remove(Connection connection)
+ {
+ return remove(connection, false);
+ }
+
+ protected boolean remove(Connection connection, boolean force)
+ {
+ boolean activeRemoved = true;
+ boolean idleRemoved = false;
+ lock();
+ try
+ {
+ Holder holder = muxedConnections.remove(connection);
+ if (holder == null)
+ holder = busyConnections.remove(connection);
+ if (holder == null)
+ {
+ activeRemoved = false;
+ for (Iterator<Holder> iterator = idleConnections.iterator(); iterator.hasNext();)
+ {
+ holder = iterator.next();
+ if (holder.connection == connection)
+ {
+ idleRemoved = true;
+ iterator.remove();
+ break;
+ }
+ }
+ }
+ }
+ finally
+ {
+ unlock();
+ }
+
+ if (activeRemoved || force)
+ released(connection);
+ boolean removed = activeRemoved || idleRemoved || force;
+ if (removed)
+ removed(connection);
+ return removed;
+ }
+
+ @Override
+ public void close()
+ {
+ super.close();
+
+ List<Connection> connections;
+ lock();
+ try
+ {
+ connections = idleConnections.stream().map(holder -> holder.connection).collect(Collectors.toList());
+ connections.addAll(muxedConnections.keySet());
+ connections.addAll(busyConnections.keySet());
+ }
+ finally
+ {
+ unlock();
+ }
+
+ close(connections);
+ }
+
+ @Override
+ public void dump(Appendable out, String indent) throws IOException
+ {
+ List<Holder> connections = new ArrayList<>();
+ lock();
+ try
+ {
+ connections.addAll(busyConnections.values());
+ connections.addAll(muxedConnections.values());
+ connections.addAll(idleConnections);
+ }
+ finally
+ {
+ unlock();
+ }
+
+ ContainerLifeCycle.dumpObject(out, this);
+ ContainerLifeCycle.dump(out, indent, connections);
+ }
+
+ private static class Holder
+ {
+ private final Connection connection;
+ private int count;
+
+ private Holder(Connection connection)
+ {
+ this.connection = connection;
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format("%s[%d]", connection, count);
+ }
+ }
+}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java
index a50131f1ed..a23fb34a82 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java
@@ -18,136 +18,16 @@
package org.eclipse.jetty.client;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.jetty.client.api.Connection;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.util.Promise;
-
-public abstract class MultiplexHttpDestination<C extends Connection> extends HttpDestination implements Promise<Connection>
+public abstract class MultiplexHttpDestination extends HttpDestination
{
- private final AtomicReference<ConnectState> connect = new AtomicReference<>(ConnectState.DISCONNECTED);
- private C connection;
-
protected MultiplexHttpDestination(HttpClient client, Origin origin)
{
super(client, origin);
}
- @Override
- public void send()
- {
- while (true)
- {
- ConnectState current = connect.get();
- switch (current)
- {
- case DISCONNECTED:
- {
- if (!connect.compareAndSet(current, ConnectState.CONNECTING))
- break;
- newConnection(this);
- return;
- }
- case CONNECTING:
- {
- // Waiting to connect, just return
- return;
- }
- case CONNECTED:
- {
- if (process(connection))
- break;
- return;
- }
- default:
- {
- abort(new IllegalStateException("Invalid connection state " + current));
- return;
- }
- }
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void succeeded(Connection result)
- {
- C connection = this.connection = (C)result;
- if (connect.compareAndSet(ConnectState.CONNECTING, ConnectState.CONNECTED))
- {
- process(connection);
- }
- else
- {
- connection.close();
- failed(new IllegalStateException());
- }
- }
-
- @Override
- public void failed(Throwable x)
- {
- connect.set(ConnectState.DISCONNECTED);
- abort(x);
- }
-
- protected boolean process(final C connection)
- {
- HttpClient client = getHttpClient();
- final HttpExchange exchange = getHttpExchanges().poll();
- if (LOG.isDebugEnabled())
- LOG.debug("Processing {} on {}", exchange, connection);
- if (exchange == null)
- return false;
-
- final Request request = exchange.getRequest();
- Throwable cause = request.getAbortCause();
- if (cause != null)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Aborted before processing {}: {}", exchange, cause);
- // It may happen that the request is aborted before the exchange
- // is created. Aborting the exchange a second time will result in
- // a no-operation, so we just abort here to cover that edge case.
- exchange.abort(cause);
- }
- else
- {
- send(connection, exchange);
- }
- return true;
- }
-
- @Override
- public void close()
- {
- super.close();
- C connection = this.connection;
- if (connection != null)
- connection.close();
- }
-
- @Override
- public void close(Connection connection)
- {
- super.close(connection);
- while (true)
- {
- ConnectState current = connect.get();
- if (connect.compareAndSet(current, ConnectState.DISCONNECTED))
- {
- if (getHttpClient().isRemoveIdleDestinations())
- getHttpClient().removeDestination(this);
- break;
- }
- }
- }
-
- protected abstract void send(C connection, HttpExchange exchange);
-
- private enum ConnectState
+ protected ConnectionPool newConnectionPool(HttpClient client)
{
- DISCONNECTED, CONNECTING, CONNECTED
+ return new MultiplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this,
+ client.getMaxRequestsQueuedPerDestination());
}
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
index 3c4e73b1ae..b77805aeae 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
@@ -18,224 +18,15 @@
package org.eclipse.jetty.client;
-import java.io.IOException;
-import java.util.Collections;
-
-import org.eclipse.jetty.client.api.Connection;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.util.Callback;
-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.thread.Sweeper;
-
-@ManagedObject
-public abstract class PoolingHttpDestination<C extends Connection> extends HttpDestination implements Callback
+public abstract class PoolingHttpDestination extends HttpDestination
{
- private DuplexConnectionPool connectionPool;
-
public PoolingHttpDestination(HttpClient client, Origin origin)
{
super(client, origin);
- this.connectionPool = newConnectionPool(client);
- addBean(connectionPool);
- Sweeper sweeper = client.getBean(Sweeper.class);
- if (sweeper != null)
- sweeper.offer(connectionPool);
}
- @Override
- protected void doStart() throws Exception
- {
- HttpClient client = getHttpClient();
- this.connectionPool = newConnectionPool(client);
- addBean(connectionPool);
- super.doStart();
- Sweeper sweeper = client.getBean(Sweeper.class);
- if (sweeper != null)
- sweeper.offer(connectionPool);
- }
-
- @Override
- protected void doStop() throws Exception
- {
- HttpClient client = getHttpClient();
- Sweeper sweeper = client.getBean(Sweeper.class);
- if (sweeper != null)
- sweeper.remove(connectionPool);
- super.doStop();
- removeBean(connectionPool);
- }
-
- protected DuplexConnectionPool newConnectionPool(HttpClient client)
+ protected ConnectionPool newConnectionPool(HttpClient client)
{
return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this);
}
-
- @ManagedAttribute(value = "The connection pool", readonly = true)
- public DuplexConnectionPool getConnectionPool()
- {
- return connectionPool;
- }
-
- @Override
- public void succeeded()
- {
- send();
- }
-
- @Override
- public void failed(final Throwable x)
- {
- abort(x);
- }
-
- public void send()
- {
- if (getHttpExchanges().isEmpty())
- return;
- process();
- }
-
- @SuppressWarnings("unchecked")
- public C acquire()
- {
- return (C)connectionPool.acquire();
- }
-
- private void process()
- {
- C connection = acquire();
- if (connection != null)
- process(connection);
- }
-
- /**
- * <p>Processes a new connection making it idle or active depending on whether requests are waiting to be sent.</p>
- * <p>A new connection is created when a request needs to be executed; it is possible that the request that
- * triggered the request creation is executed by another connection that was just released, so the new connection
- * may become idle.</p>
- * <p>If a request is waiting to be executed, it will be dequeued and executed by the new connection.</p>
- *
- * @param connection the new connection
- */
- public void process(final C connection)
- {
- HttpClient client = getHttpClient();
- final HttpExchange exchange = getHttpExchanges().poll();
- if (LOG.isDebugEnabled())
- LOG.debug("Processing exchange {} on {} of {}", exchange, connection, this);
- if (exchange == null)
- {
- if (!connectionPool.release(connection))
- connection.close();
-
- if (!client.isRunning())
- {
- if (LOG.isDebugEnabled())
- LOG.debug("{} is stopping", client);
- connection.close();
- }
- }
- else
- {
- final Request request = exchange.getRequest();
- Throwable cause = request.getAbortCause();
- if (cause != null)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Aborted before processing {}: {}", exchange, cause);
- // It may happen that the request is aborted before the exchange
- // is created. Aborting the exchange a second time will result in
- // a no-operation, so we just abort here to cover that edge case.
- exchange.abort(cause);
- }
- else
- {
- send(connection, exchange);
- }
- }
- }
-
- protected abstract void send(C connection, HttpExchange exchange);
-
- @Override
- public void release(Connection c)
- {
- @SuppressWarnings("unchecked")
- C connection = (C)c;
- if (LOG.isDebugEnabled())
- LOG.debug("Released {}", connection);
- HttpClient client = getHttpClient();
- if (client.isRunning())
- {
- if (connectionPool.isActive(connection))
- {
- if (connectionPool.release(connection))
- send();
- else
- connection.close();
- }
- else
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Released explicit {}", connection);
- }
- }
- else
- {
- if (LOG.isDebugEnabled())
- LOG.debug("{} is stopped", client);
- connection.close();
- }
- }
-
- @Override
- public void close(Connection connection)
- {
- super.close(connection);
-
- boolean removed = connectionPool.remove(connection);
-
- if (getHttpExchanges().isEmpty())
- {
- if (getHttpClient().isRemoveIdleDestinations() && connectionPool.isEmpty())
- {
- // There is a race condition between this thread removing the destination
- // and another thread queueing a request to this same destination.
- // If this destination is removed, but the request queued, a new connection
- // will be opened, the exchange will be executed and eventually the connection
- // will idle timeout and be closed. Meanwhile a new destination will be created
- // in HttpClient and will be used for other requests.
- getHttpClient().removeDestination(this);
- }
- }
- else
- {
- // We need to execute queued requests even if this connection failed.
- // We may create a connection that is not needed, but it will eventually
- // idle timeout, so no worries.
- if (removed)
- process();
- }
- }
-
- public void close()
- {
- super.close();
- connectionPool.close();
- }
-
- @Override
- public void dump(Appendable out, String indent) throws IOException
- {
- super.dump(out, indent);
- ContainerLifeCycle.dump(out, indent, Collections.singletonList(connectionPool));
- }
-
- @Override
- public String toString()
- {
- return String.format("%s,pool=%s", super.toString(), connectionPool);
- }
}
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 7d6d48a2e5..5c0969d3a8 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
@@ -210,7 +210,7 @@ public class ResponseNotifier
notifyHeaders(listeners, response);
if (response instanceof ContentResponse)
// TODO: handle callback
- notifyContent(listeners, response, ByteBuffer.wrap(((ContentResponse)response).getContent()), new Callback.Adapter());
+ notifyContent(listeners, response, ByteBuffer.wrap(((ContentResponse)response).getContent()), Callback.NOOP);
notifySuccess(listeners, response);
}
@@ -232,7 +232,7 @@ public class ResponseNotifier
notifyHeaders(listeners, response);
if (response instanceof ContentResponse)
// TODO: handle callback
- notifyContent(listeners, response, ByteBuffer.wrap(((ContentResponse)response).getContent()), new Callback.Adapter());
+ notifyContent(listeners, response, ByteBuffer.wrap(((ContentResponse)response).getContent()), Callback.NOOP);
notifyFailure(listeners, response, failure);
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java b/jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java
index 58ac5cc995..246681e646 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/Socks4Proxy.java
@@ -27,7 +27,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jetty.client.api.Connection;
-import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.EndPoint;
@@ -196,7 +195,7 @@ public class Socks4Proxy extends ProxyConfiguration.Proxy
HttpDestination destination = (HttpDestination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY);
HttpClient client = destination.getHttpClient();
ClientConnectionFactory connectionFactory = this.connectionFactory;
- if (HttpScheme.HTTPS.is(destination.getScheme()))
+ if (destination.isSecure())
connectionFactory = new SslClientConnectionFactory(client.getSslContextFactory(), client.getByteBufferPool(), client.getExecutor(), connectionFactory);
org.eclipse.jetty.io.Connection newConnection = connectionFactory.newConnection(getEndPoint(), context);
getEndPoint().upgrade(newConnection);
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java
index 2235f75dab..a218d14e87 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/ValidatingConnectionPool.java
@@ -56,7 +56,7 @@ import org.eclipse.jetty.util.thread.Scheduler;
* tuning the idle timeout of the servers to be larger than
* that of the client.</p>
*/
-public class ValidatingConnectionPool extends ConnectionPool
+public class ValidatingConnectionPool extends DuplexConnectionPool
{
private static final Logger LOG = Log.getLogger(ValidatingConnectionPool.class);
@@ -154,7 +154,7 @@ public class ValidatingConnectionPool extends ConnectionPool
private class Holder implements Runnable
{
private final long timestamp = System.nanoTime();
- private final AtomicBoolean latch = new AtomicBoolean();
+ private final AtomicBoolean done = new AtomicBoolean();
private final Connection connection;
public Scheduler.Task task;
@@ -166,30 +166,31 @@ public class ValidatingConnectionPool extends ConnectionPool
@Override
public void run()
{
- if (latch.compareAndSet(false, true))
+ if (done.compareAndSet(false, true))
{
- boolean idle;
+ boolean closed = isClosed();
lock();
try
{
- quarantine.remove(connection);
- idle = offerIdle(connection);
if (LOG.isDebugEnabled())
LOG.debug("Validated {}", connection);
+ quarantine.remove(connection);
+ if (!closed)
+ deactivate(connection);
}
finally
{
unlock();
}
- if (idle(connection, idle))
- proceed();
+ idle(connection, closed);
+ proceed();
}
}
public boolean cancel()
{
- if (latch.compareAndSet(false, true))
+ if (done.compareAndSet(false, true))
{
task.cancel();
return true;
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Result.java b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Result.java
index a782bd8d88..f934ba5f0e 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Result.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Result.java
@@ -52,6 +52,14 @@ public class Result
this.responseFailure = responseFailure;
}
+ public Result(Result result, Throwable responseFailure)
+ {
+ this.request = result.request;
+ this.requestFailure = result.requestFailure;
+ this.response = result.response;
+ this.responseFailure = responseFailure;
+ }
+
/**
* @return the request object
*/
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java
index a204cf3a2e..0ca65b109c 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java
@@ -18,16 +18,20 @@
package org.eclipse.jetty.client.http;
+import java.util.Locale;
+
import org.eclipse.jetty.client.HttpChannel;
import org.eclipse.jetty.client.HttpExchange;
-import org.eclipse.jetty.client.HttpReceiver;
-import org.eclipse.jetty.client.HttpSender;
+import org.eclipse.jetty.client.HttpRequest;
+import org.eclipse.jetty.client.HttpResponse;
+import org.eclipse.jetty.client.HttpResponseException;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
public class HttpChannelOverHTTP extends HttpChannel
@@ -55,13 +59,13 @@ public class HttpChannelOverHTTP extends HttpChannel
}
@Override
- protected HttpSender getHttpSender()
+ protected HttpSenderOverHTTP getHttpSender()
{
return sender;
}
@Override
- protected HttpReceiver getHttpReceiver()
+ protected HttpReceiverOverHTTP getHttpReceiver()
{
return receiver;
}
@@ -85,6 +89,42 @@ public class HttpChannelOverHTTP extends HttpChannel
connection.release();
}
+ @Override
+ public Result exchangeTerminating(HttpExchange exchange, Result result)
+ {
+ if (result.isFailed())
+ return result;
+
+ HttpResponse response = exchange.getResponse();
+
+ if ((response.getVersion() == HttpVersion.HTTP_1_1) &&
+ (response.getStatus() == HttpStatus.SWITCHING_PROTOCOLS_101))
+ {
+ String connection = response.getHeaders().get(HttpHeader.CONNECTION);
+ if ((connection == null) || !connection.toLowerCase(Locale.US).contains("upgrade"))
+ {
+ return new Result(result,new HttpResponseException("101 Switching Protocols without Connection: Upgrade not supported",response));
+ }
+
+ // Upgrade Response
+ HttpRequest request = exchange.getRequest();
+ if (request instanceof HttpConnectionUpgrader)
+ {
+ HttpConnectionUpgrader listener = (HttpConnectionUpgrader)request;
+ try
+ {
+ listener.upgrade(response,getHttpConnection());
+ }
+ catch (Throwable x)
+ {
+ return new Result(result,x);
+ }
+ }
+ }
+
+ return result;
+ }
+
public void receive()
{
receiver.receive();
@@ -131,7 +171,10 @@ public class HttpChannelOverHTTP extends HttpChannel
}
else
{
- release();
+ if (response.getStatus() == HttpStatus.SWITCHING_PROTOCOLS_101)
+ connection.remove();
+ else
+ release();
}
}
@@ -143,4 +186,5 @@ public class HttpChannelOverHTTP extends HttpChannel
sender,
receiver);
}
+
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
index 8108e5491c..5c60de2c66 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
@@ -18,6 +18,7 @@
package org.eclipse.jetty.client.http;
+import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousCloseException;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -36,7 +37,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Sweeper;
-public class HttpConnectionOverHTTP extends AbstractConnection implements Connection, Sweeper.Sweepable
+public class HttpConnectionOverHTTP extends AbstractConnection implements Connection, org.eclipse.jetty.io.Connection.UpgradeFrom, Sweeper.Sweepable
{
private static final Logger LOG = Log.getLogger(HttpConnectionOverHTTP.class);
@@ -119,6 +120,13 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements Connec
}
}
+ @Override
+ public ByteBuffer onUpgradeFrom()
+ {
+ HttpReceiverOverHTTP receiver = channel.getHttpReceiver();
+ return receiver.onUpgradeFrom();
+ }
+
public void release()
{
// Restore idle timeout
@@ -171,6 +179,11 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements Connec
return true;
}
+ public void remove()
+ {
+ getHttpDestination().remove(this);
+ }
+
@Override
public String toString()
{
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/graph/Predicate.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionUpgrader.java
index b995932391..c2c43749be 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/graph/Predicate.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionUpgrader.java
@@ -16,12 +16,11 @@
// ========================================================================
//
-package org.eclipse.jetty.start.graph;
+package org.eclipse.jetty.client.http;
-/**
- * Matcher of Nodes
- */
-public interface Predicate
+import org.eclipse.jetty.client.HttpResponse;
+
+public interface HttpConnectionUpgrader
{
- public boolean match(Node<?> input);
+ public void upgrade(HttpResponse response, HttpConnectionOverHTTP connection);
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTP.java
index 304ba96d35..284ce08fe5 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTP.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTP.java
@@ -22,8 +22,9 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.PoolingHttpDestination;
+import org.eclipse.jetty.client.api.Connection;
-public class HttpDestinationOverHTTP extends PoolingHttpDestination<HttpConnectionOverHTTP>
+public class HttpDestinationOverHTTP extends PoolingHttpDestination
{
public HttpDestinationOverHTTP(HttpClient client, Origin origin)
{
@@ -31,8 +32,8 @@ public class HttpDestinationOverHTTP extends PoolingHttpDestination<HttpConnecti
}
@Override
- protected void send(HttpConnectionOverHTTP connection, HttpExchange exchange)
+ protected void send(Connection connection, HttpExchange exchange)
{
- connection.send(exchange);
+ ((HttpConnectionOverHTTP)connection).send(exchange);
}
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java
index c957249474..bf6c039d46 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java
@@ -88,6 +88,17 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
buffer = null;
}
+ protected ByteBuffer onUpgradeFrom()
+ {
+ if (BufferUtil.hasContent(buffer))
+ {
+ ByteBuffer upgradeBuffer = ByteBuffer.allocate(buffer.remaining());
+ upgradeBuffer.put(buffer);
+ return upgradeBuffer;
+ }
+ return null;
+ }
+
private void process()
{
try
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java b/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java
index 416a5fd19e..917f51a0fc 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/util/MultiPartContentProvider.java
@@ -116,8 +116,8 @@ public class MultiPartContentProvider extends AbstractTypedContentProvider imple
* <p>The {@code Content-Type} of this part will be obtained from:</p>
* <ul>
* <li>the {@code Content-Type} header in the {@code fields} parameter; otherwise</li>
- * <li>the {@link Typed#getContentType()} method if the {@code content} parameter
- * implements {@link Typed}; otherwise</li>
+ * <li>the {@link org.eclipse.jetty.client.api.ContentProvider.Typed#getContentType()} method if the {@code content} parameter
+ * implements {@link org.eclipse.jetty.client.api.ContentProvider.Typed}; otherwise</li>
* <li>"text/plain"</li>
* </ul>
*
@@ -136,8 +136,8 @@ public class MultiPartContentProvider extends AbstractTypedContentProvider imple
* <p>The {@code Content-Type} of this part will be obtained from:</p>
* <ul>
* <li>the {@code Content-Type} header in the {@code fields} parameter; otherwise</li>
- * <li>the {@link Typed#getContentType()} method if the {@code content} parameter
- * implements {@link Typed}; otherwise</li>
+ * <li>the {@link org.eclipse.jetty.client.api.ContentProvider.Typed#getContentType()} method if the {@code content} parameter
+ * implements {@link org.eclipse.jetty.client.api.ContentProvider.Typed}; otherwise</li>
* <li>"application/octet-stream"</li>
* </ul>
*
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java
index c54f88981e..dd35154613 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientExplicitConnectionTest.java
@@ -59,7 +59,7 @@ public class HttpClientExplicitConnectionTest extends AbstractHttpClientServerTe
Assert.assertEquals(200, response.getStatus());
HttpDestinationOverHTTP httpDestination = (HttpDestinationOverHTTP)destination;
- DuplexConnectionPool connectionPool = httpDestination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)httpDestination.getConnectionPool();
Assert.assertTrue(connectionPool.getActiveConnections().isEmpty());
Assert.assertTrue(connectionPool.getIdleConnections().isEmpty());
}
@@ -94,7 +94,7 @@ public class HttpClientExplicitConnectionTest extends AbstractHttpClientServerTe
Assert.assertFalse(httpConnection.getEndPoint().isOpen());
HttpDestinationOverHTTP httpDestination = (HttpDestinationOverHTTP)destination;
- DuplexConnectionPool connectionPool = httpDestination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)httpDestination.getConnectionPool();
Assert.assertTrue(connectionPool.getActiveConnections().isEmpty());
Assert.assertTrue(connectionPool.getIdleConnections().isEmpty());
}
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java
index 0db34443c2..e7ab277f20 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientFailureTest.java
@@ -25,9 +25,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.client.api.Connection;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.api.Response;
-import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.client.http.HttpConnectionOverHTTP;
import org.eclipse.jetty.client.util.DeferredContentProvider;
@@ -89,14 +86,7 @@ public class HttpClientFailureTest
try
{
client.newRequest("localhost", connector.getLocalPort())
- .onRequestHeaders(new Request.HeadersListener()
- {
- @Override
- public void onHeaders(Request request)
- {
- connectionRef.get().getEndPoint().close();
- }
- })
+ .onRequestHeaders(request -> connectionRef.get().getEndPoint().close())
.timeout(5, TimeUnit.SECONDS)
.send();
Assert.fail();
@@ -106,7 +96,7 @@ public class HttpClientFailureTest
// Expected.
}
- DuplexConnectionPool connectionPool = connectionRef.get().getHttpDestination().getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)connectionRef.get().getHttpDestination().getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
@@ -134,25 +124,17 @@ public class HttpClientFailureTest
final CountDownLatch completeLatch = new CountDownLatch(1);
DeferredContentProvider content = new DeferredContentProvider();
client.newRequest("localhost", connector.getLocalPort())
- .onRequestCommit(new Request.CommitListener()
+ .onRequestCommit(request ->
{
- @Override
- public void onCommit(Request request)
- {
- connectionRef.get().getEndPoint().close();
- commitLatch.countDown();
- }
+ connectionRef.get().getEndPoint().close();
+ commitLatch.countDown();
})
.content(content)
.idleTimeout(2, TimeUnit.SECONDS)
- .send(new Response.CompleteListener()
+ .send(result ->
{
- @Override
- public void onComplete(Result result)
- {
- if (result.isFailed())
- completeLatch.countDown();
- }
+ if (result.isFailed())
+ completeLatch.countDown();
});
Assert.assertTrue(commitLatch.await(5, TimeUnit.SECONDS));
@@ -170,7 +152,7 @@ public class HttpClientFailureTest
Assert.assertTrue(contentLatch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
- DuplexConnectionPool connectionPool = connectionRef.get().getHttpDestination().getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)connectionRef.get().getHttpDestination().getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
index 6117b1be60..404a3e8e3f 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
@@ -114,7 +114,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
Assert.assertEquals(200, response.getStatus());
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
long start = System.nanoTime();
HttpConnectionOverHTTP connection = null;
@@ -646,7 +646,8 @@ public class HttpClientTest extends AbstractHttpClientServerTest
.onRequestBegin(request ->
{
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- destination.getConnectionPool().getActiveConnections().peek().close();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
+ connectionPool.getActiveConnections().iterator().next().close();
})
.send(new Response.Listener.Adapter()
{
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTimeoutTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTimeoutTest.java
index e41ee143d3..9ed138fa11 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTimeoutTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTimeoutTest.java
@@ -448,7 +448,7 @@ public class HttpClientTimeoutTest extends AbstractHttpClientServerTest
start(new EmptyServerHandler());
long timeout = 1000;
- Request request = client.newRequest("badscheme://localhost:" + connector.getLocalPort());
+ Request request = client.newRequest("badscheme://localhost:badport");
try
{
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdown.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdown.java
index b899a1f211..bc80ff7aae 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdown.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdown.java
@@ -31,8 +31,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.Connection;
-import org.eclipse.jetty.client.api.Response;
-import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.http.HttpChannelOverHTTP;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.client.http.HttpConnectionOverHTTP;
@@ -121,14 +119,7 @@ public class HttpClientUploadDuringServerShutdown
int length = 16 * 1024 * 1024 + random.nextInt(16 * 1024 * 1024);
client.newRequest("localhost", 8888)
.content(new BytesContentProvider(new byte[length]))
- .send(new Response.CompleteListener()
- {
- @Override
- public void onComplete(Result result)
- {
- latch.countDown();
- }
- });
+ .send(result -> latch.countDown());
long sleep = 1 + random.nextInt(10);
TimeUnit.MILLISECONDS.sleep(sleep);
}
@@ -244,35 +235,24 @@ public class HttpClientUploadDuringServerShutdown
final CountDownLatch completeLatch = new CountDownLatch(1);
client.newRequest("localhost", connector.getLocalPort())
.timeout(10, TimeUnit.SECONDS)
- .onRequestBegin(new org.eclipse.jetty.client.api.Request.BeginListener()
+ .onRequestBegin(request ->
{
- @Override
- public void onBegin(org.eclipse.jetty.client.api.Request request)
+ try
{
- try
- {
- beginLatch.countDown();
- completeLatch.await(5, TimeUnit.SECONDS);
- }
- catch (InterruptedException x)
- {
- x.printStackTrace();
- }
+ beginLatch.countDown();
+ completeLatch.await(5, TimeUnit.SECONDS);
}
- })
- .send(new Response.CompleteListener()
- {
- @Override
- public void onComplete(Result result)
+ catch (InterruptedException x)
{
- completeLatch.countDown();
+ x.printStackTrace();
}
- });
+ })
+ .send(result -> completeLatch.countDown());
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", connector.getLocalPort());
- DuplexConnectionPool pool = destination.getConnectionPool();
+ DuplexConnectionPool pool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, pool.getConnectionCount());
Assert.assertEquals(0, pool.getIdleConnections().size());
Assert.assertEquals(0, pool.getActiveConnections().size());
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java
index f8cbb04c5a..684ff02dce 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpConnectionLifecycleTest.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.client;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Queue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -69,35 +70,24 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
- final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
+ final Collection<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
final CountDownLatch headersLatch = new CountDownLatch(1);
final CountDownLatch successLatch = new CountDownLatch(3);
client.newRequest(host, port)
.scheme(scheme)
- .onRequestSuccess(new Request.SuccessListener()
- {
- @Override
- public void onSuccess(Request request)
- {
- successLatch.countDown();
- }
- })
- .onResponseHeaders(new Response.HeadersListener()
+ .onRequestSuccess(request -> successLatch.countDown())
+ .onResponseHeaders(response ->
{
- @Override
- public void onHeaders(Response response)
- {
- Assert.assertEquals(0, idleConnections.size());
- Assert.assertEquals(1, activeConnections.size());
- headersLatch.countDown();
- }
+ Assert.assertEquals(0, idleConnections.size());
+ Assert.assertEquals(1, activeConnections.size());
+ headersLatch.countDown();
})
.send(new Response.Listener.Adapter()
{
@@ -130,12 +120,12 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
- final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
+ final Collection<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
final CountDownLatch beginLatch = new CountDownLatch(1);
@@ -145,7 +135,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
@Override
public void onBegin(Request request)
{
- activeConnections.peek().close();
+ activeConnections.iterator().next().close();
beginLatch.countDown();
}
@@ -181,12 +171,12 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
final CountDownLatch successLatch = new CountDownLatch(3);
@@ -241,12 +231,12 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
- final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
+ final Collection<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
final long delay = 1000;
@@ -314,12 +304,12 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
- final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
+ final Collection<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
server.stop();
@@ -327,22 +317,11 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
final CountDownLatch failureLatch = new CountDownLatch(2);
client.newRequest(host, port)
.scheme(scheme)
- .onRequestFailure(new Request.FailureListener()
+ .onRequestFailure((request, failure) -> failureLatch.countDown())
+ .send(result ->
{
- @Override
- public void onFailure(Request request, Throwable failure)
- {
- failureLatch.countDown();
- }
- })
- .send(new Response.Listener.Adapter()
- {
- @Override
- public void onComplete(Result result)
- {
- Assert.assertTrue(result.isFailed());
- failureLatch.countDown();
- }
+ Assert.assertTrue(result.isFailed());
+ failureLatch.countDown();
});
Assert.assertTrue(failureLatch.await(5, TimeUnit.SECONDS));
@@ -367,12 +346,12 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
- final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
+ final Collection<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
final CountDownLatch latch = new CountDownLatch(1);
@@ -417,12 +396,12 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
- final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
+ final Collection<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
Log.getLogger(HttpConnection.class).info("Expecting java.lang.IllegalStateException: HttpParser{s=CLOSED,...");
@@ -467,12 +446,12 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
- final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
+ final Collection<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
ContentResponse response = client.newRequest(host, port)
@@ -499,25 +478,21 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
String host = "localhost";
int port = connector.getLocalPort();
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
- final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
+ final Collection<Connection> idleConnections = connectionPool.getIdleConnections();
Assert.assertEquals(0, idleConnections.size());
- final Queue<Connection> activeConnections = connectionPool.getActiveConnections();
+ final Collection<Connection> activeConnections = connectionPool.getActiveConnections();
Assert.assertEquals(0, activeConnections.size());
client.setStrictEventOrdering(false);
ContentResponse response = client.newRequest(host, port)
.scheme(scheme)
- .onResponseBegin(new Response.BeginListener()
+ .onResponseBegin(response1 ->
{
- @Override
- public void onBegin(Response response)
- {
- // Simulate a HTTP 1.0 response has been received.
- ((HttpResponse)response).version(HttpVersion.HTTP_1_0);
- }
+ // Simulate a HTTP 1.0 response has been received.
+ ((HttpResponse)response1).version(HttpVersion.HTTP_1_0);
})
.send();
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java
index 45b78e7d18..4b33e574e1 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpRequestAbortTest.java
@@ -25,12 +25,12 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
+
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.http.HttpDestinationOverHTTP;
import org.eclipse.jetty.client.util.ByteBufferContentProvider;
@@ -88,7 +88,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
}
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
@@ -135,7 +135,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
}
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
@@ -182,7 +182,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
}
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
@@ -204,14 +204,10 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
{
client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
- .onRequestCommit(new Request.CommitListener()
+ .onRequestCommit(request ->
{
- @Override
- public void onCommit(Request request)
- {
- aborted.set(request.abort(cause));
- latch.countDown();
- }
+ aborted.set(request.abort(cause));
+ latch.countDown();
})
.timeout(5, TimeUnit.SECONDS)
.send();
@@ -225,7 +221,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
}
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
@@ -260,14 +256,10 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
{
client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
- .onRequestCommit(new Request.CommitListener()
+ .onRequestCommit(request ->
{
- @Override
- public void onCommit(Request request)
- {
- aborted.set(request.abort(cause));
- latch.countDown();
- }
+ aborted.set(request.abort(cause));
+ latch.countDown();
})
.content(new ByteBufferContentProvider(ByteBuffer.wrap(new byte[]{0}), ByteBuffer.wrap(new byte[]{1}))
{
@@ -289,7 +281,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
}
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
@@ -315,14 +307,10 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
{
client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
- .onRequestContent(new Request.ContentListener()
+ .onRequestContent((request, content) ->
{
- @Override
- public void onContent(Request request, ByteBuffer content)
- {
- aborted.set(request.abort(cause));
- latch.countDown();
- }
+ aborted.set(request.abort(cause));
+ latch.countDown();
})
.content(new ByteBufferContentProvider(ByteBuffer.wrap(new byte[]{0}), ByteBuffer.wrap(new byte[]{1}))
{
@@ -344,7 +332,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
}
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
@@ -454,7 +442,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
}
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
@@ -486,15 +474,11 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
Request request = client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
.timeout(3 * delay, TimeUnit.MILLISECONDS);
- request.send(new Response.CompleteListener()
+ request.send(result ->
{
- @Override
- public void onComplete(Result result)
- {
- Assert.assertTrue(result.isFailed());
- Assert.assertSame(cause, result.getFailure());
- latch.countDown();
- }
+ Assert.assertTrue(result.isFailed());
+ Assert.assertSame(cause, result.getFailure());
+ latch.countDown();
});
TimeUnit.MILLISECONDS.sleep(delay);
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java
index 23d72de601..47a7760e1a 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ServerConnectionCloseTest.java
@@ -151,7 +151,7 @@ public class ServerConnectionCloseTest
// Connection should have been removed from pool.
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getIdleConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnectionCount());
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java
index 79a9cd1879..d48ed22314 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/TLSServerConnectionCloseTest.java
@@ -183,7 +183,7 @@ public class TLSServerConnectionCloseTest
// Connection should have been removed from pool.
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", port);
- DuplexConnectionPool connectionPool = destination.getConnectionPool();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
Assert.assertEquals(0, connectionPool.getConnectionCount());
Assert.assertEquals(0, connectionPool.getIdleConnectionCount());
Assert.assertEquals(0, connectionPool.getActiveConnectionCount());
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTPTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTPTest.java
index aa3b4f5e74..bf9af834d9 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTPTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpDestinationOverHTTPTest.java
@@ -24,6 +24,7 @@ import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.client.AbstractHttpClientServerTest;
+import org.eclipse.jetty.client.ConnectionPool;
import org.eclipse.jetty.client.DuplexConnectionPool;
import org.eclipse.jetty.client.EmptyServerHandler;
import org.eclipse.jetty.client.HttpClient;
@@ -31,9 +32,6 @@ import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Destination;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.api.Response;
-import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.util.ssl.SslContextFactory;
@@ -59,11 +57,13 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
public void test_FirstAcquire_WithEmptyQueue() throws Exception
{
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", connector.getLocalPort()));
- Connection connection = destination.acquire();
+ destination.start();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
+ Connection connection = connectionPool.acquire();
if (connection == null)
{
// There are no queued requests, so the newly created connection will be idle
- connection = timedPoll(destination.getConnectionPool().getIdleConnections(), 5, TimeUnit.SECONDS);
+ connection = timedPoll(connectionPool.getIdleConnections(), 5, TimeUnit.SECONDS);
}
Assert.assertNotNull(connection);
}
@@ -72,7 +72,9 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
public void test_SecondAcquire_AfterFirstAcquire_WithEmptyQueue_ReturnsSameConnection() throws Exception
{
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", connector.getLocalPort()));
- Connection connection1 = destination.acquire();
+ destination.start();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
+ Connection connection1 = connectionPool.acquire();
if (connection1 == null)
{
// There are no queued requests, so the newly created connection will be idle
@@ -80,11 +82,11 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
while (connection1 == null && TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start) < 5)
{
TimeUnit.MILLISECONDS.sleep(50);
- connection1 = destination.getConnectionPool().getIdleConnections().peek();
+ connection1 = connectionPool.getIdleConnections().peek();
}
Assert.assertNotNull(connection1);
- Connection connection2 = destination.acquire();
+ Connection connection2 = connectionPool.acquire();
Assert.assertSame(connection1, connection2);
}
}
@@ -97,18 +99,18 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", connector.getLocalPort()))
{
@Override
- protected DuplexConnectionPool newConnectionPool(HttpClient client)
+ protected ConnectionPool newConnectionPool(HttpClient client)
{
return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
{
@Override
- protected void idleCreated(Connection connection)
+ protected void onCreated(Connection connection)
{
try
{
idleLatch.countDown();
latch.await(5, TimeUnit.SECONDS);
- super.idleCreated(connection);
+ super.onCreated(connection);
}
catch (InterruptedException x)
{
@@ -118,7 +120,9 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
};
}
};
- Connection connection1 = destination.acquire();
+ destination.start();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
+ Connection connection1 = connectionPool.acquire();
// Make sure we entered idleCreated().
Assert.assertTrue(idleLatch.await(5, TimeUnit.SECONDS));
@@ -128,13 +132,13 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
Assert.assertNull(connection1);
// Second attempt also returns null because we delayed idleCreated() above.
- Connection connection2 = destination.acquire();
+ Connection connection2 = connectionPool.acquire();
Assert.assertNull(connection2);
latch.countDown();
// There must be 2 idle connections.
- Queue<Connection> idleConnections = destination.getConnectionPool().getIdleConnections();
+ Queue<Connection> idleConnections = connectionPool.getIdleConnections();
Connection connection = timedPoll(idleConnections, 5, TimeUnit.SECONDS);
Assert.assertNotNull(connection);
connection = timedPoll(idleConnections, 5, TimeUnit.SECONDS);
@@ -145,23 +149,25 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
public void test_Acquire_Process_Release_Acquire_ReturnsSameConnection() throws Exception
{
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", connector.getLocalPort()));
- HttpConnectionOverHTTP connection1 = destination.acquire();
+ destination.start();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
+ HttpConnectionOverHTTP connection1 = (HttpConnectionOverHTTP)connectionPool.acquire();
long start = System.nanoTime();
while (connection1 == null && TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start) < 5)
{
TimeUnit.MILLISECONDS.sleep(50);
- connection1 = (HttpConnectionOverHTTP)destination.getConnectionPool().getIdleConnections().peek();
+ connection1 = (HttpConnectionOverHTTP)connectionPool.getIdleConnections().peek();
}
Assert.assertNotNull(connection1);
// Acquire the connection to make it active
- Assert.assertSame(connection1, destination.acquire());
+ Assert.assertSame(connection1, connectionPool.acquire());
destination.process(connection1);
destination.release(connection1);
- Connection connection2 = destination.acquire();
+ Connection connection2 = connectionPool.acquire();
Assert.assertSame(connection1, connection2);
}
@@ -172,7 +178,9 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
client.setIdleTimeout(idleTimeout);
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", connector.getLocalPort()));
- Connection connection1 = destination.acquire();
+ destination.start();
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
+ Connection connection1 = connectionPool.acquire();
if (connection1 == null)
{
// There are no queued requests, so the newly created connection will be idle
@@ -180,13 +188,13 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
while (connection1 == null && TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start) < 5)
{
TimeUnit.MILLISECONDS.sleep(50);
- connection1 = destination.getConnectionPool().getIdleConnections().peek();
+ connection1 = connectionPool.getIdleConnections().peek();
}
Assert.assertNotNull(connection1);
TimeUnit.MILLISECONDS.sleep(2 * idleTimeout);
- connection1 = destination.getConnectionPool().getIdleConnections().poll();
+ connection1 = connectionPool.getIdleConnections().poll();
Assert.assertNull(connection1);
}
}
@@ -210,35 +218,23 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme)
.path("/one")
- .onRequestQueued(new Request.QueuedListener()
+ .onRequestQueued(request ->
{
- @Override
- public void onQueued(Request request)
- {
- // This request exceeds the maximum queued, should fail
- client.newRequest("localhost", connector.getLocalPort())
- .scheme(scheme)
- .path("/two")
- .send(new Response.CompleteListener()
- {
- @Override
- public void onComplete(Result result)
- {
- Assert.assertTrue(result.isFailed());
- Assert.assertThat(result.getRequestFailure(), Matchers.instanceOf(RejectedExecutionException.class));
- failureLatch.countDown();
- }
- });
- }
+ // This request exceeds the maximum queued, should fail
+ client.newRequest("localhost", connector.getLocalPort())
+ .scheme(scheme)
+ .path("/two")
+ .send(result ->
+ {
+ Assert.assertTrue(result.isFailed());
+ Assert.assertThat(result.getRequestFailure(), Matchers.instanceOf(RejectedExecutionException.class));
+ failureLatch.countDown();
+ });
})
- .send(new Response.CompleteListener()
+ .send(result ->
{
- @Override
- public void onComplete(Result result)
- {
- if (result.isSucceeded())
- successLatch.countDown();
- }
+ if (result.isSucceeded())
+ successLatch.countDown();
});
Assert.assertTrue(failureLatch.await(5, TimeUnit.SECONDS));
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java
index e057cf34f9..feb5cf0c58 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java
@@ -30,6 +30,7 @@ import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.client.HttpRequest;
import org.eclipse.jetty.client.HttpResponseException;
import org.eclipse.jetty.client.Origin;
+import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.util.FutureResponseListener;
import org.eclipse.jetty.http.HttpFields;
@@ -60,6 +61,7 @@ public class HttpReceiverOverHTTPTest
client = new HttpClient();
client.start();
destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
+ destination.start();
endPoint = new ByteArrayEndPoint();
connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<>());
endPoint.setConnection(connection);
@@ -235,7 +237,7 @@ public class HttpReceiverOverHTTPTest
}
};
endPoint.setConnection(connection);
-
+
// Partial response to trigger the call to fillInterested().
endPoint.addInput("" +
"HTTP/1.1 200 OK\r\n" +
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java
index b98aea13ab..e592c42ca8 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpSenderOverHTTPTest.java
@@ -67,6 +67,7 @@ public class HttpSenderOverHTTPTest
{
ByteArrayEndPoint endPoint = new ByteArrayEndPoint();
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
+ destination.start();
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<Connection>());
Request request = client.newRequest(URI.create("http://localhost/"));
final CountDownLatch headersLatch = new CountDownLatch(1);
@@ -100,6 +101,7 @@ public class HttpSenderOverHTTPTest
{
ByteArrayEndPoint endPoint = new ByteArrayEndPoint("", 16);
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
+ destination.start();
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<Connection>());
Request request = client.newRequest(URI.create("http://localhost/"));
connection.send(request, null);
@@ -129,6 +131,7 @@ public class HttpSenderOverHTTPTest
// Shutdown output to trigger the exception on write
endPoint.shutdownOutput();
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
+ destination.start();
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<Connection>());
Request request = client.newRequest(URI.create("http://localhost/"));
final CountDownLatch failureLatch = new CountDownLatch(2);
@@ -158,6 +161,7 @@ public class HttpSenderOverHTTPTest
{
ByteArrayEndPoint endPoint = new ByteArrayEndPoint("", 16);
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
+ destination.start();
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<Connection>());
Request request = client.newRequest(URI.create("http://localhost/"));
final CountDownLatch failureLatch = new CountDownLatch(2);
@@ -193,6 +197,7 @@ public class HttpSenderOverHTTPTest
{
ByteArrayEndPoint endPoint = new ByteArrayEndPoint();
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
+ destination.start();
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<Connection>());
Request request = client.newRequest(URI.create("http://localhost/"));
String content = "abcdef";
@@ -227,6 +232,7 @@ public class HttpSenderOverHTTPTest
{
ByteArrayEndPoint endPoint = new ByteArrayEndPoint();
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
+ destination.start();
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<Connection>());
Request request = client.newRequest(URI.create("http://localhost/"));
String content1 = "0123456789";
@@ -262,6 +268,7 @@ public class HttpSenderOverHTTPTest
{
ByteArrayEndPoint endPoint = new ByteArrayEndPoint();
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", 8080));
+ destination.start();
HttpConnectionOverHTTP connection = new HttpConnectionOverHTTP(endPoint, destination, new Promise.Adapter<Connection>());
Request request = client.newRequest(URI.create("http://localhost/"));
String content1 = "0123456789";
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java
index 8dd287f492..535f7ecd89 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java
@@ -54,10 +54,10 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.ssl.SslBytesTest.TLSRecord.Type;
import org.eclipse.jetty.http.HttpParser;
+import org.eclipse.jetty.io.ChannelEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ManagedSelector;
-import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConnection;
@@ -173,9 +173,9 @@ public class SslBytesServerTest extends SslBytesTest
ServerConnector connector = new ServerConnector(server, null,null,null,1,1,sslFactory, httpFactory)
{
@Override
- protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key) throws IOException
+ protected ChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key) throws IOException
{
- SelectChannelEndPoint endp = super.newEndPoint(channel,selectSet,key);
+ ChannelEndPoint endp = super.newEndPoint(channel,selectSet,key);
serverEndPoint.set(endp);
return endp;
}
@@ -367,11 +367,19 @@ public class SslBytesServerTest extends SslBytesTest
System.arraycopy(doneBytes, 0, chunk, recordBytes.length, doneBytes.length);
System.arraycopy(closeRecordBytes, 0, chunk, recordBytes.length + doneBytes.length, closeRecordBytes.length);
proxy.flushToServer(0, chunk);
+
// Close the raw socket
proxy.flushToServer(null);
// Expect the server to send a FIN as well
record = proxy.readFromServer();
+ if (record!=null)
+ {
+ // Close alert snuck out // TODO check if this is acceptable
+ Assert.assertEquals(Type.ALERT,record.getType());
+ record = proxy.readFromServer();
+ }
+
Assert.assertNull(record);
// Check that we did not spin
diff --git a/jetty-client/src/test/resources/jetty-logging.properties b/jetty-client/src/test/resources/jetty-logging.properties
index 1c19e5331e..5f8794e83f 100644
--- a/jetty-client/src/test/resources/jetty-logging.properties
+++ b/jetty-client/src/test/resources/jetty-logging.properties
@@ -1,3 +1,4 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
#org.eclipse.jetty.LEVEL=DEBUG
#org.eclipse.jetty.client.LEVEL=DEBUG
+#org.eclipse.jetty.io.ChannelEndPoint.LEVEL=DEBUG \ No newline at end of file
diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml
index 94659c5514..edd16b1f70 100644
--- a/jetty-continuation/pom.xml
+++ b/jetty-continuation/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-continuation</artifactId>
diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml
index 9e898a4da4..9f94d9e73b 100644
--- a/jetty-deploy/pom.xml
+++ b/jetty-deploy/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-deploy</artifactId>
diff --git a/jetty-deploy/src/main/config/modules/deploy.mod b/jetty-deploy/src/main/config/modules/deploy.mod
index f567a2090f..794868bfb4 100644
--- a/jetty-deploy/src/main/config/modules/deploy.mod
+++ b/jetty-deploy/src/main/config/modules/deploy.mod
@@ -1,6 +1,5 @@
-#
-# Deploy Feature
-#
+[description]
+Enables webapplication deployment from the webapps directory.
[depend]
webapp
diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml
index f106ee4fe3..9878feb1ce 100644
--- a/jetty-distribution/pom.xml
+++ b/jetty-distribution/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<artifactId>jetty-distribution</artifactId>
<name>Jetty :: Distribution Assemblies</name>
@@ -711,6 +711,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-unixsocket</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.jetty.fcgi</groupId>
<artifactId>fcgi-server</artifactId>
<version>${project.version}</version>
diff --git a/jetty-distribution/src/main/resources/modules/hawtio.mod b/jetty-distribution/src/main/resources/modules/hawtio.mod
index f6d0d9d511..fcc34d1504 100644
--- a/jetty-distribution/src/main/resources/modules/hawtio.mod
+++ b/jetty-distribution/src/main/resources/modules/hawtio.mod
@@ -1,6 +1,5 @@
-#
-# Hawtio x module
-#
+[description]
+Deploys the Hawtio console as a webapplication.
[depend]
stats
diff --git a/jetty-distribution/src/main/resources/modules/jamon.mod b/jetty-distribution/src/main/resources/modules/jamon.mod
index 2d1f144d1b..77cc3d1e9d 100644
--- a/jetty-distribution/src/main/resources/modules/jamon.mod
+++ b/jetty-distribution/src/main/resources/modules/jamon.mod
@@ -1,6 +1,5 @@
-#
-# JAMon Jetty module
-#
+[description]
+Deploys the JAMon webapplication
[depend]
stats
diff --git a/jetty-distribution/src/main/resources/modules/jminix.mod b/jetty-distribution/src/main/resources/modules/jminix.mod
index 05788f0915..81a75c7350 100644
--- a/jetty-distribution/src/main/resources/modules/jminix.mod
+++ b/jetty-distribution/src/main/resources/modules/jminix.mod
@@ -1,6 +1,5 @@
-#
-# JaMON Jetty module
-#
+[description]
+Deploys the Jminix JMX Console within the server
[depend]
stats
diff --git a/jetty-distribution/src/main/resources/modules/jolokia.mod b/jetty-distribution/src/main/resources/modules/jolokia.mod
index da8ac8f8c2..efe8a59185 100644
--- a/jetty-distribution/src/main/resources/modules/jolokia.mod
+++ b/jetty-distribution/src/main/resources/modules/jolokia.mod
@@ -1,6 +1,5 @@
-#
-# Jolokia Jetty module
-#
+[description]
+Deploys the Jolokia console as a web application.
[depend]
stats
diff --git a/jetty-distribution/src/main/resources/modules/jsp.mod b/jetty-distribution/src/main/resources/modules/jsp.mod
index a16cc93dc9..2bc7ba8522 100644
--- a/jetty-distribution/src/main/resources/modules/jsp.mod
+++ b/jetty-distribution/src/main/resources/modules/jsp.mod
@@ -1,6 +1,5 @@
-#
-# Jetty JSP Module
-#
+[description]
+Enables JSP for all webapplications deployed on the server.
[depend]
servlet
diff --git a/jetty-distribution/src/main/resources/modules/jstl.mod b/jetty-distribution/src/main/resources/modules/jstl.mod
index efc310af6e..dedb2c052c 100644
--- a/jetty-distribution/src/main/resources/modules/jstl.mod
+++ b/jetty-distribution/src/main/resources/modules/jstl.mod
@@ -1,6 +1,5 @@
-#
-# Jetty JSTL Module
-#
+[description]
+Enables JSTL for all webapplications deployed on the server
[depend]
jsp
diff --git a/jetty-distribution/src/main/resources/modules/setuid.mod b/jetty-distribution/src/main/resources/modules/setuid.mod
index 41ef757e82..c1174ccba8 100644
--- a/jetty-distribution/src/main/resources/modules/setuid.mod
+++ b/jetty-distribution/src/main/resources/modules/setuid.mod
@@ -1,6 +1,7 @@
-#
-# Set UID Feature
-#
+[description]
+Enables the unix setUID configuration so that the server
+may be started as root to open privileged ports/files before
+changing to a restricted user (eg jetty).
[depend]
server
diff --git a/jetty-fcgi/fcgi-client/pom.xml b/jetty-fcgi/fcgi-client/pom.xml
index 72d5bf0f23..8cf9e9a68b 100644
--- a/jetty-fcgi/fcgi-client/pom.xml
+++ b/jetty-fcgi/fcgi-client/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.fcgi</groupId>
<artifactId>fcgi-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpDestinationOverFCGI.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpDestinationOverFCGI.java
index f6adf480c4..2f3447d384 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpDestinationOverFCGI.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpDestinationOverFCGI.java
@@ -22,8 +22,9 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.PoolingHttpDestination;
+import org.eclipse.jetty.client.api.Connection;
-public class HttpDestinationOverFCGI extends PoolingHttpDestination<HttpConnectionOverFCGI>
+public class HttpDestinationOverFCGI extends PoolingHttpDestination
{
public HttpDestinationOverFCGI(HttpClient client, Origin origin)
{
@@ -31,8 +32,8 @@ public class HttpDestinationOverFCGI extends PoolingHttpDestination<HttpConnecti
}
@Override
- protected void send(HttpConnectionOverFCGI connection, HttpExchange exchange)
+ protected void send(Connection connection, HttpExchange exchange)
{
- connection.send(exchange);
+ ((HttpConnectionOverFCGI)connection).send(exchange);
}
}
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/MultiplexHttpDestinationOverFCGI.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/MultiplexHttpDestinationOverFCGI.java
index 77f2259d80..80bb63cc47 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/MultiplexHttpDestinationOverFCGI.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/MultiplexHttpDestinationOverFCGI.java
@@ -22,8 +22,9 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.client.MultiplexHttpDestination;
import org.eclipse.jetty.client.Origin;
+import org.eclipse.jetty.client.api.Connection;
-public class MultiplexHttpDestinationOverFCGI extends MultiplexHttpDestination<HttpConnectionOverFCGI>
+public class MultiplexHttpDestinationOverFCGI extends MultiplexHttpDestination
{
public MultiplexHttpDestinationOverFCGI(HttpClient client, Origin origin)
{
@@ -31,8 +32,8 @@ public class MultiplexHttpDestinationOverFCGI extends MultiplexHttpDestination<H
}
@Override
- protected void send(HttpConnectionOverFCGI connection, HttpExchange exchange)
+ protected void send(Connection connection, HttpExchange exchange)
{
- connection.send(exchange);
+ ((HttpConnectionOverFCGI)connection).send(exchange);
}
}
diff --git a/jetty-fcgi/fcgi-server/pom.xml b/jetty-fcgi/fcgi-server/pom.xml
index 15921a3dbd..271ef70033 100644
--- a/jetty-fcgi/fcgi-server/pom.xml
+++ b/jetty-fcgi/fcgi-server/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.fcgi</groupId>
<artifactId>fcgi-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-fcgi/fcgi-server/src/main/config/modules/fcgi.mod b/jetty-fcgi/fcgi-server/src/main/config/modules/fcgi.mod
index 14152d5f2b..6a4beaf1ab 100644
--- a/jetty-fcgi/fcgi-server/src/main/config/modules/fcgi.mod
+++ b/jetty-fcgi/fcgi-server/src/main/config/modules/fcgi.mod
@@ -1,6 +1,5 @@
-#
-# FastCGI Module
-#
+[description]
+Adds the FastCGI implementation to the classpath.
[depend]
servlet
diff --git a/jetty-fcgi/pom.xml b/jetty-fcgi/pom.xml
index db17bbeb4f..d3f278cff6 100644
--- a/jetty-fcgi/pom.xml
+++ b/jetty-fcgi/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-gcloud/gcloud-session-manager/pom.xml b/jetty-gcloud/gcloud-session-manager/pom.xml
index c25002b078..5110e61e4d 100644
--- a/jetty-gcloud/gcloud-session-manager/pom.xml
+++ b/jetty-gcloud/gcloud-session-manager/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.gcloud</groupId>
<artifactId>gcloud-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-gcloud/gcloud-session-manager/src/main/config/etc/jetty-gcloud-sessions.xml b/jetty-gcloud/gcloud-session-manager/src/main/config/etc/jetty-gcloud-sessions.xml
index 72f9da6a51..b1b9a844db 100644
--- a/jetty-gcloud/gcloud-session-manager/src/main/config/etc/jetty-gcloud-sessions.xml
+++ b/jetty-gcloud/gcloud-session-manager/src/main/config/etc/jetty-gcloud-sessions.xml
@@ -7,11 +7,12 @@
<!-- GCloud configuration. -->
<!-- Note: passwords can use jetty obfuscation. See -->
<!-- https://www.eclipse.org/jetty/documentation/current/configuring-security-secure-passwords.html -->
+ <!-- See your start.ini or gcloud-sessions.ini file for more configuration information. -->
<!-- ============================================================================================== -->
<New id="gconf" class="org.eclipse.jetty.gcloud.session.GCloudConfiguration">
- <!-- To contact remote gclouddatastore set the following properties in start.ini -->
<!-- Either set jetty.gcloudSession.projectId or use system property/env var DATASTORE_DATASET-->
<Set name="projectId"><Property name="jetty.gcloudSession.projectId"/></Set>
+ <!-- To contact remote gclouddatastore set the following properties in start.ini -->
<Set name="p12File"><Property name="jetty.gcloudSession.p12File"/></Set>
<Set name="serviceAccount"><Property name="jetty.gcloudSession.serviceAccount"/></Set>
<Set name="password"><Property name="jetty.gcloudSession.password"/></Set>
diff --git a/jetty-gcloud/gcloud-session-manager/src/main/config/modules/gcloud-sessions.mod b/jetty-gcloud/gcloud-session-manager/src/main/config/modules/gcloud-sessions.mod
index 0780a60ba9..3a6aaef03a 100644
--- a/jetty-gcloud/gcloud-session-manager/src/main/config/modules/gcloud-sessions.mod
+++ b/jetty-gcloud/gcloud-session-manager/src/main/config/modules/gcloud-sessions.mod
@@ -1,6 +1,5 @@
-#
-# Jetty GCloudDatastore Session Manager module
-#
+[description]
+Enables the GCloudDatastore Session Mananger module.
[depend]
annotations
diff --git a/jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java b/jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java
index b6b39a9bba..a6137e47ea 100644
--- a/jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java
+++ b/jetty-gcloud/gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionManager.java
@@ -829,6 +829,7 @@ public class GCloudSessionManager extends AbstractSessionManager
if (memSession == null)
{
memSession = session;
+ _sessionsStats.increment();
}
//final check
@@ -1008,6 +1009,7 @@ public class GCloudSessionManager extends AbstractSessionManager
{
//indicate that the session was reinflated
session.didActivate();
+ _sessionsStats.increment();
LOG.debug("getSession({}): loaded session from cluster", idInCluster);
}
return session;
diff --git a/jetty-gcloud/pom.xml b/jetty-gcloud/pom.xml
index 252416ecec..75d9bad29d 100644
--- a/jetty-gcloud/pom.xml
+++ b/jetty-gcloud/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-http-spi/pom.xml b/jetty-http-spi/pom.xml
index 2c959b1538..03b9cd780c 100644
--- a/jetty-http-spi/pom.xml
+++ b/jetty-http-spi/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-http-spi</artifactId>
diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml
index 494e675256..8455a9d324 100644
--- a/jetty-http/pom.xml
+++ b/jetty-http/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-http</artifactId>
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpHeader.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpHeader.java
index 54735cb57a..edf83768ef 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpHeader.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpHeader.java
@@ -101,6 +101,16 @@ public enum HttpHeader
WWW_AUTHENTICATE("WWW-Authenticate"),
/* ------------------------------------------------------------ */
+ /** WebSocket Fields.
+ */
+ ORIGIN("Origin"),
+ SEC_WEBSOCKET_KEY("Sec-WebSocket-Key"),
+ SEC_WEBSOCKET_VERSION("Sec-WebSocket-Version"),
+ SEC_WEBSOCKET_EXTENSIONS("Sec-WebSocket-Extensions"),
+ SEC_WEBSOCKET_SUBPROTOCOL("Sec-WebSocket-Protocol"),
+ SEC_WEBSOCKET_ACCEPT("Sec-WebSocket-Accept"),
+
+ /* ------------------------------------------------------------ */
/** Other Fields.
*/
COOKIE("Cookie"),
@@ -125,7 +135,7 @@ public enum HttpHeader
/* ------------------------------------------------------------ */
- public final static Trie<HttpHeader> CACHE= new ArrayTrie<>(530);
+ public final static Trie<HttpHeader> CACHE= new ArrayTrie<>(630);
static
{
for (HttpHeader header : HttpHeader.values())
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java
index bd1ec11dd0..2f44419fd7 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java
@@ -119,6 +119,7 @@ public class HttpURI
public HttpURI(HttpURI uri)
{
this(uri._scheme,uri._host,uri._port,uri._path,uri._param,uri._query,uri._fragment);
+ _uri=uri._uri;
}
/* ------------------------------------------------------------ */
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java b/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java
index b4038cbdb9..43bc07d794 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java
@@ -158,7 +158,6 @@ public class MetaData implements Iterable<HttpField>
this(request.getMethod(),new HttpURI(request.getURI()), request.getVersion(), new HttpFields(request.getFields()), request.getContentLength());
}
- // TODO MetaData should be immuttable!!!
public void recycle()
{
super.recycle();
diff --git a/jetty-http2/http2-alpn-tests/pom.xml b/jetty-http2/http2-alpn-tests/pom.xml
index 4084bb118b..8a1521e4b4 100644
--- a/jetty-http2/http2-alpn-tests/pom.xml
+++ b/jetty-http2/http2-alpn-tests/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-http2/http2-client/pom.xml b/jetty-http2/http2-client/pom.xml
index db91dd1a75..56fb4ddff9 100644
--- a/jetty-http2/http2-client/pom.xml
+++ b/jetty-http2/http2-client/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java
index 6256a6d2c4..142d10bf4b 100644
--- a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java
+++ b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2Client.java
@@ -20,6 +20,7 @@ package org.eclipse.jetty.http2.client;
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.Arrays;
@@ -36,8 +37,8 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.MappedByteBufferPool;
-import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
+import org.eclipse.jetty.io.SocketChannelEndPoint;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
@@ -318,13 +319,15 @@ public class HTTP2Client extends ContainerLifeCycle
}
@Override
- protected EndPoint newEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey selectionKey) throws IOException
+ protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey selectionKey) throws IOException
{
- return new SelectChannelEndPoint(channel, selector, selectionKey, getScheduler(), getIdleTimeout());
+ SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, selectionKey, getScheduler());
+ endp.setIdleTimeout(getIdleTimeout());
+ return endp;
}
@Override
- public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException
+ public Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment) throws IOException
{
@SuppressWarnings("unchecked")
Map<String, Object> context = (Map<String, Object>)attachment;
@@ -335,7 +338,7 @@ public class HTTP2Client extends ContainerLifeCycle
}
@Override
- protected void connectionFailed(SocketChannel channel, Throwable failure, Object attachment)
+ protected void connectionFailed(SelectableChannel channel, Throwable failure, Object attachment)
{
@SuppressWarnings("unchecked")
Map<String, Object> context = (Map<String, Object>)attachment;
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java
index 5ea92308e7..e27ca4ab9f 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/FlowControlStrategyTest.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Exchanger;
import java.util.concurrent.TimeUnit;
@@ -64,6 +65,7 @@ import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -293,11 +295,16 @@ public abstract class FlowControlStrategyTest
Stream stream = promise.get(5, TimeUnit.SECONDS);
// Send first chunk that exceeds the window.
- stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(size * 2), false), Callback.NOOP);
+ Callback.Completable completable = new Callback.Completable();
+ stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(size * 2), false), completable);
settingsLatch.await(5, TimeUnit.SECONDS);
- // Send the second chunk of data, must not arrive since we're flow control stalled on the client.
- stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(size * 2), true), Callback.NOOP);
+ completable.thenRun(() ->
+ {
+ // Send the second chunk of data, must not arrive since we're flow control stalled on the client.
+ stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(size * 2), true), Callback.NOOP);
+ });
+
Assert.assertFalse(dataLatch.await(1, TimeUnit.SECONDS));
// Consume the data arrived to server, this will resume flow control on the client.
@@ -325,10 +332,13 @@ public abstract class FlowControlStrategyTest
{
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
- stream.headers(responseFrame, Callback.NOOP);
-
- DataFrame dataFrame = new DataFrame(stream.getId(), ByteBuffer.allocate(length), true);
- stream.data(dataFrame, Callback.NOOP);
+ CompletableFuture<Void> completable = new CompletableFuture<>();
+ stream.headers(responseFrame, Callback.from(completable));
+ completable.thenRun(() ->
+ {
+ DataFrame dataFrame = new DataFrame(stream.getId(), ByteBuffer.allocate(length), true);
+ stream.data(dataFrame, Callback.NOOP);
+ });
return null;
}
});
@@ -416,7 +426,7 @@ public abstract class FlowControlStrategyTest
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
{
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
- HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
+ HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
stream.headers(responseFrame, Callback.NOOP);
return new Stream.Listener.Adapter()
{
@@ -527,9 +537,13 @@ public abstract class FlowControlStrategyTest
// For every stream, send down half the window size of data.
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
- stream.headers(responseFrame, Callback.NOOP);
- DataFrame dataFrame = new DataFrame(stream.getId(), ByteBuffer.allocate(windowSize / 2), true);
- stream.data(dataFrame, Callback.NOOP);
+ Callback.Completable completable = new Callback.Completable();
+ stream.headers(responseFrame, completable);
+ completable.thenRun(() ->
+ {
+ DataFrame dataFrame = new DataFrame(stream.getId(), ByteBuffer.allocate(windowSize / 2), true);
+ stream.data(dataFrame, Callback.NOOP);
+ });
return null;
}
}
@@ -615,9 +629,13 @@ public abstract class FlowControlStrategyTest
{
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
- stream.headers(responseFrame, Callback.NOOP);
- DataFrame dataFrame = new DataFrame(stream.getId(), ByteBuffer.wrap(data), true);
- stream.data(dataFrame, Callback.NOOP);
+ Callback.Completable completable = new Callback.Completable();
+ stream.headers(responseFrame, completable);
+ completable.thenRun(() ->
+ {
+ DataFrame dataFrame = new DataFrame(stream.getId(), ByteBuffer.wrap(data), true);
+ stream.data(dataFrame, Callback.NOOP);
+ });
return null;
}
});
@@ -647,6 +665,11 @@ public abstract class FlowControlStrategyTest
Assert.assertArrayEquals(data, bytes);
}
+ // TODO
+ // Since we changed the API to disallow consecutive data() calls without waiting
+ // for the callback, it is now not possible to have DATA1, DATA2 in the queue for
+ // the same stream. Perhaps this test should just be deleted.
+ @Ignore
@Test
public void testServerTwoDataFramesWithStalledStream() throws Exception
{
@@ -734,7 +757,8 @@ public abstract class FlowControlStrategyTest
{
MetaData metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
- stream.headers(responseFrame, Callback.NOOP);
+ Callback.Completable completable = new Callback.Completable();
+ stream.headers(responseFrame, completable);
return new Stream.Listener.Adapter()
{
@Override
@@ -745,7 +769,8 @@ public abstract class FlowControlStrategyTest
ByteBuffer data = frame.getData();
ByteBuffer copy = ByteBuffer.allocateDirect(data.remaining());
copy.put(data).flip();
- stream.data(new DataFrame(stream.getId(), copy, frame.isEndStream()), callback);
+ completable.thenRun(() ->
+ stream.data(new DataFrame(stream.getId(), copy, frame.isEndStream()), callback));
}
};
}
@@ -770,9 +795,9 @@ public abstract class FlowControlStrategyTest
final ByteBuffer responseContent = ByteBuffer.wrap(responseData);
MetaData.Request metaData = newRequest("GET", new HttpFields());
HeadersFrame requestFrame = new HeadersFrame(metaData, null, false);
- FuturePromise<Stream> streamPromise = new FuturePromise<>();
+ Promise.Completable<Stream> completable = new Promise.Completable<>();
final CountDownLatch latch = new CountDownLatch(1);
- session.newStream(requestFrame, streamPromise, new Stream.Listener.Adapter()
+ session.newStream(requestFrame, completable, new Stream.Listener.Adapter()
{
@Override
public void onData(Stream stream, DataFrame frame, Callback callback)
@@ -783,11 +808,12 @@ public abstract class FlowControlStrategyTest
latch.countDown();
}
});
- Stream stream = streamPromise.get(5, TimeUnit.SECONDS);
-
- ByteBuffer requestContent = ByteBuffer.wrap(requestData);
- DataFrame dataFrame = new DataFrame(stream.getId(), requestContent, true);
- stream.data(dataFrame, Callback.NOOP);
+ completable.thenAccept(stream ->
+ {
+ ByteBuffer requestContent = ByteBuffer.wrap(requestData);
+ DataFrame dataFrame = new DataFrame(stream.getId(), requestContent, true);
+ stream.data(dataFrame, Callback.NOOP);
+ });
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
@@ -815,9 +841,9 @@ public abstract class FlowControlStrategyTest
// Consume the whole session and stream window.
MetaData.Request metaData = newRequest("POST", new HttpFields());
HeadersFrame requestFrame = new HeadersFrame(metaData, null, false);
- FuturePromise<Stream> streamPromise = new FuturePromise<>();
- session.newStream(requestFrame, streamPromise, new Stream.Listener.Adapter());
- Stream stream = streamPromise.get(5, TimeUnit.SECONDS);
+ CompletableFuture<Stream> completable = new CompletableFuture<>();
+ session.newStream(requestFrame, Promise.from(completable), new Stream.Listener.Adapter());
+ Stream stream = completable.get(5, TimeUnit.SECONDS);
ByteBuffer data = ByteBuffer.allocate(FlowControlStrategy.DEFAULT_WINDOW_SIZE);
final CountDownLatch dataLatch = new CountDownLatch(1);
stream.data(new DataFrame(stream.getId(), data, false), new Callback.NonBlocking()
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java
index 1f68283fcf..405e6d8d56 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/HTTP2Test.java
@@ -20,6 +20,7 @@ package org.eclipse.jetty.http2.client;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.channels.WritePendingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@@ -263,7 +264,7 @@ public class HTTP2Test extends AbstractTest
}
});
- Thread.sleep(1000);
+ sleep(1000);
server.stop();
@@ -285,7 +286,7 @@ public class HTTP2Test extends AbstractTest
newClient(new Session.Listener.Adapter());
- Thread.sleep(1000);
+ sleep(1000);
client.stop();
@@ -416,4 +417,183 @@ public class HTTP2Test extends AbstractTest
Assert.assertTrue(exchangeLatch2.await(5, TimeUnit.SECONDS));
Assert.assertEquals(0, session.getStreams().size());
}
+
+ @Test
+ public void testInvalidAPIUsageOnClient() throws Exception
+ {
+ start(new ServerSessionListener.Adapter()
+ {
+ @Override
+ public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
+ {
+ Callback.Completable completable = new Callback.Completable();
+ MetaData.Response response = new MetaData.Response(HttpVersion.HTTP_2, HttpStatus.OK_200, new HttpFields());
+ stream.headers(new HeadersFrame(stream.getId(), response, null, false), completable);
+ return new Stream.Listener.Adapter()
+ {
+ @Override
+ public void onData(Stream stream, DataFrame frame, Callback callback)
+ {
+ callback.succeeded();
+ if (frame.isEndStream())
+ {
+ completable.thenRun(() ->
+ {
+ DataFrame endFrame = new DataFrame(stream.getId(), BufferUtil.EMPTY_BUFFER, true);
+ stream.data(endFrame, Callback.NOOP);
+ });
+ }
+ }
+ };
+ }
+ });
+
+ Session session = newClient(new Session.Listener.Adapter());
+
+ MetaData.Request metaData = newRequest("GET", new HttpFields());
+ HeadersFrame frame = new HeadersFrame(metaData, null, false);
+ Promise.Completable<Stream> completable = new Promise.Completable<>();
+ CountDownLatch completeLatch = new CountDownLatch(2);
+ session.newStream(frame, completable, new Stream.Listener.Adapter()
+ {
+ @Override
+ public void onData(Stream stream, DataFrame frame, Callback callback)
+ {
+ callback.succeeded();
+ if (frame.isEndStream())
+ completeLatch.countDown();
+ }
+ });
+ Stream stream = completable.get(5, TimeUnit.SECONDS);
+
+ long sleep = 1000;
+ DataFrame data1 = new DataFrame(stream.getId(), ByteBuffer.allocate(1024), false)
+ {
+ @Override
+ public ByteBuffer getData()
+ {
+ sleep(2 * sleep);
+ return super.getData();
+ }
+ };
+ DataFrame data2 = new DataFrame(stream.getId(), BufferUtil.EMPTY_BUFFER, true);
+
+ new Thread(() ->
+ {
+ // The first data() call is legal, but slow.
+ stream.data(data1, new Callback()
+ {
+ @Override
+ public void succeeded()
+ {
+ stream.data(data2, NOOP);
+ }
+ });
+ }).start();
+
+ // Wait for the first data() call to happen.
+ sleep(sleep);
+
+ // This data call is illegal because it does not
+ // wait for the previous callback to complete.
+ stream.data(data2, new Callback()
+ {
+ @Override
+ public void failed(Throwable x)
+ {
+ if (x instanceof WritePendingException)
+ {
+ // Expected.
+ completeLatch.countDown();
+ }
+ }
+ });
+
+ Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
+ }
+
+ @Test
+ public void testInvalidAPIUsageOnServer() throws Exception
+ {
+ long sleep = 1000;
+ CountDownLatch completeLatch = new CountDownLatch(2);
+ start(new ServerSessionListener.Adapter()
+ {
+ @Override
+ public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
+ {
+ MetaData.Response response = new MetaData.Response(HttpVersion.HTTP_2, HttpStatus.OK_200, new HttpFields());
+ DataFrame dataFrame = new DataFrame(stream.getId(), BufferUtil.EMPTY_BUFFER, true);
+ // The call to headers() is legal, but slow.
+ new Thread(() ->
+ {
+ stream.headers(new HeadersFrame(stream.getId(), response, null, false)
+ {
+ @Override
+ public MetaData getMetaData()
+ {
+ sleep(2 * sleep);
+ return super.getMetaData();
+ }
+ }, new Callback()
+ {
+ @Override
+ public void succeeded()
+ {
+ stream.data(dataFrame, NOOP);
+ }
+ });
+ }).start();
+
+ // Wait for the headers() call to happen.
+ sleep(sleep);
+
+ // This data call is illegal because it does not
+ // wait for the previous callback to complete.
+ stream.data(dataFrame, new Callback()
+ {
+ @Override
+ public void failed(Throwable x)
+ {
+ if (x instanceof WritePendingException)
+ {
+ // Expected.
+ completeLatch.countDown();
+ }
+ }
+ });
+
+ return null;
+ }
+ });
+
+ Session session = newClient(new Session.Listener.Adapter());
+
+ MetaData.Request metaData = newRequest("GET", new HttpFields());
+ HeadersFrame frame = new HeadersFrame(metaData, null, true);
+ session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter()
+ {
+ @Override
+ public void onData(Stream stream, DataFrame frame, Callback callback)
+ {
+ callback.succeeded();
+ if (frame.isEndStream())
+ completeLatch.countDown();
+ }
+ });
+
+ Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
+ }
+
+ private static void sleep(long time)
+ {
+ try
+ {
+ Thread.sleep(time);
+ }
+ catch (InterruptedException x)
+ {
+ throw new RuntimeException();
+ }
+ }
}
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java
index f03a3f6699..bbcb3727ca 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java
@@ -512,12 +512,20 @@ public class IdleTimeoutTest extends AbstractTest
session.newStream(requestFrame, promise, new Stream.Listener.Adapter());
final Stream stream = promise.get(5, TimeUnit.SECONDS);
+ Callback.Completable completable1 = new Callback.Completable();
sleep(idleTimeout / 2);
- stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(1), false), Callback.NOOP);
- sleep(idleTimeout / 2);
- stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(1), false), Callback.NOOP);
- sleep(idleTimeout / 2);
- stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(1), true), Callback.NOOP);
+ stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(1), false), completable1);
+ completable1.thenCompose(nil ->
+ {
+ Callback.Completable completable2 = new Callback.Completable();
+ sleep(idleTimeout / 2);
+ stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(1), false), completable2);
+ return completable2;
+ }).thenRun(() ->
+ {
+ sleep(idleTimeout / 2);
+ stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(1), true), Callback.NOOP);
+ });
Assert.assertFalse(resetLatch.await(0, TimeUnit.SECONDS));
}
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java
index 650cc26746..f72199e465 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/ProxyProtocolTest.java
@@ -48,6 +48,7 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.FuturePromise;
import org.eclipse.jetty.util.Promise;
+import org.eclipse.jetty.util.TypeUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
@@ -80,13 +81,25 @@ public class ProxyProtocolTest
}
@Test
- public void test_PROXY_GET() throws Exception
+ public void test_PROXY_GET_v1() throws Exception
{
startServer(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
+ try
+ {
+ Assert.assertEquals("1.2.3.4",request.getRemoteAddr());
+ Assert.assertEquals(1111,request.getRemotePort());
+ Assert.assertEquals("5.6.7.8",request.getLocalAddr());
+ Assert.assertEquals(2222,request.getLocalPort());
+ }
+ catch(Throwable th)
+ {
+ th.printStackTrace();
+ response.setStatus(500);
+ }
baseRequest.setHandled(true);
}
});
@@ -118,4 +131,56 @@ public class ProxyProtocolTest
});
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
}
+
+ @Test
+ public void test_PROXY_GET_v2() throws Exception
+ {
+ startServer(new AbstractHandler()
+ {
+ @Override
+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ try
+ {
+ Assert.assertEquals("10.0.0.4",request.getRemoteAddr());
+ Assert.assertEquals(33824,request.getRemotePort());
+ Assert.assertEquals("10.0.0.4",request.getLocalAddr());
+ Assert.assertEquals(8888,request.getLocalPort());
+ }
+ catch(Throwable th)
+ {
+ th.printStackTrace();
+ response.setStatus(500);
+ }
+ baseRequest.setHandled(true);
+ }
+ });
+
+ String request1 = "0D0A0D0A000D0A515549540A211100140A0000040A000004842022B82000050000000000";
+ SocketChannel channel = SocketChannel.open();
+ channel.connect(new InetSocketAddress("localhost", connector.getLocalPort()));
+ channel.write(ByteBuffer.wrap(TypeUtil.fromHexString(request1)));
+
+ FuturePromise<Session> promise = new FuturePromise<>();
+ client.accept(null, channel, new Session.Listener.Adapter(), promise);
+ Session session = promise.get(5, TimeUnit.SECONDS);
+
+ HttpFields fields = new HttpFields();
+ String uri = "http://localhost:" + connector.getLocalPort() + "/";
+ MetaData.Request metaData = new MetaData.Request("GET", new HttpURI(uri), HttpVersion.HTTP_2, fields);
+ HeadersFrame frame = new HeadersFrame(metaData, null, true);
+ CountDownLatch latch = new CountDownLatch(1);
+ session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter()
+ {
+ @Override
+ public void onHeaders(Stream stream, HeadersFrame frame)
+ {
+ MetaData.Response response = (MetaData.Response)frame.getMetaData();
+ Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
+ if (frame.isEndStream())
+ latch.countDown();
+ }
+ });
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
+ }
}
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java
index 8a86944f37..2210402f7c 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamCloseTest.java
@@ -122,24 +122,26 @@ public class StreamCloseTest extends AbstractTest
{
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
HeadersFrame response = new HeadersFrame(stream.getId(), metaData, null, false);
- stream.headers(response, Callback.NOOP);
+ Callback.Completable completable = new Callback.Completable();
+ stream.headers(response, completable);
return new Stream.Listener.Adapter()
{
@Override
public void onData(final Stream stream, DataFrame frame, final Callback callback)
{
Assert.assertTrue(((HTTP2Stream)stream).isRemotelyClosed());
- stream.data(frame, new Callback()
- {
- @Override
- public void succeeded()
- {
- Assert.assertTrue(stream.isClosed());
- Assert.assertEquals(0, stream.getSession().getStreams().size());
- callback.succeeded();
- serverDataLatch.countDown();
- }
- });
+ completable.thenRun(() ->
+ stream.data(frame, new Callback()
+ {
+ @Override
+ public void succeeded()
+ {
+ Assert.assertTrue(stream.isClosed());
+ Assert.assertEquals(0, stream.getSession().getStreams().size());
+ callback.succeeded();
+ serverDataLatch.countDown();
+ }
+ }));
}
};
}
diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java
index 7e5d60e5ca..39efd253d3 100644
--- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java
+++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/StreamResetTest.java
@@ -37,6 +37,7 @@ import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http2.ErrorCode;
+import org.eclipse.jetty.http2.IStream;
import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.http2.api.Stream;
import org.eclipse.jetty.http2.api.server.ServerSessionListener;
@@ -126,29 +127,38 @@ public class StreamResetTest extends AbstractTest
{
MetaData.Response response = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), response, null, false);
- stream.headers(responseFrame, Callback.NOOP);
+ Callback.Completable completable = new Callback.Completable();
+ stream.headers(responseFrame, completable);
return new Stream.Listener.Adapter()
{
@Override
public void onData(Stream stream, DataFrame frame, Callback callback)
{
callback.succeeded();
- stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(16), true), Callback.NOOP);
- serverDataLatch.countDown();
+ completable.thenRun(() ->
+ stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(16), true), new Callback()
+ {
+ @Override
+ public void succeeded()
+ {
+ serverDataLatch.countDown();
+ }
+ }));
}
@Override
- public void onReset(Stream stream, ResetFrame frame)
+ public void onReset(Stream s, ResetFrame frame)
{
// Simulate that there is pending data to send.
- stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(16), true), new Callback()
+ IStream stream = (IStream)s;
+ stream.getSession().frames(stream, new Callback()
{
@Override
public void failed(Throwable x)
{
serverResetLatch.countDown();
}
- });
+ }, new DataFrame(s.getId(), ByteBuffer.allocate(16), true));
}
};
}
diff --git a/jetty-http2/http2-common/pom.xml b/jetty-http2/http2-common/pom.xml
index be2213dc8f..e78abaa202 100644
--- a/jetty-http2/http2-common/pom.xml
+++ b/jetty-http2/http2-common/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
index a3efe4057c..29daa61f8e 100644
--- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
+++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
@@ -1165,9 +1165,10 @@ public abstract class HTTP2Session implements ISession, Parser.Listener
if (dataFrame.remaining() > 0)
{
// We have written part of the frame, but there is more to write.
- // We need to keep the correct ordering of frames, to avoid that other
- // frames for the same stream are written before this one is finished.
- flusher.prepend(this);
+ // The API will not allow to send two data frames for the same
+ // stream so we append the unfinished frame at the end to allow
+ // better interleaving with other streams.
+ flusher.append(this);
}
else
{
diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java
index 8e63f54262..4d56983048 100644
--- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java
+++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java
@@ -20,6 +20,7 @@ package org.eclipse.jetty.http2;
import java.io.EOFException;
import java.io.IOException;
+import java.nio.channels.WritePendingException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeoutException;
@@ -39,12 +40,13 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
-public class HTTP2Stream extends IdleTimeout implements IStream
+public class HTTP2Stream extends IdleTimeout implements IStream, Callback
{
private static final Logger LOG = Log.getLogger(HTTP2Stream.class);
private final AtomicReference<ConcurrentMap<String, Object>> attributes = new AtomicReference<>();
private final AtomicReference<CloseState> closeState = new AtomicReference<>(CloseState.NOT_CLOSED);
+ private final AtomicReference<Callback> writing = new AtomicReference<>();
private final AtomicInteger sendWindow = new AtomicInteger();
private final AtomicInteger recvWindow = new AtomicInteger();
private final ISession session;
@@ -83,8 +85,10 @@ public class HTTP2Stream extends IdleTimeout implements IStream
@Override
public void headers(HeadersFrame frame, Callback callback)
{
+ if (!checkWrite(callback))
+ return;
notIdle();
- session.frames(this, callback, frame, Frame.EMPTY_ARRAY);
+ session.frames(this, this, frame, Frame.EMPTY_ARRAY);
}
@Override
@@ -97,8 +101,10 @@ public class HTTP2Stream extends IdleTimeout implements IStream
@Override
public void data(DataFrame frame, Callback callback)
{
+ if (!checkWrite(callback))
+ return;
notIdle();
- session.data(this, callback, frame);
+ session.data(this, this, frame);
}
@Override
@@ -111,6 +117,14 @@ public class HTTP2Stream extends IdleTimeout implements IStream
session.frames(this, callback, frame, Frame.EMPTY_ARRAY);
}
+ private boolean checkWrite(Callback callback)
+ {
+ if (writing.compareAndSet(null, callback))
+ return true;
+ callback.failed(new WritePendingException());
+ return false;
+ }
+
@Override
public Object getAttribute(String key)
{
@@ -360,6 +374,20 @@ public class HTTP2Stream extends IdleTimeout implements IStream
onClose();
}
+ @Override
+ public void succeeded()
+ {
+ Callback callback = writing.getAndSet(null);
+ callback.succeeded();
+ }
+
+ @Override
+ public void failed(Throwable x)
+ {
+ Callback callback = writing.getAndSet(null);
+ callback.failed(x);
+ }
+
private void notifyData(Stream stream, DataFrame frame, Callback callback)
{
final Listener listener = this.listener;
diff --git a/jetty-http2/http2-hpack/pom.xml b/jetty-http2/http2-hpack/pom.xml
index d2054129c2..407e2db982 100644
--- a/jetty-http2/http2-hpack/pom.xml
+++ b/jetty-http2/http2-hpack/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-http2/http2-http-client-transport/pom.xml b/jetty-http2/http2-http-client-transport/pom.xml
index 728b0fc328..ce3acc9cfb 100644
--- a/jetty-http2/http2-http-client-transport/pom.xml
+++ b/jetty-http2/http2-http-client-transport/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpDestinationOverHTTP2.java b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpDestinationOverHTTP2.java
index b83d52371a..114df6f3f6 100644
--- a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpDestinationOverHTTP2.java
+++ b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpDestinationOverHTTP2.java
@@ -22,8 +22,9 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.client.MultiplexHttpDestination;
import org.eclipse.jetty.client.Origin;
+import org.eclipse.jetty.client.api.Connection;
-public class HttpDestinationOverHTTP2 extends MultiplexHttpDestination<HttpConnectionOverHTTP2>
+public class HttpDestinationOverHTTP2 extends MultiplexHttpDestination
{
public HttpDestinationOverHTTP2(HttpClient client, Origin origin)
{
@@ -31,8 +32,8 @@ public class HttpDestinationOverHTTP2 extends MultiplexHttpDestination<HttpConne
}
@Override
- protected void send(HttpConnectionOverHTTP2 connection, HttpExchange exchange)
+ protected void send(Connection connection, HttpExchange exchange)
{
- connection.send(exchange);
+ ((HttpConnectionOverHTTP2)connection).send(exchange);
}
}
diff --git a/jetty-http2/http2-server/pom.xml b/jetty-http2/http2-server/pom.xml
index c5bac99a11..78e4dc35c4 100644
--- a/jetty-http2/http2-server/pom.xml
+++ b/jetty-http2/http2-server/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-http2/http2-server/src/main/config/modules/http2.mod b/jetty-http2/http2-server/src/main/config/modules/http2.mod
index 585c1fa5ee..ece1e331b5 100644
--- a/jetty-http2/http2-server/src/main/config/modules/http2.mod
+++ b/jetty-http2/http2-server/src/main/config/modules/http2.mod
@@ -1,6 +1,6 @@
-#
-# HTTP2 Support Module
-#
+[description]
+Enables HTTP2 protocol support on the TLS(SSL) Connector,
+using the ALPN extension to select which protocol to use.
[depend]
ssl
diff --git a/jetty-http2/http2-server/src/main/config/modules/http2c.mod b/jetty-http2/http2-server/src/main/config/modules/http2c.mod
index 1c78016598..dfca925ee5 100644
--- a/jetty-http2/http2-server/src/main/config/modules/http2c.mod
+++ b/jetty-http2/http2-server/src/main/config/modules/http2c.mod
@@ -1,9 +1,6 @@
-#
-# HTTP2 Clear Text Support Module
-# This module adds support for HTTP/2 clear text to the
-# HTTP/1 clear text connector (defined in jetty-http.xml).
-# The resulting connector will accept both HTTP/1 and HTTP/2 connections.
-#
+[description]
+Enables the HTTP2C protocol on the HTTP Connector
+The connector will accept both HTTP/1 and HTTP/2 connections.
[depend]
http
diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java
index 0588930b2b..336e840e48 100644
--- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java
+++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpTransportOverHTTP2.java
@@ -44,7 +44,6 @@ public class HttpTransportOverHTTP2 implements HttpTransport
private static final Logger LOG = Log.getLogger(HttpTransportOverHTTP2.class);
private final AtomicBoolean commit = new AtomicBoolean();
- private final Callback commitCallback = new CommitCallback();
private final Connector connector;
private final HTTP2ServerConnection connection;
private IStream stream;
@@ -62,7 +61,7 @@ public class HttpTransportOverHTTP2 implements HttpTransport
// copying we can defer to the endpoint
return connection.getEndPoint().isOptimizedForDirectBuffers();
}
-
+
public IStream getStream()
{
return stream;
@@ -101,8 +100,24 @@ public class HttpTransportOverHTTP2 implements HttpTransport
{
if (hasContent)
{
- commit(info, false, commitCallback);
- send(content, lastContent, callback);
+ commit(info, false, new Callback()
+ {
+ @Override
+ public void succeeded()
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("HTTP2 Response #{} committed", stream.getId());
+ send(content, lastContent, callback);
+ }
+
+ @Override
+ public void failed(Throwable x)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("HTTP2 Response #" + stream.getId() + " failed to commit", x);
+ callback.failed(x);
+ }
+ });
}
else
{
@@ -145,7 +160,7 @@ public class HttpTransportOverHTTP2 implements HttpTransport
if (LOG.isDebugEnabled())
LOG.debug("HTTP/2 Push {}",request);
-
+
stream.push(new PushPromiseFrame(stream.getId(), 0, request), new Promise<Stream>()
{
@Override
@@ -211,21 +226,4 @@ public class HttpTransportOverHTTP2 implements HttpTransport
if (stream != null)
stream.reset(new ResetFrame(stream.getId(), ErrorCode.INTERNAL_ERROR.code), Callback.NOOP);
}
-
- private class CommitCallback implements Callback.NonBlocking
- {
- @Override
- public void succeeded()
- {
- if (LOG.isDebugEnabled())
- LOG.debug("HTTP2 Response #{} committed", stream.getId());
- }
-
- @Override
- public void failed(Throwable x)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("HTTP2 Response #" + stream.getId() + " failed to commit", x);
- }
- }
}
diff --git a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java
index 554a5b4717..c78bf9f6e6 100644
--- a/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java
+++ b/jetty-http2/http2-server/src/test/java/org/eclipse/jetty/http2/server/HTTP2ServerTest.java
@@ -57,6 +57,7 @@ import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.ChannelEndPoint;
import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.server.HttpChannel;
@@ -329,7 +330,7 @@ public class HTTP2ServerTest extends AbstractServerTest
ServerConnector connector2 = new ServerConnector(server, new HTTP2ServerConnectionFactory(new HttpConfiguration()))
{
@Override
- protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key) throws IOException
+ protected ChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key) throws IOException
{
return new SelectChannelEndPoint(channel, selectSet, key, getScheduler(), getIdleTimeout())
{
diff --git a/jetty-http2/pom.xml b/jetty-http2/pom.xml
index 688750659c..f6ed2ff281 100644
--- a/jetty-http2/pom.xml
+++ b/jetty-http2/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-infinispan/pom.xml b/jetty-infinispan/pom.xml
index 28ed8c875e..37c7f33cac 100644
--- a/jetty-infinispan/pom.xml
+++ b/jetty-infinispan/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-infinispan</artifactId>
diff --git a/jetty-infinispan/src/main/config/modules/infinispan.mod b/jetty-infinispan/src/main/config/modules/infinispan.mod
index afa39fc961..9a1e0b27df 100644
--- a/jetty-infinispan/src/main/config/modules/infinispan.mod
+++ b/jetty-infinispan/src/main/config/modules/infinispan.mod
@@ -1,6 +1,6 @@
-#
-# Jetty Infinispan module
-#
+[description]
+Enables an Infinispan Session Manager for session
+persistance and/or clustering
[depend]
annotations
diff --git a/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java b/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java
index 039263a46c..072d0f1a77 100644
--- a/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java
+++ b/jetty-infinispan/src/main/java/org/eclipse/jetty/session/infinispan/InfinispanSessionManager.java
@@ -664,7 +664,7 @@ public class InfinispanSessionManager extends AbstractSessionManager
for (String candidateId:candidateIds)
{
if (LOG.isDebugEnabled())
- LOG.debug("Session {} expired ", candidateId);
+ LOG.debug("Session {} candidate for expiry", candidateId);
Session candidateSession = _sessions.get(candidateId);
if (candidateSession != null)
@@ -691,6 +691,7 @@ public class InfinispanSessionManager extends AbstractSessionManager
if (LOG.isDebugEnabled()) LOG.debug("Session({}) not local to this session manager, removing from local memory", candidateId);
candidateSession.willPassivate();
_sessions.remove(candidateSession.getClusterId());
+ _sessionsStats.decrement();
}
}
@@ -870,6 +871,7 @@ public class InfinispanSessionManager extends AbstractSessionManager
{
//indicate that the session was reinflated
session.didActivate();
+ _sessionsStats.increment();
LOG.debug("getSession({}): loaded session from cluster", idInCluster);
}
return session;
diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml
index e2d784da4c..3723e68651 100644
--- a/jetty-io/pom.xml
+++ b/jetty-io/pom.xml
@@ -2,7 +2,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-io</artifactId>
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java
index 5b49c8e44c..ceab75bd02 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java
@@ -19,9 +19,9 @@
package org.eclipse.jetty.io;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
@@ -31,10 +31,10 @@ import org.eclipse.jetty.util.thread.Scheduler;
public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
{
+ enum State {OPEN, ISHUTTING, ISHUT, OSHUTTING, OSHUT, CLOSED};
private static final Logger LOG = Log.getLogger(AbstractEndPoint.class);
+ private final AtomicReference<State> _state = new AtomicReference<>(State.OPEN);
private final long _created=System.currentTimeMillis();
- private final InetSocketAddress _local;
- private final InetSocketAddress _remote;
private volatile Connection _connection;
private final FillInterest _fillInterest = new FillInterest()
@@ -55,29 +55,237 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
}
};
- protected AbstractEndPoint(Scheduler scheduler,InetSocketAddress local,InetSocketAddress remote)
+ protected AbstractEndPoint(Scheduler scheduler)
{
super(scheduler);
- _local=local;
- _remote=remote;
+ }
+
+
+ protected final void shutdownInput()
+ {
+ while(true)
+ {
+ State s = _state.get();
+ switch(s)
+ {
+ case OPEN:
+ if (!_state.compareAndSet(s,State.ISHUTTING))
+ continue;
+ try
+ {
+ doShutdownInput();
+ }
+ finally
+ {
+ if(!_state.compareAndSet(State.ISHUTTING,State.ISHUT))
+ {
+ // If somebody else switched to CLOSED while we were ishutting,
+ // then we do the close for them
+ if (_state.get()==State.CLOSED)
+ doOnClose();
+ else
+ throw new IllegalStateException();
+ }
+ }
+ return;
+
+ case ISHUTTING: // Somebody else ishutting
+ case ISHUT: // Already ishut
+ return;
+
+ case OSHUTTING:
+ if (!_state.compareAndSet(s,State.CLOSED))
+ continue;
+ // The thread doing the OSHUT will close
+ return;
+
+ case OSHUT:
+ if (!_state.compareAndSet(s,State.CLOSED))
+ continue;
+ // Already OSHUT so we close
+ doOnClose();
+ return;
+
+ case CLOSED: // already closed
+ return;
+ }
+ }
}
@Override
- public long getCreatedTimeStamp()
+ public final void shutdownOutput()
{
- return _created;
+ while(true)
+ {
+ State s = _state.get();
+ switch(s)
+ {
+ case OPEN:
+ if (!_state.compareAndSet(s,State.OSHUTTING))
+ continue;
+ try
+ {
+ doShutdownOutput();
+ }
+ finally
+ {
+ if(!_state.compareAndSet(State.OSHUTTING,State.OSHUT))
+ {
+ // If somebody else switched to CLOSED while we were oshutting,
+ // then we do the close for them
+ if (_state.get()==State.CLOSED)
+ doOnClose();
+ else
+ throw new IllegalStateException();
+ }
+ }
+ return;
+
+ case ISHUTTING:
+ if (!_state.compareAndSet(s,State.CLOSED))
+ continue;
+ // The thread doing the ISHUT will close
+ return;
+
+ case ISHUT:
+ if (!_state.compareAndSet(s,State.CLOSED))
+ continue;
+ // Already ISHUT so we close
+ doOnClose();
+ return;
+
+ case OSHUTTING: // Somebody else oshutting
+ case OSHUT: // Already oshut
+ return;
+
+ case CLOSED: // already closed
+ return;
+ }
+ }
+ }
+
+ @Override
+ public final void close()
+ {
+ while(true)
+ {
+ State s = _state.get();
+ switch(s)
+ {
+ case OPEN:
+ case ISHUT: // Already ishut
+ case OSHUT: // Already oshut
+ if (!_state.compareAndSet(s,State.CLOSED))
+ continue;
+ doOnClose();
+ return;
+
+ case ISHUTTING: // Somebody else ishutting
+ case OSHUTTING: // Somebody else oshutting
+ if (!_state.compareAndSet(s,State.CLOSED))
+ continue;
+ // The thread doing the IO SHUT will call doOnClose
+ return;
+
+ case CLOSED: // already closed
+ return;
+ }
+ }
+ }
+
+ protected void doShutdownInput()
+ {}
+
+ protected void doShutdownOutput()
+ {}
+
+ protected void doClose()
+ {}
+
+ private void doOnClose()
+ {
+ try
+ {
+ doClose();
+ }
+ finally
+ {
+ onClose();
+ }
+ }
+
+
+ @Override
+ public boolean isOutputShutdown()
+ {
+ switch(_state.get())
+ {
+ case CLOSED:
+ case OSHUT:
+ case OSHUTTING:
+ return true;
+ default:
+ return false;
+ }
+ }
+ @Override
+ public boolean isInputShutdown()
+ {
+ switch(_state.get())
+ {
+ case CLOSED:
+ case ISHUT:
+ case ISHUTTING:
+ return true;
+ default:
+ return false;
+ }
}
@Override
- public InetSocketAddress getLocalAddress()
+ public boolean isOpen()
+ {
+ switch(_state.get())
+ {
+ case CLOSED:
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ public void checkFlush() throws IOException
{
- return _local;
+ State s=_state.get();
+ switch(s)
+ {
+ case OSHUT:
+ case OSHUTTING:
+ case CLOSED:
+ throw new IOException(s.toString());
+ default:
+ break;
+ }
+ }
+
+ public void checkFill() throws IOException
+ {
+ State s=_state.get();
+ switch(s)
+ {
+ case ISHUT:
+ case ISHUTTING:
+ case CLOSED:
+ throw new IOException(s.toString());
+ default:
+ break;
+ }
}
@Override
- public InetSocketAddress getRemoteAddress()
+ public long getCreatedTimeStamp()
{
- return _remote;
+ return _created;
}
@Override
@@ -98,12 +306,22 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
return false;
}
+
+
+ protected void reset()
+ {
+ _state.set(State.OPEN);
+ _writeFlusher.onClose();
+ _fillInterest.onClose();
+ }
+
@Override
public void onOpen()
{
if (LOG.isDebugEnabled())
LOG.debug("onOpen {}",this);
- super.onOpen();
+ if (_state.get()!=State.OPEN)
+ throw new IllegalStateException();
}
@Override
@@ -117,12 +335,6 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
}
@Override
- public void close()
- {
- onClose();
- }
-
- @Override
public void fillInterested(Callback callback) throws IllegalStateException
{
notIdle();
@@ -207,15 +419,13 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
c=c.getSuperclass();
name=c.getSimpleName();
}
-
- return String.format("%s@%x{%s<->%d,%s,%s,%s,%s,%s,%d/%d,%s}",
+
+ return String.format("%s@%x{%s<->%s,%s,%s|%s,%d/%d,%s}",
name,
hashCode(),
getRemoteAddress(),
- getLocalAddress().getPort(),
- isOpen()?"Open":"CLOSED",
- isInputShutdown()?"ISHUT":"in",
- isOutputShutdown()?"OSHUT":"out",
+ getLocalAddress(),
+ _state.get(),
_fillInterest.toStateString(),
_writeFlusher.toStateString(),
getIdleFor(),
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 cbaebf78db..954d0e5742 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
@@ -20,7 +20,10 @@ package org.eclipse.jetty.io;
import java.io.EOFException;
import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.Charset;
@@ -42,7 +45,28 @@ import org.eclipse.jetty.util.thread.Scheduler;
public class ByteArrayEndPoint extends AbstractEndPoint
{
static final Logger LOG = Log.getLogger(ByteArrayEndPoint.class);
- public final static InetSocketAddress NOIP=new InetSocketAddress(0);
+ static final InetAddress NOIP;
+ static final InetSocketAddress NOIPPORT;
+
+ static
+ {
+ InetAddress noip=null;
+ try
+ {
+ noip = Inet4Address.getByName("0.0.0.0");
+ }
+ catch (UnknownHostException e)
+ {
+ LOG.warn(e);
+ }
+ finally
+ {
+ NOIP=noip;
+ NOIPPORT=new InetSocketAddress(NOIP,0);
+ }
+ }
+
+
private static final ByteBuffer EOF = BufferUtil.allocate(0);
private final Runnable _runFillable = new Runnable()
@@ -57,9 +81,6 @@ public class ByteArrayEndPoint extends AbstractEndPoint
private final Locker _locker = new Locker();
private final Queue<ByteBuffer> _inQ = new ArrayQueue<>();
private ByteBuffer _out;
- private boolean _ishut;
- private boolean _oshut;
- private boolean _closed;
private boolean _growOutput;
/* ------------------------------------------------------------ */
@@ -112,11 +133,26 @@ public class ByteArrayEndPoint extends AbstractEndPoint
/* ------------------------------------------------------------ */
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input, ByteBuffer output)
{
- super(timer,NOIP,NOIP);
+ super(timer);
if (BufferUtil.hasContent(input))
addInput(input);
_out=output==null?BufferUtil.allocate(1024):output;
setIdleTimeout(idleTimeoutMs);
+ onOpen();
+ }
+
+ /* ------------------------------------------------------------ */
+ @Override
+ public InetSocketAddress getLocalAddress()
+ {
+ return NOIPPORT;
+ }
+
+ /* ------------------------------------------------------------ */
+ @Override
+ public InetSocketAddress getRemoteAddress()
+ {
+ return NOIPPORT;
}
/* ------------------------------------------------------------ */
@@ -138,7 +174,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
{
try(Locker.Lock lock = _locker.lock())
{
- if (_closed)
+ if (!isOpen())
throw new ClosedChannelException();
ByteBuffer in = _inQ.peek();
@@ -288,92 +324,6 @@ public class ByteArrayEndPoint extends AbstractEndPoint
}
/* ------------------------------------------------------------ */
- /*
- * @see org.eclipse.io.EndPoint#isOpen()
- */
- @Override
- public boolean isOpen()
- {
- try(Locker.Lock lock = _locker.lock())
- {
- return !_closed;
- }
- }
-
- /* ------------------------------------------------------------ */
- /*
- */
- @Override
- public boolean isInputShutdown()
- {
- try(Locker.Lock lock = _locker.lock())
- {
- return _ishut||_closed;
- }
- }
-
- /* ------------------------------------------------------------ */
- /*
- */
- @Override
- public boolean isOutputShutdown()
- {
- try(Locker.Lock lock = _locker.lock())
- {
- return _oshut||_closed;
- }
- }
-
- /* ------------------------------------------------------------ */
- public void shutdownInput()
- {
- boolean close=false;
- try(Locker.Lock lock = _locker.lock())
- {
- _ishut=true;
- if (_oshut && !_closed)
- close=_closed=true;
- }
- if (close)
- super.close();
- }
-
- /* ------------------------------------------------------------ */
- /*
- * @see org.eclipse.io.EndPoint#shutdownOutput()
- */
- @Override
- public void shutdownOutput()
- {
- boolean close=false;
- try(Locker.Lock lock = _locker.lock())
- {
- _oshut=true;
- if (_ishut && !_closed)
- close=_closed=true;
- }
- if (close)
- super.close();
- }
-
- /* ------------------------------------------------------------ */
- /*
- * @see org.eclipse.io.EndPoint#close()
- */
- @Override
- public void close()
- {
- boolean close=false;
- try(Locker.Lock lock = _locker.lock())
- {
- if (!_closed)
- close=_closed=_ishut=_oshut=true;
- }
- if (close)
- super.close();
- }
-
- /* ------------------------------------------------------------ */
/**
* @return <code>true</code> if there are bytes remaining to be read from the encoded input
*/
@@ -390,15 +340,14 @@ public class ByteArrayEndPoint extends AbstractEndPoint
public int fill(ByteBuffer buffer) throws IOException
{
int filled=0;
- boolean close=false;
try(Locker.Lock lock = _locker.lock())
{
while(true)
{
- if (_closed)
+ if (!isOpen())
throw new EofException("CLOSED");
- if (_ishut)
+ if (isInputShutdown())
return -1;
if (_inQ.isEmpty())
@@ -407,9 +356,6 @@ public class ByteArrayEndPoint extends AbstractEndPoint
ByteBuffer in= _inQ.peek();
if (in==EOF)
{
- _ishut=true;
- if (_oshut)
- close=_closed=true;
filled=-1;
break;
}
@@ -425,10 +371,10 @@ public class ByteArrayEndPoint extends AbstractEndPoint
}
}
- if (close)
- super.close();
if (filled>0)
notIdle();
+ else if (filled<0)
+ shutdownInput();
return filled;
}
@@ -439,9 +385,9 @@ public class ByteArrayEndPoint extends AbstractEndPoint
@Override
public boolean flush(ByteBuffer... buffers) throws IOException
{
- if (_closed)
+ if (!isOpen())
throw new IOException("CLOSED");
- if (_oshut)
+ if (isOutputShutdown())
throw new IOException("OSHUT");
boolean flushed=true;
@@ -483,13 +429,12 @@ public class ByteArrayEndPoint extends AbstractEndPoint
*/
public void reset()
{
- getFillInterest().onClose();
- getWriteFlusher().onClose();
- _ishut=false;
- _oshut=false;
- _closed=false;
- _inQ.clear();
+ try(Locker.Lock lock = _locker.lock())
+ {
+ _inQ.clear();
+ }
BufferUtil.clear(_out);
+ super.reset();
}
/* ------------------------------------------------------------ */
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 306e74fb0e..f51e038c57 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
@@ -19,105 +19,123 @@
package org.eclipse.jetty.io;
import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
-import java.nio.channels.SocketChannel;
+import java.nio.channels.CancelledKeyException;
+import java.nio.channels.GatheringByteChannel;
+import java.nio.channels.SelectionKey;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.util.thread.Locker;
import org.eclipse.jetty.util.thread.Scheduler;
/**
* Channel End Point.
* <p>Holds the channel and socket for an NIO endpoint.
*/
-public class ChannelEndPoint extends AbstractEndPoint
+public abstract class ChannelEndPoint extends AbstractEndPoint implements ManagedSelector.Selectable
{
private static final Logger LOG = Log.getLogger(ChannelEndPoint.class);
- private final SocketChannel _channel;
- private final Socket _socket;
- private volatile boolean _ishut;
- private volatile boolean _oshut;
+ private final Locker _locker = new Locker();
+ private final ByteChannel _channel;
+ private final GatheringByteChannel _gather;
+ protected final ManagedSelector _selector;
+ protected final SelectionKey _key;
- public ChannelEndPoint(Scheduler scheduler,SocketChannel channel)
- {
- super(scheduler,
- (InetSocketAddress)channel.socket().getLocalSocketAddress(),
- (InetSocketAddress)channel.socket().getRemoteSocketAddress());
- _channel=channel;
- _socket=channel.socket();
- }
+ private boolean _updatePending;
- @Override
- public boolean isOptimizedForDirectBuffers()
+ /**
+ * The current value for {@link SelectionKey#interestOps()}.
+ */
+ protected int _currentInterestOps;
+
+ /**
+ * The desired value for {@link SelectionKey#interestOps()}.
+ */
+ protected int _desiredInterestOps;
+
+
+ private abstract class RunnableTask implements Runnable
{
- return true;
+ final String _operation;
+ RunnableTask(String op)
+ {
+ _operation=op;
+ }
+
+ @Override
+ public String toString()
+ {
+ return ChannelEndPoint.this.toString()+":"+_operation;
+ }
}
+
+ private final Runnable _runUpdateKey = new RunnableTask("runUpdateKey")
+ {
+ @Override
+ public void run()
+ {
+ updateKey();
+ }
+ };
- @Override
- public boolean isOpen()
+ private final Runnable _runFillable = new RunnableTask("runFillable")
{
- return _channel.isOpen();
- }
+ @Override
+ public void run()
+ {
+ getFillInterest().fillable();
+ }
+ };
- protected void shutdownInput()
+ private final Runnable _runCompleteWrite = new RunnableTask("runCompleteWrite")
{
- if (LOG.isDebugEnabled())
- LOG.debug("ishut {}", this);
- _ishut=true;
- if (_oshut)
- close();
- }
+ @Override
+ public void run()
+ {
+ getWriteFlusher().completeWrite();
+ }
+ };
- @Override
- public void shutdownOutput()
+ private final Runnable _runFillableCompleteWrite = new RunnableTask("runFillableCompleteWrite")
{
- if (LOG.isDebugEnabled())
- LOG.debug("oshut {}", this);
- _oshut = true;
- if (_channel.isOpen())
+ @Override
+ public void run()
{
- try
- {
- if (!_socket.isOutputShutdown())
- _socket.shutdownOutput();
- }
- catch (IOException e)
- {
- LOG.debug(e);
- }
- finally
- {
- if (_ishut)
- {
- close();
- }
- }
+ getFillInterest().fillable();
+ getWriteFlusher().completeWrite();
}
+ };
+
+ public ChannelEndPoint(ByteChannel channel, ManagedSelector selector, SelectionKey key, Scheduler scheduler)
+ {
+ super(scheduler);
+ _channel=channel;
+ _selector=selector;
+ _key=key;
+ _gather=(channel instanceof GatheringByteChannel)?(GatheringByteChannel)channel:null;
}
@Override
- public boolean isOutputShutdown()
+ public boolean isOptimizedForDirectBuffers()
{
- return _oshut || !_channel.isOpen() || _socket.isOutputShutdown();
+ return true;
}
@Override
- public boolean isInputShutdown()
+ public boolean isOpen()
{
- return _ishut || !_channel.isOpen() || _socket.isInputShutdown();
+ return _channel.isOpen();
}
@Override
- public void close()
+ public void doClose()
{
- super.close();
if (LOG.isDebugEnabled())
- LOG.debug("close {}", this);
+ LOG.debug("doClose {}", this);
try
{
_channel.close();
@@ -128,15 +146,29 @@ public class ChannelEndPoint extends AbstractEndPoint
}
finally
{
- _ishut=true;
- _oshut=true;
+ super.doClose();
}
}
+
+ @Override
+ public void onClose()
+ {
+ try
+ {
+ super.onClose();
+ }
+ finally
+ {
+ if (_selector!=null)
+ _selector.onClose(this);
+ }
+ }
+
@Override
public int fill(ByteBuffer buffer) throws IOException
{
- if (_ishut)
+ if (isInputShutdown())
return -1;
int pos=BufferUtil.flipToFill(buffer);
@@ -173,8 +205,8 @@ public class ChannelEndPoint extends AbstractEndPoint
{
if (buffers.length==1)
flushed=_channel.write(buffers[0]);
- else if (buffers.length>1)
- flushed=_channel.write(buffers,0,buffers.length);
+ else if (_gather!=null && buffers.length>1)
+ flushed=_gather.write(buffers,0,buffers.length);
else
{
for (ByteBuffer b : buffers)
@@ -218,20 +250,160 @@ public class ChannelEndPoint extends AbstractEndPoint
return _channel;
}
- public Socket getSocket()
+
+ @Override
+ protected void needsFillInterest()
{
- return _socket;
+ changeInterests(SelectionKey.OP_READ);
}
@Override
protected void onIncompleteFlush()
{
- throw new UnsupportedOperationException();
+ changeInterests(SelectionKey.OP_WRITE);
+ }
+
+ @Override
+ public Runnable onSelected()
+ {
+ /**
+ * This method may run concurrently with {@link #changeInterests(int)}.
+ */
+
+ int readyOps = _key.readyOps();
+ int oldInterestOps;
+ int newInterestOps;
+ try (Locker.Lock lock = _locker.lock())
+ {
+ _updatePending = true;
+ // Remove the readyOps, that here can only be OP_READ or OP_WRITE (or both).
+ oldInterestOps = _desiredInterestOps;
+ newInterestOps = oldInterestOps & ~readyOps;
+ _desiredInterestOps = newInterestOps;
+ }
+
+
+ boolean readable = (readyOps & SelectionKey.OP_READ) != 0;
+ boolean writable = (readyOps & SelectionKey.OP_WRITE) != 0;
+
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("onSelected {}->{} r={} w={} for {}", oldInterestOps, newInterestOps, readable, writable, this);
+
+ // Run non-blocking code immediately.
+ // This producer knows that this non-blocking code is special
+ // and that it must be run in this thread and not fed to the
+ // ExecutionStrategy, which could not have any thread to run these
+ // tasks (or it may starve forever just after having run them).
+ if (readable && getFillInterest().isCallbackNonBlocking())
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Direct readable run {}",this);
+ _runFillable.run();
+ readable = false;
+ }
+ if (writable && getWriteFlusher().isCallbackNonBlocking())
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Direct writable run {}",this);
+ _runCompleteWrite.run();
+ writable = false;
+ }
+
+ // return task to complete the job
+ Runnable task= readable ? (writable ? _runFillableCompleteWrite : _runFillable)
+ : (writable ? _runCompleteWrite : null);
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("task {}",task);
+ return task;
+ }
+
+ @Override
+ public void updateKey()
+ {
+ /**
+ * This method may run concurrently with {@link #changeInterests(int)}.
+ */
+
+ try
+ {
+ int oldInterestOps;
+ int newInterestOps;
+ try (Locker.Lock lock = _locker.lock())
+ {
+ _updatePending = false;
+ oldInterestOps = _currentInterestOps;
+ newInterestOps = _desiredInterestOps;
+ if (oldInterestOps != newInterestOps)
+ {
+ _currentInterestOps = newInterestOps;
+ _key.interestOps(newInterestOps);
+ }
+ }
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Key interests updated {} -> {} on {}", oldInterestOps, newInterestOps, this);
+ }
+ catch (CancelledKeyException x)
+ {
+ LOG.debug("Ignoring key update for concurrently closed channel {}", this);
+ close();
+ }
+ catch (Throwable x)
+ {
+ LOG.warn("Ignoring key update for " + this, x);
+ close();
+ }
+ }
+
+ private void changeInterests(int operation)
+ {
+ /**
+ * This method may run concurrently with
+ * {@link #updateKey()} and {@link #onSelected()}.
+ */
+
+ int oldInterestOps;
+ int newInterestOps;
+ boolean pending;
+ try (Locker.Lock lock = _locker.lock())
+ {
+ pending = _updatePending;
+ oldInterestOps = _desiredInterestOps;
+ newInterestOps = oldInterestOps | operation;
+ if (newInterestOps != oldInterestOps)
+ _desiredInterestOps = newInterestOps;
+ }
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("changeInterests p={} {}->{} for {}", pending, oldInterestOps, newInterestOps, this);
+
+ if (!pending && _selector!=null)
+ _selector.submit(_runUpdateKey);
}
+
@Override
- protected void needsFillInterest() throws IOException
+ public String toString()
{
- throw new UnsupportedOperationException();
+ // We do a best effort to print the right toString() and that's it.
+ try
+ {
+ boolean valid = _key != null && _key.isValid();
+ int keyInterests = valid ? _key.interestOps() : -1;
+ int keyReadiness = valid ? _key.readyOps() : -1;
+ return String.format("%s{io=%d/%d,kio=%d,kro=%d}",
+ super.toString(),
+ _currentInterestOps,
+ _desiredInterestOps,
+ keyInterests,
+ keyReadiness);
+ }
+ catch (Throwable x)
+ {
+ return String.format("%s{io=%s,kio=-2,kro=-2}", super.toString(), _desiredInterestOps);
+ }
}
+
}
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java
index a0f7a5d29d..b47c59058e 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/Connection.java
@@ -63,7 +63,7 @@ public interface Connection extends Closeable
public long getBytesOut();
public long getCreatedTimeStamp();
- public interface UpgradeFrom extends Connection
+ public interface UpgradeFrom
{
/* ------------------------------------------------------------ */
/** Take the input buffer from the connection on upgrade.
@@ -75,7 +75,7 @@ public interface Connection extends Closeable
ByteBuffer onUpgradeFrom();
}
- public interface UpgradeTo extends Connection
+ public interface UpgradeTo
{
/**
* <p>Callback method invoked when this {@link Connection} is upgraded.</p>
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 cb1cda8083..73309e7a61 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
@@ -94,7 +94,7 @@ import org.eclipse.jetty.util.IteratingCallback;
* </pre></blockquote>
*/
public interface EndPoint extends Closeable
-{
+{
/* ------------------------------------------------------------ */
/**
* @return The local Inet address to which this <code>EndPoint</code> is bound, or <code>null</code>
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java b/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java
index b5c48c4b08..8639ee8c91 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java
@@ -131,6 +131,8 @@ public abstract class FillInterest
public void onClose()
{
Callback callback = _interested.get();
+ if (LOG.isDebugEnabled())
+ LOG.debug("{} onClose {}",this,callback);
if (callback != null && _interested.compareAndSet(callback, null))
callback.failed(new ClosedChannelException());
}
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java
index d2a33bff57..30d670c91a 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java
@@ -23,10 +23,9 @@ import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.nio.channels.CancelledKeyException;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
@@ -77,12 +76,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
protected void doStart() throws Exception
{
super.doStart();
- _selector = newSelector();
- }
-
- protected Selector newSelector() throws IOException
- {
- return Selector.open();
+ _selector = _selectorManager.newSelector();
}
public int size()
@@ -137,10 +131,10 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
}
/**
- * A {@link SelectableEndPoint} is an {@link EndPoint} that wish to be
+ * A {@link Selectable} is an {@link EndPoint} that wish to be
* notified of non-blocking events by the {@link ManagedSelector}.
*/
- public interface SelectableEndPoint extends EndPoint
+ public interface Selectable
{
/**
* Callback method invoked when a read or write events has been
@@ -264,12 +258,14 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
if (key.isValid())
{
Object attachment = key.attachment();
+ if (LOG.isDebugEnabled())
+ LOG.debug("selected {} {} ",key,attachment);
try
{
- if (attachment instanceof SelectableEndPoint)
+ if (attachment instanceof Selectable)
{
// Try to produce a task
- Runnable task = ((SelectableEndPoint)attachment).onSelected();
+ Runnable task = ((Selectable)attachment).onSelected();
if (task != null)
return task;
}
@@ -323,8 +319,8 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
private void updateKey(SelectionKey key)
{
Object attachment = key.attachment();
- if (attachment instanceof SelectableEndPoint)
- ((SelectableEndPoint)attachment).updateKey();
+ if (attachment instanceof Selectable)
+ ((Selectable)attachment).updateKey();
}
}
@@ -334,11 +330,11 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
private Runnable processConnect(SelectionKey key, final Connect connect)
{
- SocketChannel channel = (SocketChannel)key.channel();
+ SelectableChannel channel = (SelectableChannel)key.channel();
try
{
key.attach(connect.attachment);
- boolean connected = _selectorManager.finishConnect(channel);
+ boolean connected = _selectorManager.doFinishConnect(channel);
if (LOG.isDebugEnabled())
LOG.debug("Connected {} {}", connected, channel);
if (connected)
@@ -375,14 +371,13 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
private void processAccept(SelectionKey key)
{
- ServerSocketChannel server = (ServerSocketChannel)key.channel();
- SocketChannel channel = null;
+ SelectableChannel server = key.channel();
+ SelectableChannel channel = null;
try
{
- while ((channel = server.accept()) != null)
- {
+ channel = _selectorManager.doAccept(server);
+ if (channel!=null)
_selectorManager.accepted(channel);
- }
}
catch (Throwable x)
{
@@ -404,7 +399,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
}
}
- private EndPoint createEndPoint(SocketChannel channel, SelectionKey selectionKey) throws IOException
+ private EndPoint createEndPoint(SelectableChannel channel, SelectionKey selectionKey) throws IOException
{
EndPoint endPoint = _selectorManager.newEndPoint(channel, this, selectionKey);
_selectorManager.endPointOpened(endPoint);
@@ -417,7 +412,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
return endPoint;
}
- public void destroyEndPoint(final EndPoint endPoint)
+ public void onClose(final EndPoint endPoint)
{
final Connection connection = endPoint.getConnection();
submit(new Product()
@@ -517,9 +512,9 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
class Acceptor implements Runnable
{
- private final ServerSocketChannel _channel;
+ private final SelectableChannel _channel;
- public Acceptor(ServerSocketChannel channel)
+ public Acceptor(SelectableChannel channel)
{
this._channel = channel;
}
@@ -543,10 +538,10 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
class Accept implements Runnable
{
- private final SocketChannel channel;
+ private final SelectableChannel channel;
private final Object attachment;
- Accept(SocketChannel channel, Object attachment)
+ Accept(SelectableChannel channel, Object attachment)
{
this.channel = channel;
this.attachment = attachment;
@@ -570,10 +565,10 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
private class CreateEndPoint implements Product
{
- private final SocketChannel channel;
+ private final SelectableChannel channel;
private final SelectionKey key;
- public CreateEndPoint(SocketChannel channel, SelectionKey key)
+ public CreateEndPoint(SelectableChannel channel, SelectionKey key)
{
this.channel = channel;
this.key = key;
@@ -603,11 +598,11 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
class Connect implements Runnable
{
private final AtomicBoolean failed = new AtomicBoolean();
- private final SocketChannel channel;
+ private final SelectableChannel channel;
private final Object attachment;
private final Scheduler.Task timeout;
- Connect(SocketChannel channel, Object attachment)
+ Connect(SelectableChannel channel, Object attachment)
{
this.channel = channel;
this.attachment = attachment;
@@ -650,8 +645,8 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
@Override
public void run()
{
- SocketChannel channel = connect.channel;
- if (channel.isConnectionPending())
+ SelectableChannel channel = connect.channel;
+ if (_selectorManager.isConnectionPending(channel))
{
if (LOG.isDebugEnabled())
LOG.debug("Channel {} timed out while connecting, closing it", channel);
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java
index b45c39b80e..52473d7aef 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java
@@ -18,285 +18,24 @@
package org.eclipse.jetty.io;
-import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-import org.eclipse.jetty.util.thread.Locker;
import org.eclipse.jetty.util.thread.Scheduler;
/**
* An ChannelEndpoint that can be scheduled by {@link SelectorManager}.
*/
-public class SelectChannelEndPoint extends ChannelEndPoint implements ManagedSelector.SelectableEndPoint
+@Deprecated
+public class SelectChannelEndPoint extends SocketChannelEndPoint implements ManagedSelector.Selectable
{
public static final Logger LOG = Log.getLogger(SelectChannelEndPoint.class);
- private final Locker _locker = new Locker();
- private boolean _updatePending;
-
- /**
- * true if {@link ManagedSelector#destroyEndPoint(EndPoint)} has not been called
- */
- private final AtomicBoolean _open = new AtomicBoolean();
- private final ManagedSelector _selector;
- private final SelectionKey _key;
- /**
- * The current value for {@link SelectionKey#interestOps()}.
- */
- private int _currentInterestOps;
- /**
- * The desired value for {@link SelectionKey#interestOps()}.
- */
- private int _desiredInterestOps;
-
- private final Runnable _runUpdateKey = new Runnable()
- {
- @Override
- public void run()
- {
- updateKey();
- }
-
- @Override
- public String toString()
- {
- return SelectChannelEndPoint.this.toString()+":runUpdateKey";
- }
- };
- private final Runnable _runFillable = new Runnable()
- {
- @Override
- public void run()
- {
- getFillInterest().fillable();
- }
-
- @Override
- public String toString()
- {
- return SelectChannelEndPoint.this.toString()+":runFillable";
- }
- };
- private final Runnable _runCompleteWrite = new Runnable()
- {
- @Override
- public void run()
- {
- getWriteFlusher().completeWrite();
- }
-
- @Override
- public String toString()
- {
- return SelectChannelEndPoint.this.toString()+":runCompleteWrite";
- }
- };
- private final Runnable _runFillableCompleteWrite = new Runnable()
- {
- @Override
- public void run()
- {
- getFillInterest().fillable();
- getWriteFlusher().completeWrite();
- }
-
- @Override
- public String toString()
- {
- return SelectChannelEndPoint.this.toString()+":runFillableCompleteWrite";
- }
- };
-
public SelectChannelEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey key, Scheduler scheduler, long idleTimeout)
{
- super(scheduler, channel);
- _selector = selector;
- _key = key;
+ super(channel,selector,key,scheduler);
setIdleTimeout(idleTimeout);
}
-
- @Override
- protected void needsFillInterest()
- {
- changeInterests(SelectionKey.OP_READ);
- }
-
- @Override
- protected void onIncompleteFlush()
- {
- changeInterests(SelectionKey.OP_WRITE);
- }
-
- @Override
- public Runnable onSelected()
- {
- /**
- * This method may run concurrently with {@link #changeInterests(int)}.
- */
-
- int readyOps = _key.readyOps();
- int oldInterestOps;
- int newInterestOps;
- try (Locker.Lock lock = _locker.lock())
- {
- _updatePending = true;
- // Remove the readyOps, that here can only be OP_READ or OP_WRITE (or both).
- oldInterestOps = _desiredInterestOps;
- newInterestOps = oldInterestOps & ~readyOps;
- _desiredInterestOps = newInterestOps;
- }
-
-
- boolean readable = (readyOps & SelectionKey.OP_READ) != 0;
- boolean writable = (readyOps & SelectionKey.OP_WRITE) != 0;
-
-
- if (LOG.isDebugEnabled())
- LOG.debug("onSelected {}->{} r={} w={} for {}", oldInterestOps, newInterestOps, readable, writable, this);
-
- // Run non-blocking code immediately.
- // This producer knows that this non-blocking code is special
- // and that it must be run in this thread and not fed to the
- // ExecutionStrategy, which could not have any thread to run these
- // tasks (or it may starve forever just after having run them).
- if (readable && getFillInterest().isCallbackNonBlocking())
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Direct readable run {}",this);
- _runFillable.run();
- readable = false;
- }
- if (writable && getWriteFlusher().isCallbackNonBlocking())
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Direct writable run {}",this);
- _runCompleteWrite.run();
- writable = false;
- }
-
- // return task to complete the job
- Runnable task= readable ? (writable ? _runFillableCompleteWrite : _runFillable)
- : (writable ? _runCompleteWrite : null);
-
- if (LOG.isDebugEnabled())
- LOG.debug("task {}",task);
- return task;
- }
-
- @Override
- public void updateKey()
- {
- /**
- * This method may run concurrently with {@link #changeInterests(int)}.
- */
-
- try
- {
- int oldInterestOps;
- int newInterestOps;
- try (Locker.Lock lock = _locker.lock())
- {
- _updatePending = false;
- oldInterestOps = _currentInterestOps;
- newInterestOps = _desiredInterestOps;
- if (oldInterestOps != newInterestOps)
- {
- _currentInterestOps = newInterestOps;
- _key.interestOps(newInterestOps);
- }
- }
-
- if (LOG.isDebugEnabled())
- LOG.debug("Key interests updated {} -> {} on {}", oldInterestOps, newInterestOps, this);
- }
- catch (CancelledKeyException x)
- {
- LOG.debug("Ignoring key update for concurrently closed channel {}", this);
- close();
- }
- catch (Throwable x)
- {
- LOG.warn("Ignoring key update for " + this, x);
- close();
- }
- }
-
- private void changeInterests(int operation)
- {
- /**
- * This method may run concurrently with
- * {@link #updateKey()} and {@link #onSelected()}.
- */
-
- int oldInterestOps;
- int newInterestOps;
- boolean pending;
- try (Locker.Lock lock = _locker.lock())
- {
- pending = _updatePending;
- oldInterestOps = _desiredInterestOps;
- newInterestOps = oldInterestOps | operation;
- if (newInterestOps != oldInterestOps)
- _desiredInterestOps = newInterestOps;
- }
-
- if (LOG.isDebugEnabled())
- LOG.debug("changeInterests p={} {}->{} for {}", pending, oldInterestOps, newInterestOps, this);
-
- if (!pending)
- _selector.submit(_runUpdateKey);
- }
-
-
- @Override
- public void close()
- {
- if (_open.compareAndSet(true, false))
- {
- super.close();
- _selector.destroyEndPoint(this);
- }
- }
-
- @Override
- public boolean isOpen()
- {
- // We cannot rely on super.isOpen(), because there is a race between calls to close() and isOpen():
- // a thread may call close(), which flips the boolean but has not yet called super.close(), and
- // another thread calls isOpen() which would return true - wrong - if based on super.isOpen().
- return _open.get();
- }
-
- @Override
- public void onOpen()
- {
- if (_open.compareAndSet(false, true))
- super.onOpen();
- }
-
- @Override
- public String toString()
- {
- // We do a best effort to print the right toString() and that's it.
- try
- {
- boolean valid = _key != null && _key.isValid();
- int keyInterests = valid ? _key.interestOps() : -1;
- int keyReadiness = valid ? _key.readyOps() : -1;
- return String.format("%s{io=%d/%d,kio=%d,kro=%d}",
- super.toString(),
- _currentInterestOps,
- _desiredInterestOps,
- keyInterests,
- keyReadiness);
- }
- catch (Throwable x)
- {
- return String.format("%s{io=%s,kio=-2,kro=-2}", super.toString(), _desiredInterestOps);
- }
- }
}
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
index 9dfe8db4d5..fe170f7f7c 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
@@ -22,7 +22,9 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.Executor;
@@ -133,7 +135,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
return _selectors.length;
}
- private ManagedSelector chooseSelector(SocketChannel channel)
+ private ManagedSelector chooseSelector(SelectableChannel channel)
{
// Ideally we would like to have all connections from the same client end
// up on the same selector (to try to avoid smearing the data from a single
@@ -145,14 +147,17 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
{
try
{
- SocketAddress remote = channel.getRemoteAddress();
- if (remote instanceof InetSocketAddress)
+ if (channel instanceof SocketChannel)
{
- byte[] addr = ((InetSocketAddress)remote).getAddress().getAddress();
- if (addr != null)
+ SocketAddress remote = ((SocketChannel)channel).getRemoteAddress();
+ if (remote instanceof InetSocketAddress)
{
- int s = addr[addr.length - 1] & 0xFF;
- candidate1 = _selectors[s % getSelectorCount()];
+ byte[] addr = ((InetSocketAddress)remote).getAddress().getAddress();
+ if (addr != null)
+ {
+ int s = addr[addr.length - 1] & 0xFF;
+ candidate1 = _selectors[s % getSelectorCount()];
+ }
}
}
}
@@ -182,9 +187,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
*
* @param channel the channel to register
* @param attachment the attachment object
- * @see #accept(SocketChannel, Object)
+ * @see #accept(SelectableChannel, Object)
*/
- public void connect(SocketChannel channel, Object attachment)
+ public void connect(SelectableChannel channel, Object attachment)
{
ManagedSelector set = chooseSelector(channel);
set.submit(set.new Connect(channel, attachment));
@@ -192,9 +197,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
/**
* @param channel the channel to accept
- * @see #accept(SocketChannel, Object)
+ * @see #accept(SelectableChannel, Object)
*/
- public void accept(SocketChannel channel)
+ public void accept(SelectableChannel channel)
{
accept(channel, null);
}
@@ -209,7 +214,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
* @param channel the channel to register
* @param attachment the attachment object
*/
- public void accept(SocketChannel channel, Object attachment)
+ public void accept(SelectableChannel channel, Object attachment)
{
final ManagedSelector selector = chooseSelector(channel);
selector.submit(selector.new Accept(channel, attachment));
@@ -218,12 +223,12 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
/**
* <p>Registers a server channel for accept operations.
* When a {@link SocketChannel} is accepted from the given {@link ServerSocketChannel}
- * then the {@link #accepted(SocketChannel)} method is called, which must be
+ * then the {@link #accepted(SelectableChannel)} method is called, which must be
* overridden by a derivation of this class to handle the accepted channel
*
* @param server the server channel to register
*/
- public void acceptor(ServerSocketChannel server)
+ public void acceptor(SelectableChannel server)
{
final ManagedSelector selector = chooseSelector(null);
selector.submit(selector.new Acceptor(server));
@@ -231,14 +236,14 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
/**
* Callback method when a channel is accepted from the {@link ServerSocketChannel}
- * passed to {@link #acceptor(ServerSocketChannel)}.
+ * passed to {@link #acceptor(SelectableChannel)}.
* The default impl throws an {@link UnsupportedOperationException}, so it must
* be overridden by subclasses if a server channel is provided.
*
* @param channel the
* @throws IOException if unable to accept channel
*/
- protected void accepted(SocketChannel channel) throws IOException
+ protected void accepted(SelectableChannel channel) throws IOException
{
throw new UnsupportedOperationException();
}
@@ -292,7 +297,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
*/
protected void endPointClosed(EndPoint endpoint)
{
- endpoint.onClose();
}
/**
@@ -332,11 +336,22 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
}
}
- protected boolean finishConnect(SocketChannel channel) throws IOException
+ protected boolean doFinishConnect(SelectableChannel channel) throws IOException
{
- return channel.finishConnect();
+ return ((SocketChannel)channel).finishConnect();
+ }
+
+ protected boolean isConnectionPending(SelectableChannel channel)
+ {
+ return ((SocketChannel)channel).isConnectionPending();
+ }
+
+ protected SelectableChannel doAccept(SelectableChannel server) throws IOException
+ {
+ return ((ServerSocketChannel)server).accept();
}
+
/**
* <p>Callback method invoked when a non-blocking connect cannot be completed.</p>
* <p>By default it just logs with level warning.</p>
@@ -345,24 +360,29 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
* @param ex the exception that caused the connect to fail
* @param attachment the attachment object associated at registration
*/
- protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment)
+ protected void connectionFailed(SelectableChannel channel, Throwable ex, Object attachment)
{
LOG.warn(String.format("%s - %s", channel, attachment), ex);
}
+ protected Selector newSelector() throws IOException
+ {
+ return Selector.open();
+ }
+
/**
* <p>Factory method to create {@link EndPoint}.</p>
- * <p>This method is invoked as a result of the registration of a channel via {@link #connect(SocketChannel, Object)}
- * or {@link #accept(SocketChannel)}.</p>
+ * <p>This method is invoked as a result of the registration of a channel via {@link #connect(SelectableChannel, Object)}
+ * or {@link #accept(SelectableChannel)}.</p>
*
* @param channel the channel associated to the endpoint
* @param selector the selector the channel is registered to
* @param selectionKey the selection key
* @return a new endpoint
* @throws IOException if the endPoint cannot be created
- * @see #newConnection(SocketChannel, EndPoint, Object)
+ * @see #newConnection(SelectableChannel, EndPoint, Object)
*/
- protected abstract EndPoint newEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey selectionKey) throws IOException;
+ protected abstract EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey selectionKey) throws IOException;
/**
* <p>Factory method to create {@link Connection}.</p>
@@ -372,9 +392,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
* @param attachment the attachment
* @return a new connection
* @throws IOException if unable to create new connection
- * @see #newEndPoint(SocketChannel, ManagedSelector, SelectionKey)
*/
- public abstract Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException;
+ public abstract Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment) throws IOException;
@Override
public String dump()
@@ -388,4 +407,5 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
ContainerLifeCycle.dumpObject(out, this);
ContainerLifeCycle.dump(out, indent, TypeUtil.asList(_selectors));
}
+
}
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SocketChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SocketChannelEndPoint.java
new file mode 100644
index 0000000000..0824d54899
--- /dev/null
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SocketChannelEndPoint.java
@@ -0,0 +1,81 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.io;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
+
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.util.thread.Scheduler;
+
+public class SocketChannelEndPoint extends ChannelEndPoint
+{
+ private static final Logger LOG = Log.getLogger(SocketChannelEndPoint.class);
+ private final Socket _socket;
+ private final InetSocketAddress _local;
+ private final InetSocketAddress _remote;
+
+ public SocketChannelEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key, Scheduler scheduler)
+ {
+ this((SocketChannel)channel,selector,key,scheduler);
+ }
+
+ public SocketChannelEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey key, Scheduler scheduler)
+ {
+ super(channel,selector,key,scheduler);
+
+ _socket=channel.socket();
+ _local=(InetSocketAddress)_socket.getLocalSocketAddress();
+ _remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
+ }
+
+ public Socket getSocket()
+ {
+ return _socket;
+ }
+
+ public InetSocketAddress getLocalAddress()
+ {
+ return _local;
+ }
+
+ public InetSocketAddress getRemoteAddress()
+ {
+ return _remote;
+ }
+
+ @Override
+ protected void doShutdownOutput()
+ {
+ try
+ {
+ if (!_socket.isOutputShutdown())
+ _socket.shutdownOutput();
+ }
+ catch (IOException e)
+ {
+ LOG.debug(e);
+ }
+ }
+}
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java
index ca32841446..014b2c3c33 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.io.ssl;
import java.io.IOException;
+import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.concurrent.Executor;
@@ -328,10 +329,28 @@ public class SslConnection extends AbstractConnection
public DecryptedEndPoint()
{
- super(null,getEndPoint().getLocalAddress(), getEndPoint().getRemoteAddress());
+ super(((AbstractEndPoint)getEndPoint()).getScheduler());
setIdleTimeout(getEndPoint().getIdleTimeout());
}
+
+
+ @Override
+ public InetSocketAddress getLocalAddress()
+ {
+ return getEndPoint().getLocalAddress();
+ }
+
+
+
+ @Override
+ public InetSocketAddress getRemoteAddress()
+ {
+ return getEndPoint().getRemoteAddress();
+ }
+
+
+
@Override
public void setIdleTimeout(long idleTimeout)
{
@@ -868,12 +887,11 @@ public class SslConnection extends AbstractConnection
}
@Override
- public void shutdownOutput()
+ public void doShutdownOutput()
{
boolean ishut = isInputShutdown();
- boolean oshut = isOutputShutdown();
if (DEBUG)
- LOG.debug("{} shutdownOutput: oshut={}, ishut={}", SslConnection.this, oshut, ishut);
+ LOG.debug("{} shutdownOutput: ishut={}", SslConnection.this, ishut);
if (ishut)
{
// Aggressively close, since inbound close alert has already been processed
@@ -882,7 +900,7 @@ public class SslConnection extends AbstractConnection
// reply. If a TLS close reply is sent, most implementations send a RST.
getEndPoint().close();
}
- else if (!oshut)
+ else
{
try
{
@@ -914,12 +932,27 @@ public class SslConnection extends AbstractConnection
}
@Override
- public void close()
+ public void doClose()
{
// First send the TLS Close Alert, then the FIN
- shutdownOutput();
+ if (!_sslEngine.isOutboundDone())
+ {
+ try
+ {
+ synchronized (this) // TODO review synchronized boundary
+ {
+ _sslEngine.closeOutbound();
+ flush(BufferUtil.EMPTY_BUFFER); // Send close handshake
+ ensureFillInterested();
+ }
+ }
+ catch (Exception e)
+ {
+ LOG.ignore(e);
+ }
+ }
getEndPoint().close();
- super.close();
+ super.doClose();
}
@Override
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java
index cc38b8ee94..578a6867fe 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/IOTest.java
@@ -18,6 +18,11 @@
package org.eclipse.jetty.io;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -45,11 +50,6 @@ import org.eclipse.jetty.util.IO;
import org.junit.Assert;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
public class IOTest
{
@Test
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java
index ddec08085f..b9f880f52f 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java
@@ -24,6 +24,7 @@ import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
@@ -62,10 +63,11 @@ public class SelectChannelEndPointInterestsTest
selectorManager = new SelectorManager(threadPool, scheduler)
{
+
@Override
- protected EndPoint newEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey selectionKey) throws IOException
+ protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key) throws IOException
{
- return new SelectChannelEndPoint(channel, selector, selectionKey, getScheduler(), 60000)
+ SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler())
{
@Override
protected void onIncompleteFlush()
@@ -74,10 +76,13 @@ public class SelectChannelEndPointInterestsTest
interested.onIncompleteFlush();
}
};
+
+ endp.setIdleTimeout(60000);
+ return endp;
}
@Override
- public Connection newConnection(SocketChannel channel, final EndPoint endPoint, Object attachment)
+ public Connection newConnection(SelectableChannel channel, final EndPoint endPoint, Object attachment)
{
return new AbstractConnection(endPoint, getExecutor())
{
@@ -136,7 +141,7 @@ public class SelectChannelEndPointInterestsTest
connection.fillInterested();
ByteBuffer output = ByteBuffer.allocate(size.get());
- endPoint.write(new Callback.Adapter(), output);
+ endPoint.write(new Callback(){}, output);
latch1.countDown();
}
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java
index 2367ed6b85..ec3d158835 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java
@@ -26,6 +26,7 @@ import java.io.File;
import java.io.IOException;
import java.net.Socket;
import java.nio.ByteBuffer;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;
@@ -71,7 +72,7 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
}
@Override
- protected Connection newConnection(SocketChannel channel, EndPoint endpoint)
+ protected Connection newConnection(SelectableChannel channel, EndPoint endpoint)
{
SSLEngine engine = __sslCtxFactory.newSSLEngine();
engine.setUseClientMode(false);
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java
index 77e004ca3c..77691a235f 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java
@@ -32,6 +32,7 @@ import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
@@ -64,19 +65,21 @@ public class SelectChannelEndPointTest
protected SelectorManager _manager = new SelectorManager(_threadPool, _scheduler)
{
@Override
- public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment)
+ public Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment)
{
return SelectChannelEndPointTest.this.newConnection(channel, endpoint);
}
@Override
- protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey selectionKey) throws IOException
+ protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key) throws IOException
{
- SelectChannelEndPoint endp = new SelectChannelEndPoint(channel, selectSet, selectionKey, getScheduler(), 60000);
+ SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler());
+ endp.setIdleTimeout(60000);
_lastEndPoint = endp;
_lastEndPointLatch.countDown();
return endp;
}
+
};
// Must be volatile or the test may fail spuriously
@@ -110,7 +113,7 @@ public class SelectChannelEndPointTest
return new Socket(_connector.socket().getInetAddress(), _connector.socket().getLocalPort());
}
- protected Connection newConnection(SocketChannel channel, EndPoint endpoint)
+ protected Connection newConnection(SelectableChannel channel, EndPoint endpoint)
{
return new TestConnection(endpoint);
}
@@ -228,11 +231,11 @@ public class SelectChannelEndPointTest
}
catch (InterruptedException | EofException e)
{
- SelectChannelEndPoint.LOG.ignore(e);
+ Log.getRootLogger().ignore(e);
}
catch (Exception e)
{
- SelectChannelEndPoint.LOG.warn(e);
+ Log.getRootLogger().warn(e);
}
finally
{
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectorManagerTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectorManagerTest.java
index 66d39d3a16..a5f09432a8 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectorManagerTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectorManagerTest.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.io;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
@@ -69,20 +70,22 @@ public class SelectorManagerTest
SelectorManager selectorManager = new SelectorManager(executor, scheduler)
{
@Override
- protected EndPoint newEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey selectionKey) throws IOException
+ protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key) throws IOException
{
- return new SelectChannelEndPoint(channel, selector, selectionKey, getScheduler(), connectTimeout / 2);
+ SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler());
+ endp.setIdleTimeout(connectTimeout/2);
+ return endp;
}
-
+
@Override
- protected boolean finishConnect(SocketChannel channel) throws IOException
+ protected boolean doFinishConnect(SelectableChannel channel) throws IOException
{
try
{
long timeout = timeoutConnection.get();
if (timeout > 0)
TimeUnit.MILLISECONDS.sleep(timeout);
- return super.finishConnect(channel);
+ return super.doFinishConnect(channel);
}
catch (InterruptedException e)
{
@@ -91,7 +94,7 @@ public class SelectorManagerTest
}
@Override
- public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException
+ public Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment) throws IOException
{
((Callback)attachment).succeeded();
return new AbstractConnection(endpoint, executor)
@@ -104,7 +107,7 @@ public class SelectorManagerTest
}
@Override
- protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment)
+ protected void connectionFailed(SelectableChannel channel, Throwable ex, Object attachment)
{
((Callback)attachment).failed(ex);
}
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/ChannelEndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SocketChannelEndPointTest.java
index 0a437ec907..69035af133 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/ChannelEndPointTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SocketChannelEndPointTest.java
@@ -24,7 +24,7 @@ import java.nio.channels.SocketChannel;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-public class ChannelEndPointTest extends EndPointTest<ChannelEndPoint>
+public class SocketChannelEndPointTest extends EndPointTest<SocketChannelEndPoint>
{
static ServerSocketChannel connector;
@@ -43,16 +43,22 @@ public class ChannelEndPointTest extends EndPointTest<ChannelEndPoint>
}
@Override
- protected EndPointPair<ChannelEndPoint> newConnection() throws Exception
+ protected EndPointPair<SocketChannelEndPoint> newConnection() throws Exception
{
- EndPointPair<ChannelEndPoint> c = new EndPointPair<>();
+ EndPointPair<SocketChannelEndPoint> c = new EndPointPair<>();
- c.client=new ChannelEndPoint(null,SocketChannel.open(connector.socket().getLocalSocketAddress()));
- c.server=new ChannelEndPoint(null,connector.accept());
+ c.client=new SocketChannelEndPoint(SocketChannel.open(connector.socket().getLocalSocketAddress()),null,null,null);
+ c.server=new SocketChannelEndPoint(connector.accept(),null,null,null);
return c;
}
@Override
+ public void testClientClose() throws Exception
+ {
+ super.testClientClose();
+ }
+
+ @Override
public void testClientServerExchange() throws Exception
{
super.testClientServerExchange();
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java
index 0ec33fb660..d12868e21b 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.nio.ByteBuffer;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
@@ -39,6 +40,7 @@ import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.FutureCallback;
+import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.Scheduler;
@@ -74,7 +76,7 @@ public class SslConnectionTest
protected SelectorManager _manager = new SelectorManager(_threadPool, _scheduler)
{
@Override
- public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment)
+ public Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment)
{
SSLEngine engine = __sslCtxFactory.newSSLEngine();
engine.setUseClientMode(false);
@@ -85,10 +87,12 @@ public class SslConnectionTest
return sslConnection;
}
+
@Override
- protected SelectChannelEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey selectionKey) throws IOException
+ protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey selectionKey) throws IOException
{
- SelectChannelEndPoint endp = new TestEP(channel,selectSet, selectionKey, getScheduler(), 60000);
+ SocketChannelEndPoint endp = new TestEP(channel, selector, selectionKey, getScheduler());
+ endp.setIdleTimeout(60000);
_lastEndp=endp;
return endp;
}
@@ -96,12 +100,11 @@ public class SslConnectionTest
static final AtomicInteger __startBlocking = new AtomicInteger();
static final AtomicInteger __blockFor = new AtomicInteger();
- private static class TestEP extends SelectChannelEndPoint
+ private static class TestEP extends SocketChannelEndPoint
{
-
- public TestEP(SocketChannel channel, ManagedSelector selector, SelectionKey key, Scheduler scheduler, long idleTimeout)
+ public TestEP(SelectableChannel channel, ManagedSelector selector, SelectionKey key, Scheduler scheduler)
{
- super(channel,selector,key,scheduler,idleTimeout);
+ super((SocketChannel)channel,selector,key,scheduler);
}
@Override
@@ -121,7 +124,6 @@ public class SslConnectionTest
return false;
}
}
- String s=BufferUtil.toDetailString(buffers[0]);
boolean flushed=super.flush(buffers);
return flushed;
}
@@ -235,11 +237,11 @@ public class SslConnectionTest
}
catch(InterruptedException|EofException e)
{
- SelectChannelEndPoint.LOG.ignore(e);
+ Log.getRootLogger().ignore(e);
}
catch(Exception e)
{
- SelectChannelEndPoint.LOG.warn(e);
+ Log.getRootLogger().warn(e);
}
finally
{
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java
index fe01caa7a7..1ec2b99e8c 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java
@@ -18,15 +18,6 @@
package org.eclipse.jetty.io;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.WritePendingException;
@@ -59,6 +50,15 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class WriteFlusherTest
{
@@ -414,7 +414,7 @@ public class WriteFlusherTest
Arrays.fill(chunk1, (byte)2);
ByteBuffer buffer2 = ByteBuffer.wrap(chunk2);
- _flusher.write(new Callback.Adapter(), buffer1, buffer2);
+ _flusher.write(Callback.NOOP, buffer1, buffer2);
assertTrue(_flushIncomplete.get());
assertFalse(buffer1.hasRemaining());
@@ -585,7 +585,7 @@ public class WriteFlusherTest
stalled.set(true);
return false;
}
-
+
// make sure failed is called before we go on
try
{
@@ -624,15 +624,15 @@ public class WriteFlusherTest
@Override
protected void onIncompleteFlush()
{
- executor.submit(new Runnable()
- {
- public void run()
+ executor.submit(new Runnable()
+ {
+ public void run()
{
try
{
while(window.get()==0)
window.addAndGet(exchange.exchange(0));
- completeWrite();
+ completeWrite();
}
catch(Throwable th)
{
@@ -647,25 +647,25 @@ public class WriteFlusherTest
BlockingCallback callback = new BlockingCallback();
writeFlusher.write(callback,BufferUtil.toBuffer("How "),BufferUtil.toBuffer("now "),BufferUtil.toBuffer("brown "),BufferUtil.toBuffer("cow."));
exchange.exchange(0);
-
+
Assert.assertThat(endp.takeOutputString(StandardCharsets.US_ASCII),Matchers.equalTo("How now br"));
-
+
exchange.exchange(1);
exchange.exchange(0);
-
+
Assert.assertThat(endp.takeOutputString(StandardCharsets.US_ASCII),Matchers.equalTo("o"));
-
+
exchange.exchange(8);
callback.block();
-
+
Assert.assertThat(endp.takeOutputString(StandardCharsets.US_ASCII),Matchers.equalTo("wn cow."));
-
+
}
private static class EndPointIterationOnNonBlockedStallMock extends ByteArrayEndPoint
{
final AtomicInteger _window;
-
+
public EndPointIterationOnNonBlockedStallMock(AtomicInteger window)
{
_window=window;
@@ -675,7 +675,7 @@ public class WriteFlusherTest
public boolean flush(ByteBuffer... buffers) throws IOException
{
ByteBuffer byteBuffer = buffers[0];
-
+
if (_window.get()>0 && byteBuffer.hasRemaining())
{
// consume 1 byte
@@ -692,7 +692,7 @@ public class WriteFlusherTest
return true;
}
}
-
+
private static class FailedCaller implements Callable<FutureCallback>
{
diff --git a/jetty-jaas/pom.xml b/jetty-jaas/pom.xml
index 6f42e0ee5c..70fe50f0c4 100644
--- a/jetty-jaas/pom.xml
+++ b/jetty-jaas/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jaas</artifactId>
diff --git a/jetty-jaas/src/main/config/modules/jaas.mod b/jetty-jaas/src/main/config/modules/jaas.mod
index fee3f59d87..26c68fff54 100644
--- a/jetty-jaas/src/main/config/modules/jaas.mod
+++ b/jetty-jaas/src/main/config/modules/jaas.mod
@@ -1,6 +1,5 @@
-#
-# JAAS Module
-#
+[description]
+Enable JAAS for deployed webapplications.
[depend]
server
diff --git a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java
index 778d2284f4..0d47c33db0 100644
--- a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java
+++ b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java
@@ -222,7 +222,7 @@ public class JAASLoginService extends AbstractLifeCycle implements LoginService
}
else
{
- Class<?> clazz = Loader.loadClass(getClass(), _callbackHandlerClass);
+ Class<?> clazz = Loader.loadClass(_callbackHandlerClass);
callbackHandler = (CallbackHandler)clazz.newInstance();
}
//set up the login context
diff --git a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java
index 0bcdd54c17..552b4fab4c 100644
--- a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java
+++ b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/AbstractLoginModule.java
@@ -289,6 +289,7 @@ public abstract class AbstractLoginModule implements LoginModule
public boolean logout() throws LoginException
{
this.currentUser.unsetJAASInfo(this.subject);
+ this.currentUser = null;
return true;
}
diff --git a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java
index 86ca2349b7..fd20a1f395 100644
--- a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java
+++ b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java
@@ -103,7 +103,7 @@ public class JDBCLoginModule extends AbstractDatabaseLoginModule
dbPassword = "";
if (dbDriver != null)
- Loader.loadClass(this.getClass(), dbDriver).newInstance();
+ Loader.loadClass(dbDriver).newInstance();
}
catch (ClassNotFoundException e)
{
diff --git a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/PropertyFileLoginModule.java b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/PropertyFileLoginModule.java
index 3560f2b57b..8750aaf19a 100644
--- a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/PropertyFileLoginModule.java
+++ b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/PropertyFileLoginModule.java
@@ -48,6 +48,8 @@ public class PropertyFileLoginModule extends AbstractLoginModule
private int _refreshInterval = 0;
private String _filename = DEFAULT_FILENAME;
+
+
/**
* Read contents of the configured property file.
*
@@ -73,7 +75,6 @@ public class PropertyFileLoginModule extends AbstractLoginModule
{
PropertyUserStore propertyUserStore = new PropertyUserStore();
propertyUserStore.setConfig(_filename);
- propertyUserStore.setRefreshInterval(_refreshInterval);
PropertyUserStore prev = _propertyUserStores.putIfAbsent(_filename, propertyUserStore);
if (prev == null)
diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml
index fc83e23a91..db67f580ef 100644
--- a/jetty-jaspi/pom.xml
+++ b/jetty-jaspi/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jaspi</artifactId>
diff --git a/jetty-jaspi/src/main/config/modules/jaspi.mod b/jetty-jaspi/src/main/config/modules/jaspi.mod
index e7019ae1b6..0d55273034 100644
--- a/jetty-jaspi/src/main/config/modules/jaspi.mod
+++ b/jetty-jaspi/src/main/config/modules/jaspi.mod
@@ -1,6 +1,5 @@
-#
-# Jetty JASPI Module
-#
+[description]
+Enable JASPI authentication for deployed webapplications.
[depend]
security
diff --git a/jetty-jaspi/src/test/java/org/eclipse/jetty/security/jaspi/JaspiTest.java b/jetty-jaspi/src/test/java/org/eclipse/jetty/security/jaspi/JaspiTest.java
index 4bc51cb782..25eb1b8bc9 100644
--- a/jetty-jaspi/src/test/java/org/eclipse/jetty/security/jaspi/JaspiTest.java
+++ b/jetty-jaspi/src/test/java/org/eclipse/jetty/security/jaspi/JaspiTest.java
@@ -22,14 +22,16 @@ import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jetty.security.AbstractLoginService;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
-import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
@@ -38,6 +40,7 @@ import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.security.Constraint;
+import org.eclipse.jetty.util.security.Credential;
import org.eclipse.jetty.util.security.Password;
import org.hamcrest.Matchers;
import org.junit.After;
@@ -48,6 +51,43 @@ public class JaspiTest
{
Server _server;
LocalConnector _connector;
+ public class TestLoginService extends AbstractLoginService
+ {
+ protected Map<String, UserPrincipal> _users = new HashMap<>();
+ protected Map<String, String[]> _roles = new HashMap();
+
+
+
+ public TestLoginService(String name)
+ {
+ setName(name);
+ }
+
+ public void putUser (String username, Credential credential, String[] roles)
+ {
+ UserPrincipal userPrincipal = new UserPrincipal(username,credential);
+ _users.put(username, userPrincipal);
+ _roles.put(username, roles);
+ }
+
+ /**
+ * @see org.eclipse.jetty.security.AbstractLoginService#loadRoleInfo(org.eclipse.jetty.security.AbstractLoginService.UserPrincipal)
+ */
+ @Override
+ protected String[] loadRoleInfo(UserPrincipal user)
+ {
+ return _roles.get(user.getName());
+ }
+
+ /**
+ * @see org.eclipse.jetty.security.AbstractLoginService#loadUserInfo(java.lang.String)
+ */
+ @Override
+ protected UserPrincipal loadUserInfo(String username)
+ {
+ return _users.get(username);
+ }
+ }
@Before
public void before() throws Exception
@@ -60,7 +100,7 @@ public class JaspiTest
ContextHandlerCollection contexts = new ContextHandlerCollection();
_server.setHandler(contexts);
- HashLoginService loginService = new HashLoginService("TestRealm");
+ TestLoginService loginService = new TestLoginService("TestRealm");
loginService.putUser("user",new Password("password"),new String[]{"users"});
loginService.putUser("admin",new Password("secret"),new String[]{"users","admins"});
_server.addBean(loginService);
diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml
index b8cd6fd952..8c15a72029 100644
--- a/jetty-jmx/pom.xml
+++ b/jetty-jmx/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jmx</artifactId>
diff --git a/jetty-jmx/src/main/config/modules/jmx-remote.mod b/jetty-jmx/src/main/config/modules/jmx-remote.mod
index f8a5111d8f..7a10a01814 100644
--- a/jetty-jmx/src/main/config/modules/jmx-remote.mod
+++ b/jetty-jmx/src/main/config/modules/jmx-remote.mod
@@ -1,6 +1,5 @@
-#
-# JMX Remote Module
-#
+[description]
+Enables remote RMI access to JMX
[depend]
jmx
diff --git a/jetty-jmx/src/main/config/modules/jmx.mod b/jetty-jmx/src/main/config/modules/jmx.mod
index ee091c706a..a59c6dd9c1 100644
--- a/jetty-jmx/src/main/config/modules/jmx.mod
+++ b/jetty-jmx/src/main/config/modules/jmx.mod
@@ -1,6 +1,6 @@
-#
-# JMX Module
-#
+[description]
+Enables JMX instrumentation for server beans and
+enables JMX agent.
[depend]
server
diff --git a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java
index 33a3a59cf9..0c6713cfcc 100644
--- a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java
+++ b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java
@@ -129,8 +129,21 @@ public class ObjectMBean implements DynamicMBean
String mName = pName + ".jmx." + cName + "MBean";
try
- {
- Class<?> mClass = (Object.class.equals(oClass))?oClass=ObjectMBean.class:Loader.loadClass(oClass,mName);
+ {
+ Class<?> mClass;
+ try
+ {
+ // Look for an MBean class from the same loader that loaded the original class
+ mClass = (Object.class.equals(oClass))?oClass=ObjectMBean.class:Loader.loadClass(oClass,mName);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // Not found, so if not the same as the thread context loader, try that.
+ if (Thread.currentThread().getContextClassLoader()==oClass.getClassLoader())
+ throw e;
+ LOG.ignore(e);
+ mClass=Loader.loadClass(oClass,mName);
+ }
if (LOG.isDebugEnabled())
LOG.debug("ObjectMbean: mbeanFor {} mClass={}", o, mClass);
diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml
index 0ef15da242..9df46b81ad 100644
--- a/jetty-jndi/pom.xml
+++ b/jetty-jndi/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jndi</artifactId>
diff --git a/jetty-jndi/src/main/config/modules/jndi.mod b/jetty-jndi/src/main/config/modules/jndi.mod
index 33c077ce68..b0d3fc4449 100644
--- a/jetty-jndi/src/main/config/modules/jndi.mod
+++ b/jetty-jndi/src/main/config/modules/jndi.mod
@@ -1,6 +1,5 @@
-#
-# JNDI Support
-#
+[description]
+Adds the Jetty JNDI implementation to the classpath.
[depend]
server
diff --git a/jetty-jspc-maven-plugin/pom.xml b/jetty-jspc-maven-plugin/pom.xml
index 893502f13c..9923d8def5 100644
--- a/jetty-jspc-maven-plugin/pom.xml
+++ b/jetty-jspc-maven-plugin/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jspc-maven-plugin</artifactId>
diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml
index eeee9a0786..9d6d2a3ba7 100644
--- a/jetty-maven-plugin/pom.xml
+++ b/jetty-maven-plugin/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-maven-plugin</artifactId>
diff --git a/jetty-monitor/pom.xml b/jetty-monitor/pom.xml
index 22ee8ac241..cdf4905f56 100644
--- a/jetty-monitor/pom.xml
+++ b/jetty-monitor/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-monitor</artifactId>
diff --git a/jetty-monitor/src/main/config/modules/monitor.mod b/jetty-monitor/src/main/config/modules/monitor.mod
index 09132c7b2c..f1fa81f98c 100644
--- a/jetty-monitor/src/main/config/modules/monitor.mod
+++ b/jetty-monitor/src/main/config/modules/monitor.mod
@@ -1,6 +1,6 @@
-#
-# Jetty Monitor module
-#
+[description]
+Enables the Jetty Monitor Module to periodically
+check/publish JMX parameters of the server.
[depend]
server
diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml
index dceec0711a..55be194dec 100644
--- a/jetty-nosql/pom.xml
+++ b/jetty-nosql/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-nosql</artifactId>
diff --git a/jetty-nosql/src/main/config/modules/nosql.mod b/jetty-nosql/src/main/config/modules/nosql.mod
index a5b5a9ed75..fb4ed66f69 100644
--- a/jetty-nosql/src/main/config/modules/nosql.mod
+++ b/jetty-nosql/src/main/config/modules/nosql.mod
@@ -1,6 +1,5 @@
-#
-# Jetty NoSql module
-#
+[description]
+Enables NoSql session management with a MongoDB driver.
[depend]
webapp
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java
index 7d5e9dca58..51b8d60912 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java
@@ -96,7 +96,10 @@ public abstract class NoSqlSessionManager extends AbstractSessionManager impleme
session=race;
}
else
+ {
__log.debug("session loaded ", idInCluster);
+ _sessionsStats.increment();
+ }
//check if the session we just loaded has actually expired, maybe while we weren't running
if (getMaxInactiveInterval() > 0 && session.getAccessed() > 0 && ((getMaxInactiveInterval()*1000L)+session.getAccessed()) < System.currentTimeMillis())
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
index d822ea7926..894a3fda10 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java
@@ -206,7 +206,7 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
protected void scavenge()
{
long now = System.currentTimeMillis();
- __log.debug("SessionIdManager:scavenge:at {}", now);
+ __log.debug(getWorkerName()+":SessionIdManager:scavenge:at {}", now);
/*
* run a query returning results that:
* - are in the known list of sessionIds
@@ -258,7 +258,7 @@ public class MongoSessionIdManager extends AbstractSessionIdManager
for ( DBObject session : checkSessions )
{
- __log.debug("SessionIdManager:scavenge: expiring session {}", (String)session.get(MongoSessionManager.__ID));
+ __log.debug(getWorkerName()+":SessionIdManager:scavenge: {} expiring session {}", atTime,(String)session.get(MongoSessionManager.__ID));
expireAll((String)session.get(MongoSessionManager.__ID));
}
}
diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
index df8f917188..8c44e9fa47 100644
--- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
+++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java
@@ -268,7 +268,9 @@ public class MongoSessionManager extends NoSqlSessionManager
if (currentMaxIdle != null && getMaxInactiveInterval() > 0 && getMaxInactiveInterval() < currentMaxIdle)
sets.put(__MAX_IDLE, getMaxInactiveInterval());
if (currentExpiry != null && expiry > 0 && expiry != currentExpiry)
+ {
sets.put(__EXPIRY, expiry);
+ }
}
}
diff --git a/jetty-osgi/jetty-osgi-alpn/pom.xml b/jetty-osgi/jetty-osgi-alpn/pom.xml
index 621f3d1458..d6307719dc 100644
--- a/jetty-osgi/jetty-osgi-alpn/pom.xml
+++ b/jetty-osgi/jetty-osgi-alpn/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-osgi-alpn</artifactId>
diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
index 5b75afad2c..578c2ad42e 100644
--- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
+++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-osgi-boot-jsp</artifactId>
diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml
index b5b69b5163..6c3bf6185a 100644
--- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml
+++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml
index 9fc2e7f572..428612012b 100644
--- a/jetty-osgi/jetty-osgi-boot/pom.xml
+++ b/jetty-osgi/jetty-osgi-boot/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-osgi-boot</artifactId>
diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml
index c54033c23d..ad95aa1592 100644
--- a/jetty-osgi/jetty-osgi-httpservice/pom.xml
+++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-httpservice</artifactId>
diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml
index 32422e4e26..e72e88d0b7 100644
--- a/jetty-osgi/pom.xml
+++ b/jetty-osgi/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
diff --git a/jetty-osgi/test-jetty-osgi-context/pom.xml b/jetty-osgi/test-jetty-osgi-context/pom.xml
index 5aae6b09e4..561adbaf7a 100644
--- a/jetty-osgi/test-jetty-osgi-context/pom.xml
+++ b/jetty-osgi/test-jetty-osgi-context/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-jetty-osgi-context</artifactId>
diff --git a/jetty-osgi/test-jetty-osgi-webapp/pom.xml b/jetty-osgi/test-jetty-osgi-webapp/pom.xml
index 534df5d6e9..eeacbb70a5 100644
--- a/jetty-osgi/test-jetty-osgi-webapp/pom.xml
+++ b/jetty-osgi/test-jetty-osgi-webapp/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml
index 74d2aedef8..132bc64bc7 100644
--- a/jetty-osgi/test-jetty-osgi/pom.xml
+++ b/jetty-osgi/test-jetty-osgi/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-testrealm.xml b/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-testrealm.xml
index 4c8cb533cc..056e0c251b 100644
--- a/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-testrealm.xml
+++ b/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-testrealm.xml
@@ -13,7 +13,6 @@
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">Test Realm</Set>
<Set name="config"><Property name="jetty.home" default="src/test/config"/>realm.properties</Set>
- <Set name="refreshInterval">0</Set>
</New>
</Arg>
</Call>
diff --git a/jetty-overlay-deployer/src/main/config/modules/overlay.mod b/jetty-overlay-deployer/src/main/config/modules/overlay.mod
index 87bf9e1722..1c95193c1d 100644
--- a/jetty-overlay-deployer/src/main/config/modules/overlay.mod
+++ b/jetty-overlay-deployer/src/main/config/modules/overlay.mod
@@ -1,6 +1,6 @@
-#
-# Jetty Overlay module
-#
+[description]
+Enable the jetty overlay deployer that allows
+webapplications to be dynamically composed of layers.
[depend]
deploy
diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml
index 1471c2a739..9dc78f9980 100644
--- a/jetty-plus/pom.xml
+++ b/jetty-plus/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-plus</artifactId>
diff --git a/jetty-plus/src/main/config/modules/plus.mod b/jetty-plus/src/main/config/modules/plus.mod
index aac0f8f3ec..a424117b17 100644
--- a/jetty-plus/src/main/config/modules/plus.mod
+++ b/jetty-plus/src/main/config/modules/plus.mod
@@ -1,6 +1,7 @@
-#
-# Jetty Plus module
-#
+[description]
+Enables JNDI and resource injection for webapplications
+and other servlet 3.x features not supported in the core
+jetty webapps module.
[depend]
server
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java
index 129b300e9a..1cd7570b5b 100644
--- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java
+++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java
@@ -127,7 +127,7 @@ public class ContainerInitializer
try
{
for (String s : _applicableTypeNames)
- classes.add(Loader.loadClass(context.getClass(), s));
+ classes.add(Loader.loadClass(s));
context.getServletContext().setExtendedListenerTypes(true);
if (LOG.isDebugEnabled())
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java
index f226179e67..16f555fd8a 100644
--- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java
+++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java
@@ -106,7 +106,7 @@ public abstract class LifeCycleCallback
if (_target == null)
{
if (_targetClass == null)
- _targetClass = Loader.loadClass(null, _className);
+ _targetClass = Loader.loadClass(_className);
_target = _targetClass.getDeclaredMethod(_methodName, TypeUtil.NO_ARGS);
}
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/security/DataSourceLoginService.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/security/DataSourceLoginService.java
index e3ab07f898..7b19b7cb3a 100644
--- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/security/DataSourceLoginService.java
+++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/security/DataSourceLoginService.java
@@ -32,14 +32,12 @@ import java.util.Locale;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-import javax.servlet.ServletRequest;
import javax.sql.DataSource;
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
+import org.eclipse.jetty.security.AbstractLoginService;
import org.eclipse.jetty.security.IdentityService;
-import org.eclipse.jetty.security.MappedLoginService;
import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.security.Credential;
@@ -51,7 +49,7 @@ import org.eclipse.jetty.util.security.Credential;
* Obtain user/password/role information from a database
* via jndi DataSource.
*/
-public class DataSourceLoginService extends MappedLoginService
+public class DataSourceLoginService extends AbstractLoginService
{
private static final Logger LOG = Log.getLogger(DataSourceLoginService.class);
@@ -68,8 +66,6 @@ public class DataSourceLoginService extends MappedLoginService
private String _userRoleTableName = "user_roles";
private String _userRoleTableUserKey = "user_id";
private String _userRoleTableRoleKey = "role_id";
- private int _cacheMs = 30000;
- private long _lastPurge = 0;
private String _userSql;
private String _roleSql;
private boolean _createTables = false;
@@ -78,11 +74,11 @@ public class DataSourceLoginService extends MappedLoginService
/**
* DBUser
*/
- public class DBUser extends KnownUser
+ public class DBUserPrincipal extends UserPrincipal
{
private int _key;
- public DBUser(String name, Credential credential, int key)
+ public DBUserPrincipal(String name, Credential credential, int key)
{
super(name, credential);
_key = key;
@@ -286,80 +282,10 @@ public class DataSourceLoginService extends MappedLoginService
_userRoleTableRoleKey = roleTableRoleKey;
}
- /* ------------------------------------------------------------ */
- public void setCacheMs (int ms)
- {
- _cacheMs=ms;
- }
-
- /* ------------------------------------------------------------ */
- public int getCacheMs ()
- {
- return _cacheMs;
- }
-
- /* ------------------------------------------------------------ */
- @Override
- protected void loadUsers()
- {
- }
-
-
+
/* ------------------------------------------------------------ */
- /** Load user's info from database.
- *
- * @param userName the user name
- */
- @Deprecated
- protected UserIdentity loadUser (String userName)
- {
- try
- {
- try (Connection connection = getConnection();
- PreparedStatement statement1 = connection.prepareStatement(_userSql))
- {
- statement1.setObject(1, userName);
- try (ResultSet rs1 = statement1.executeQuery())
- {
- if (rs1.next())
- {
- int key = rs1.getInt(_userTableKey);
- String credentials = rs1.getString(_userTablePasswordField);
-
- List<String> roles = new ArrayList<String>();
- try (PreparedStatement statement2 = connection.prepareStatement(_roleSql))
- {
- statement2.setInt(1, key);
- try (ResultSet rs2 = statement2.executeQuery())
- {
- while (rs2.next())
- {
- roles.add(rs2.getString(_roleTableRoleField));
- }
- }
- }
- return putUser(userName, Credential.getCredential(credentials), roles.toArray(new String[roles.size()]));
- }
- }
- }
- }
- catch (NamingException e)
- {
- LOG.warn("No datasource for "+_jndiName, e);
- }
- catch (SQLException e)
- {
- LOG.warn("Problem loading user info for "+userName, e);
- }
- return null;
- }
-
-
- /**
- * @see org.eclipse.jetty.security.MappedLoginService#loadUserInfo(java.lang.String)
- */
- public KnownUser loadUserInfo (String username)
+ public UserPrincipal loadUserInfo (String username)
{
try
{
@@ -374,7 +300,7 @@ public class DataSourceLoginService extends MappedLoginService
int key = rs1.getInt(_userTableKey);
String credentials = rs1.getString(_userTablePasswordField);
- return new DBUser(username, Credential.getCredential(credentials), key);
+ return new DBUserPrincipal(username, Credential.getCredential(credentials), key);
}
}
}
@@ -390,12 +316,11 @@ public class DataSourceLoginService extends MappedLoginService
return null;
}
- /**
- * @see org.eclipse.jetty.security.MappedLoginService#loadRoleInfo(org.eclipse.jetty.security.MappedLoginService.KnownUser)
- */
- public String[] loadRoleInfo (KnownUser user)
+
+ /* ------------------------------------------------------------ */
+ public String[] loadRoleInfo (UserPrincipal user)
{
- DBUser dbuser = (DBUser)user;
+ DBUserPrincipal dbuser = (DBUserPrincipal)user;
try
{
@@ -428,19 +353,7 @@ public class DataSourceLoginService extends MappedLoginService
return null;
}
- /* ------------------------------------------------------------ */
- @Override
- public UserIdentity login(String username, Object credentials, ServletRequest request)
- {
- long now = System.currentTimeMillis();
- if (now - _lastPurge > _cacheMs || _cacheMs == 0)
- {
- _users.clear();
- _lastPurge = now;
- }
- return super.login(username,credentials, request);
- }
/* ------------------------------------------------------------ */
/**
@@ -495,6 +408,11 @@ public class DataSourceLoginService extends MappedLoginService
prepareTables();
}
+ /* ------------------------------------------------------------ */
+ /**
+ * @throws NamingException
+ * @throws SQLException
+ */
private void prepareTables()
throws NamingException, SQLException
{
@@ -595,6 +513,12 @@ public class DataSourceLoginService extends MappedLoginService
}
}
+ /* ------------------------------------------------------------ */
+ /**
+ * @return
+ * @throws NamingException
+ * @throws SQLException
+ */
private Connection getConnection ()
throws NamingException, SQLException
{
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java
index 2f26edfc7a..1a401d6689 100644
--- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java
+++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java
@@ -41,6 +41,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.webapp.AbstractConfiguration;
import org.eclipse.jetty.webapp.Configuration;
+import org.eclipse.jetty.webapp.WebAppClassLoader;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration;
@@ -113,7 +114,7 @@ public class EnvConfiguration extends AbstractConfiguration
{
localContextRoot.getRoot().addListener(listener);
XmlConfiguration configuration = new XmlConfiguration(jettyEnvXmlUrl);
- configuration.configure(context);
+ WebAppClassLoader.runWithServerClassAccess(()->{configuration.configure(context);return null;});
}
finally
{
diff --git a/jetty-proxy/pom.xml b/jetty-proxy/pom.xml
index d284a784cd..260dba6be6 100644
--- a/jetty-proxy/pom.xml
+++ b/jetty-proxy/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-proxy</artifactId>
diff --git a/jetty-proxy/src/main/config/modules/proxy.mod b/jetty-proxy/src/main/config/modules/proxy.mod
index 6b91f68914..c14ee0cba7 100644
--- a/jetty-proxy/src/main/config/modules/proxy.mod
+++ b/jetty-proxy/src/main/config/modules/proxy.mod
@@ -1,6 +1,6 @@
-#
-# Jetty Proxy module
-#
+[description]
+Enable the Jetty Proxy, that allows the server to act
+as a non-transparent proxy for browsers.
[depend]
servlet
diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java
index 9d0c49fb2e..7b196626f3 100644
--- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java
+++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java
@@ -22,6 +22,7 @@ import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.HashSet;
@@ -45,6 +46,7 @@ import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
+import org.eclipse.jetty.io.SocketChannelEndPoint;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConnection;
import org.eclipse.jetty.server.HttpTransport;
@@ -332,7 +334,7 @@ public class ConnectHandler extends HandlerWrapper
HttpConnection httpConnection = connectContext.getHttpConnection();
EndPoint downstreamEndPoint = httpConnection.getEndPoint();
- DownstreamConnection downstreamConnection = newDownstreamConnection(downstreamEndPoint, context, BufferUtil.EMPTY_BUFFER);
+ DownstreamConnection downstreamConnection = newDownstreamConnection(downstreamEndPoint, context);
downstreamConnection.setInputBufferSize(getBufferSize());
upstreamConnection.setConnection(downstreamConnection);
@@ -389,15 +391,6 @@ public class ConnectHandler extends HandlerWrapper
return true;
}
- /**
- * @deprecated use {@link #newDownstreamConnection(EndPoint, ConcurrentMap)} instead
- */
- @Deprecated
- protected DownstreamConnection newDownstreamConnection(EndPoint endPoint, ConcurrentMap<String, Object> context, ByteBuffer buffer)
- {
- return newDownstreamConnection(endPoint, context);
- }
-
protected DownstreamConnection newDownstreamConnection(EndPoint endPoint, ConcurrentMap<String, Object> context)
{
return new DownstreamConnection(endPoint, getExecutor(), getByteBufferPool(), context);
@@ -434,22 +427,13 @@ public class ConnectHandler extends HandlerWrapper
*/
protected int read(EndPoint endPoint, ByteBuffer buffer, ConcurrentMap<String, Object> context) throws IOException
{
- int read = read(endPoint, buffer);
+ int read = endPoint.fill(buffer);
if (LOG.isDebugEnabled())
LOG.debug("{} read {} bytes", this, read);
return read;
}
/**
- * @deprecated override {@link #read(EndPoint, ByteBuffer, ConcurrentMap)} instead
- */
- @Deprecated
- protected int read(EndPoint endPoint, ByteBuffer buffer) throws IOException
- {
- return endPoint.fill(buffer);
- }
-
- /**
* <p>Writes (with non-blocking semantic) the given buffer of data onto the given endPoint.</p>
*
* @param endPoint the endPoint to write to
@@ -461,15 +445,6 @@ public class ConnectHandler extends HandlerWrapper
{
if (LOG.isDebugEnabled())
LOG.debug("{} writing {} bytes", this, buffer.remaining());
- write(endPoint, buffer, callback);
- }
-
- /**
- * @deprecated override {@link #write(EndPoint, ByteBuffer, Callback, ConcurrentMap)} instead
- */
- @Deprecated
- protected void write(EndPoint endPoint, ByteBuffer buffer, Callback callback)
- {
endPoint.write(callback, buffer);
}
@@ -529,16 +504,18 @@ public class ConnectHandler extends HandlerWrapper
}
@Override
- protected EndPoint newEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey selectionKey) throws IOException
+ protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key) throws IOException
{
- return new SelectChannelEndPoint(channel, selector, selectionKey, getScheduler(), getIdleTimeout());
+ SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler());
+ endp.setIdleTimeout(getIdleTimeout());
+ return endp;
}
@Override
- public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException
+ public Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment) throws IOException
{
if (ConnectHandler.LOG.isDebugEnabled())
- ConnectHandler.LOG.debug("Connected to {}", channel.getRemoteAddress());
+ ConnectHandler.LOG.debug("Connected to {}", ((SocketChannel)channel).getRemoteAddress());
ConnectContext connectContext = (ConnectContext)attachment;
UpstreamConnection connection = newUpstreamConnection(endpoint, connectContext);
connection.setInputBufferSize(getBufferSize());
@@ -546,7 +523,7 @@ public class ConnectHandler extends HandlerWrapper
}
@Override
- protected void connectionFailed(SocketChannel channel, final Throwable ex, final Object attachment)
+ protected void connectionFailed(SelectableChannel channel, final Throwable ex, final Object attachment)
{
close(channel);
ConnectContext connectContext = (ConnectContext)attachment;
@@ -636,15 +613,6 @@ public class ConnectHandler extends HandlerWrapper
super(endPoint, executor, bufferPool, context);
}
- /**
- * @deprecated use {@link #DownstreamConnection(EndPoint, Executor, ByteBufferPool, ConcurrentMap)} instead
- */
- @Deprecated
- public DownstreamConnection(EndPoint endPoint, Executor executor, ByteBufferPool bufferPool, ConcurrentMap<String, Object> context, ByteBuffer buffer)
- {
- this(endPoint, executor, bufferPool, context);
- }
-
@Override
public void onUpgradeTo(ByteBuffer buffer)
{
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
index 1f96b48a51..4d2dcc9233 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
@@ -61,6 +61,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jetty.client.DuplexConnectionPool;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpContentResponse;
import org.eclipse.jetty.client.HttpProxy;
@@ -1081,7 +1082,8 @@ public class ProxyServletTest
Assert.assertEquals(-1, input.read());
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", port);
- Assert.assertEquals(0, destination.getConnectionPool().getIdleConnections().size());
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
+ Assert.assertEquals(0, connectionPool.getIdleConnections().size());
}
@Test
@@ -1154,7 +1156,8 @@ public class ProxyServletTest
}
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", port);
- Assert.assertEquals(0, destination.getConnectionPool().getIdleConnections().size());
+ DuplexConnectionPool connectionPool = (DuplexConnectionPool)destination.getConnectionPool();
+ Assert.assertEquals(0, connectionPool.getIdleConnections().size());
}
@Test
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java
index e563962b6d..fd333cd88e 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java
@@ -54,6 +54,7 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
@@ -87,7 +88,10 @@ public class ProxyTunnellingTest
sslContextFactory.setKeyStorePath(keyStorePath);
sslContextFactory.setKeyStorePassword("storepwd");
sslContextFactory.setKeyManagerPassword("keypwd");
- server = new Server();
+
+ QueuedThreadPool serverThreads = new QueuedThreadPool();
+ serverThreads.setName("server");
+ server = new Server(serverThreads);
serverConnector = new ServerConnector(server, sslContextFactory);
server.addConnector(serverConnector);
server.setHandler(handler);
@@ -101,7 +105,9 @@ public class ProxyTunnellingTest
protected void startProxy(ConnectHandler connectHandler) throws Exception
{
- proxy = new Server();
+ QueuedThreadPool proxyThreads = new QueuedThreadPool();
+ proxyThreads.setName("proxy");
+ proxy = new Server(proxyThreads);
proxyConnector = new ServerConnector(proxy);
proxy.addConnector(proxyConnector);
// Under Windows, it takes a while to detect that a connection
@@ -136,7 +142,7 @@ public class ProxyTunnellingTest
}
}
- @Test
+ @Test(timeout=60000)
public void testOneExchangeViaSSL() throws Exception
{
startSSLServer(new ServerHandler());
@@ -167,7 +173,7 @@ public class ProxyTunnellingTest
}
}
- @Test
+ @Test(timeout=60000)
public void testTwoExchangesViaSSL() throws Exception
{
startSSLServer(new ServerHandler());
@@ -210,7 +216,7 @@ public class ProxyTunnellingTest
}
}
- @Test
+ @Test(timeout=60000)
public void testTwoConcurrentExchangesViaSSL() throws Exception
{
startSSLServer(new ServerHandler());
@@ -278,7 +284,7 @@ public class ProxyTunnellingTest
}
}
- @Test
+ @Test(timeout=60000)
public void testShortIdleTimeoutOverriddenByRequest() throws Exception
{
// Short idle timeout for HttpClient.
@@ -331,7 +337,7 @@ public class ProxyTunnellingTest
}
}
- @Test
+ @Test(timeout=60000)
public void testProxyDown() throws Exception
{
startSSLServer(new ServerHandler());
@@ -363,7 +369,7 @@ public class ProxyTunnellingTest
}
}
- @Test
+ @Test(timeout=60000)
public void testServerDown() throws Exception
{
startSSLServer(new ServerHandler());
@@ -395,7 +401,7 @@ public class ProxyTunnellingTest
}
}
- @Test
+ @Test(timeout=60000)
public void testProxyClosesConnection() throws Exception
{
startSSLServer(new ServerHandler());
@@ -429,7 +435,7 @@ public class ProxyTunnellingTest
}
}
- @Test
+ @Test(timeout=60000)
@Ignore("External Proxy Server no longer stable enough for testing")
public void testExternalProxy() throws Exception
{
diff --git a/jetty-quickstart/pom.xml b/jetty-quickstart/pom.xml
index 8e35ba3aad..be03980712 100644
--- a/jetty-quickstart/pom.xml
+++ b/jetty-quickstart/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty</groupId>
diff --git a/jetty-quickstart/src/main/config/modules/quickstart.mod b/jetty-quickstart/src/main/config/modules/quickstart.mod
index 4e59dd0862..cefa5f1688 100644
--- a/jetty-quickstart/src/main/config/modules/quickstart.mod
+++ b/jetty-quickstart/src/main/config/modules/quickstart.mod
@@ -1,6 +1,6 @@
-#
-# Jetty Quickstart module
-#
+[description]
+Enables the Jetty Quickstart module for rapid
+deployment of preconfigured webapplications.
[depend]
server
diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml
index 18a38920a8..0bd15bb35a 100644
--- a/jetty-rewrite/pom.xml
+++ b/jetty-rewrite/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-rewrite</artifactId>
diff --git a/jetty-rewrite/src/main/config/modules/rewrite.mod b/jetty-rewrite/src/main/config/modules/rewrite.mod
index c8a1750618..3b741a1a0d 100644
--- a/jetty-rewrite/src/main/config/modules/rewrite.mod
+++ b/jetty-rewrite/src/main/config/modules/rewrite.mod
@@ -1,6 +1,6 @@
-#
-# Jetty Rewrite module
-#
+[description]
+Enables the jetty-rewrite handler. Specific rewrite
+rules must be added to etc/jetty-rewrite.xml
[depend]
server
diff --git a/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml b/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml
index 9ac510991d..1afc803096 100644
--- a/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml
+++ b/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml
@@ -240,7 +240,6 @@
<New class="org.eclipse.jetty.security.jaspi.modules.HashLoginService">
<Set name="name">Test Realm</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
- <Set name="refreshInterval">0</Set>
</New>
</Item>
</Array>
diff --git a/jetty-runner/pom.xml b/jetty-runner/pom.xml
index 17be7ef8a0..c7eb427888 100644
--- a/jetty-runner/pom.xml
+++ b/jetty-runner/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-runner</artifactId>
diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml
index fa0ea8cc1a..f789288cb3 100644
--- a/jetty-security/pom.xml
+++ b/jetty-security/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-security</artifactId>
diff --git a/jetty-security/src/main/config/modules/security.mod b/jetty-security/src/main/config/modules/security.mod
index ba3163275f..3955fcfee8 100644
--- a/jetty-security/src/main/config/modules/security.mod
+++ b/jetty-security/src/main/config/modules/security.mod
@@ -1,6 +1,5 @@
-#
-# Jetty Security Module
-#
+[description]
+Adds servlet standard security handling to the classpath.
[depend]
server
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/AbstractLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/AbstractLoginService.java
new file mode 100644
index 0000000000..696a378662
--- /dev/null
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/AbstractLoginService.java
@@ -0,0 +1,248 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+
+package org.eclipse.jetty.security;
+
+import java.io.Serializable;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+import javax.servlet.ServletRequest;
+
+
+import org.eclipse.jetty.server.UserIdentity;
+import org.eclipse.jetty.util.component.AbstractLifeCycle;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.util.security.Credential;
+
+/**
+ * AbstractLoginService
+ */
+public abstract class AbstractLoginService extends AbstractLifeCycle implements LoginService
+{
+ private static final Logger LOG = Log.getLogger(AbstractLoginService.class);
+
+ protected IdentityService _identityService=new DefaultIdentityService();
+ protected String _name;
+ protected boolean _fullValidate = false;
+
+
+ /* ------------------------------------------------------------ */
+ /**
+ * RolePrincipal
+ */
+ public static class RolePrincipal implements Principal,Serializable
+ {
+ private static final long serialVersionUID = 2998397924051854402L;
+ private final String _roleName;
+ public RolePrincipal(String name)
+ {
+ _roleName=name;
+ }
+ public String getName()
+ {
+ return _roleName;
+ }
+ }
+
+
+ /* ------------------------------------------------------------ */
+ /**
+ * UserPrincipal
+ */
+ public static class UserPrincipal implements Principal,Serializable
+ {
+ private static final long serialVersionUID = -6226920753748399662L;
+ private final String _name;
+ private final Credential _credential;
+
+
+ /* -------------------------------------------------------- */
+ public UserPrincipal(String name,Credential credential)
+ {
+ _name=name;
+ _credential=credential;
+ }
+
+ /* -------------------------------------------------------- */
+ public boolean authenticate(Object credentials)
+ {
+ return _credential!=null && _credential.check(credentials);
+ }
+
+ /* -------------------------------------------------------- */
+ public boolean authenticate (Credential c)
+ {
+ return(_credential != null && c != null && _credential.equals(c));
+ }
+
+ /* ------------------------------------------------------------ */
+ public String getName()
+ {
+ return _name;
+ }
+
+
+
+ /* -------------------------------------------------------- */
+ @Override
+ public String toString()
+ {
+ return _name;
+ }
+ }
+
+ /* ------------------------------------------------------------ */
+ protected abstract String[] loadRoleInfo (UserPrincipal user);
+
+ /* ------------------------------------------------------------ */
+ protected abstract UserPrincipal loadUserInfo (String username);
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.security.LoginService#getName()
+ */
+ @Override
+ public String getName()
+ {
+ return _name;
+ }
+
+ /* ------------------------------------------------------------ */
+ /** Set the identityService.
+ * @param identityService the identityService to set
+ */
+ public void setIdentityService(IdentityService identityService)
+ {
+ if (isRunning())
+ throw new IllegalStateException("Running");
+ _identityService = identityService;
+ }
+
+ /* ------------------------------------------------------------ */
+ /** Set the name.
+ * @param name the name to set
+ */
+ public void setName(String name)
+ {
+ if (isRunning())
+ throw new IllegalStateException("Running");
+ _name = name;
+ }
+
+ /* ------------------------------------------------------------ */
+ @Override
+ public String toString()
+ {
+ return this.getClass().getSimpleName()+"["+_name+"]";
+ }
+
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.security.LoginService#login(java.lang.String, java.lang.Object, javax.servlet.ServletRequest)
+ */
+ @Override
+ public UserIdentity login(String username, Object credentials, ServletRequest request)
+ {
+ if (username == null)
+ return null;
+
+ UserPrincipal userPrincipal = loadUserInfo(username);
+ if (userPrincipal.authenticate(credentials))
+ {
+ //safe to load the roles
+ String[] roles = loadRoleInfo(userPrincipal);
+
+ Subject subject = new Subject();
+ subject.getPrincipals().add(userPrincipal);
+ subject.getPrivateCredentials().add(userPrincipal._credential);
+ if (roles!=null)
+ for (String role : roles)
+ subject.getPrincipals().add(new RolePrincipal(role));
+ subject.setReadOnly();
+ return _identityService.newUserIdentity(subject,userPrincipal,roles);
+ }
+
+ return null;
+
+ }
+
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.security.LoginService#validate(org.eclipse.jetty.server.UserIdentity)
+ */
+ @Override
+ public boolean validate(UserIdentity user)
+ {
+ if (!isFullValidate())
+ return true; //if we have a user identity it must be valid
+
+ //Do a full validation back against the user store
+ UserPrincipal fresh = loadUserInfo(user.getUserPrincipal().getName());
+ if (fresh == null)
+ return false; //user no longer exists
+
+ if (user.getUserPrincipal() instanceof UserPrincipal)
+ {
+ System.err.println("VALIDATING user "+fresh.getName());
+ return fresh.authenticate(((UserPrincipal)user.getUserPrincipal())._credential);
+ }
+
+ throw new IllegalStateException("UserPrincipal not KnownUser"); //can't validate
+ }
+
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.security.LoginService#getIdentityService()
+ */
+ @Override
+ public IdentityService getIdentityService()
+ {
+ return _identityService;
+ }
+
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.security.LoginService#logout(org.eclipse.jetty.server.UserIdentity)
+ */
+ @Override
+ public void logout(UserIdentity user)
+ {
+ //Override in subclasses
+
+ }
+
+ /* ------------------------------------------------------------ */
+ public boolean isFullValidate()
+ {
+ return _fullValidate;
+ }
+
+ /* ------------------------------------------------------------ */
+ public void setFullValidate(boolean fullValidate)
+ {
+ _fullValidate = fullValidate;
+ }
+
+}
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java
index e9f18b59c2..108ca0ad6f 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java
@@ -23,7 +23,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import org.eclipse.jetty.security.MappedLoginService.KnownUser;
import org.eclipse.jetty.security.PropertyUserStore.UserListener;
import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.Scanner;
@@ -49,37 +48,15 @@ import org.eclipse.jetty.util.security.Credential;
* <p>
* If DIGEST Authentication is used, the password must be in a recoverable format, either plain text or OBF:.
*/
-public class HashLoginService extends MappedLoginService implements UserListener
+public class HashLoginService extends AbstractLoginService
{
private static final Logger LOG = Log.getLogger(HashLoginService.class);
- private PropertyUserStore _propertyUserStore;
- private String _config;
- private Resource _configResource;
- private Scanner _scanner;
- private boolean hotReload = false; // default is not to reload
+ protected PropertyUserStore _propertyUserStore;
+ protected String _config;
+ protected Resource _configResource;
+ protected boolean hotReload = false; // default is not to reload
-
-
- public class HashKnownUser extends KnownUser
- {
- String[] _roles;
-
- public HashKnownUser(String name, Credential credential)
- {
- super(name, credential);
- }
-
- public void setRoles (String[] roles)
- {
- _roles = roles;
- }
-
- public String[] getRoles()
- {
- return _roles;
- }
- }
/* ------------------------------------------------------------ */
public HashLoginService()
@@ -153,46 +130,11 @@ public class HashLoginService extends MappedLoginService implements UserListener
this.hotReload = enable;
}
- /* ------------------------------------------------------------ */
- /**
- * sets the refresh interval (in seconds)
- * @param sec the refresh interval
- * @deprecated use {@link #setHotReload(boolean)} instead
- */
- @Deprecated
- public void setRefreshInterval(int sec)
- {
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return refresh interval in seconds for how often the properties file should be checked for changes
- * @deprecated use {@link #isHotReload()} instead
- */
- @Deprecated
- public int getRefreshInterval()
- {
- return (hotReload)?1:0;
- }
-
- /* ------------------------------------------------------------ */
- @Override
- protected UserIdentity loadUser(String username)
- {
- return null;
- }
+
/* ------------------------------------------------------------ */
@Override
- public void loadUsers() throws IOException
- {
- // TODO: Consider refactoring MappedLoginService to not have to override with unused methods
- }
-
-
-
- @Override
- protected String[] loadRoleInfo(KnownUser user)
+ protected String[] loadRoleInfo(UserPrincipal user)
{
UserIdentity id = _propertyUserStore.getUserIdentity(user.getName());
if (id == null)
@@ -210,13 +152,17 @@ public class HashLoginService extends MappedLoginService implements UserListener
return list.toArray(new String[roles.size()]);
}
+
+
+
+ /* ------------------------------------------------------------ */
@Override
- protected KnownUser loadUserInfo(String userName)
+ protected UserPrincipal loadUserInfo(String userName)
{
UserIdentity id = _propertyUserStore.getUserIdentity(userName);
if (id != null)
{
- return (KnownUser)id.getUserPrincipal();
+ return (UserPrincipal)id.getUserPrincipal();
}
return null;
@@ -241,7 +187,6 @@ public class HashLoginService extends MappedLoginService implements UserListener
_propertyUserStore = new PropertyUserStore();
_propertyUserStore.setHotReload(hotReload);
_propertyUserStore.setConfigPath(_config);
- _propertyUserStore.registerUserListener(this);
_propertyUserStore.start();
}
}
@@ -254,28 +199,5 @@ public class HashLoginService extends MappedLoginService implements UserListener
protected void doStop() throws Exception
{
super.doStop();
- if (_scanner != null)
- _scanner.stop();
- _scanner = null;
- }
-
- /* ------------------------------------------------------------ */
- @Override
- public void update(String userName, Credential credential, String[] roleArray)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("update: " + userName + " Roles: " + roleArray.length);
- //TODO need to remove and replace the authenticated user?
- }
-
-
-
- /* ------------------------------------------------------------ */
- @Override
- public void remove(String userName)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("remove: " + userName);
- removeUser(userName);
}
}
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java
index e2f3d8aa4e..7f38d07a49 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java
@@ -52,7 +52,7 @@ import org.eclipse.jetty.util.security.Credential;
* An example properties file for configuration is in
* <code>${jetty.home}/etc/jdbcRealm.properties</code>
*/
-public class JDBCLoginService extends MappedLoginService
+public class JDBCLoginService extends AbstractLoginService
{
private static final Logger LOG = Log.getLogger(JDBCLoginService.class);
@@ -64,8 +64,6 @@ public class JDBCLoginService extends MappedLoginService
protected String _userTableKey;
protected String _userTablePasswordField;
protected String _roleTableRoleField;
- protected int _cacheTime;
- protected long _lastHashPurge;
protected Connection _con;
protected String _userSql;
protected String _roleSql;
@@ -74,11 +72,11 @@ public class JDBCLoginService extends MappedLoginService
/**
* JDBCKnownUser
*/
- public class JDBCKnownUser extends KnownUser
+ public class JDBCUserPrincipal extends UserPrincipal
{
int _userKey;
- public JDBCKnownUser(String name, Credential credential, int key)
+ public JDBCUserPrincipal(String name, Credential credential, int key)
{
super(name, credential);
_userKey = key;
@@ -123,9 +121,6 @@ public class JDBCLoginService extends MappedLoginService
/* ------------------------------------------------------------ */
- /**
- * @see org.eclipse.jetty.security.MappedLoginService#doStart()
- */
@Override
protected void doStart() throws Exception
{
@@ -149,20 +144,18 @@ public class JDBCLoginService extends MappedLoginService
String _userRoleTable = properties.getProperty("userroletable");
String _userRoleTableUserKey = properties.getProperty("userroletableuserkey");
String _userRoleTableRoleKey = properties.getProperty("userroletablerolekey");
- _cacheTime = new Integer(properties.getProperty("cachetime"));
+
if (_jdbcDriver == null || _jdbcDriver.equals("")
|| _url == null
|| _url.equals("")
|| _userName == null
|| _userName.equals("")
- || _password == null
- || _cacheTime < 0)
+ || _password == null)
{
LOG.warn("UserRealm " + getName() + " has not been properly configured");
}
- _cacheTime *= 1000;
- _lastHashPurge = 0;
+
_userSql = "select " + _userTableKey + "," + _userTablePasswordField + " from " + _userTable + " where " + _userTableUserField + " = ?";
_roleSql = "select r." + _roleTableRoleField
+ " from "
@@ -177,7 +170,7 @@ public class JDBCLoginService extends MappedLoginService
+ " = u."
+ _userRoleTableRoleKey;
- Loader.loadClass(this.getClass(), _jdbcDriver).newInstance();
+ Loader.loadClass(_jdbcDriver).newInstance();
super.doStart();
}
@@ -222,79 +215,11 @@ public class JDBCLoginService extends MappedLoginService
}
}
- /* ------------------------------------------------------------ */
- @Override
- public UserIdentity login(String username, Object credentials, ServletRequest request)
- {
- long now = System.currentTimeMillis();
- if (now - _lastHashPurge > _cacheTime || _cacheTime == 0)
- {
- _users.clear();
- _lastHashPurge = now;
- closeConnection();
- }
-
- return super.login(username,credentials, request);
- }
-
- /* ------------------------------------------------------------ */
- @Override
- protected void loadUsers()
- {
- }
+
- /* ------------------------------------------------------------ */
- @Deprecated
- protected UserIdentity loadUser(String username)
- {
- try
- {
- if (null == _con)
- connectDatabase();
-
- if (null == _con)
- throw new SQLException("Can't connect to database");
-
- try (PreparedStatement stat1 = _con.prepareStatement(_userSql))
- {
- stat1.setObject(1, username);
- try (ResultSet rs1 = stat1.executeQuery())
- {
- if (rs1.next())
- {
- int key = rs1.getInt(_userTableKey);
- String credentials = rs1.getString(_userTablePasswordField);
-
-
- List<String> roles = new ArrayList<String>();
-
- try (PreparedStatement stat2 = _con.prepareStatement(_roleSql))
- {
- stat2.setInt(1, key);
- try (ResultSet rs2 = stat2.executeQuery())
- {
- while (rs2.next())
- roles.add(rs2.getString(_roleTableRoleField));
- }
- }
- return putUser(username, Credential.getCredential(credentials), roles.toArray(new String[roles.size()]));
- }
- }
- }
- }
- catch (SQLException e)
- {
- LOG.warn("UserRealm " + getName() + " could not load user information from database", e);
- closeConnection();
- }
- return null;
- }
-
- /**
- * @see org.eclipse.jetty.security.MappedLoginService#loadUserInfo(java.lang.String)
- */
- public KnownUser loadUserInfo (String username)
+ /* ------------------------------------------------------------ */
+ public UserPrincipal loadUserInfo (String username)
{
try
{
@@ -314,7 +239,7 @@ public class JDBCLoginService extends MappedLoginService
int key = rs1.getInt(_userTableKey);
String credentials = rs1.getString(_userTablePasswordField);
- return new JDBCKnownUser (username, Credential.getCredential(credentials), key);
+ return new JDBCUserPrincipal (username, Credential.getCredential(credentials), key);
}
}
}
@@ -329,13 +254,10 @@ public class JDBCLoginService extends MappedLoginService
}
-
- /**
- * @see org.eclipse.jetty.security.MappedLoginService#loadRoleInfo(org.eclipse.jetty.security.MappedLoginService.KnownUser)
- */
- public String[] loadRoleInfo (KnownUser user)
+ /* ------------------------------------------------------------ */
+ public String[] loadRoleInfo (UserPrincipal user)
{
- JDBCKnownUser jdbcUser = (JDBCKnownUser)user;
+ JDBCUserPrincipal jdbcUser = (JDBCUserPrincipal)user;
try
{
@@ -369,6 +291,18 @@ public class JDBCLoginService extends MappedLoginService
}
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStop()
+ */
+ @Override
+ protected void doStop() throws Exception
+ {
+ closeConnection();
+ super.doStop();
+ }
+
+ /* ------------------------------------------------------------ */
/**
* Close an existing connection
*/
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/MappedLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/MappedLoginService.java
deleted file mode 100644
index 310a4db8bc..0000000000
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/MappedLoginService.java
+++ /dev/null
@@ -1,375 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-
-package org.eclipse.jetty.security;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.security.Principal;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.security.auth.Subject;
-import javax.servlet.ServletRequest;
-
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
-import org.eclipse.jetty.util.security.Credential;
-
-
-
-/* ------------------------------------------------------------ */
-/**
- * A login service that keeps UserIdentities in a concurrent map
- * either as the source or a cache of the users.
- *
- */
-public abstract class MappedLoginService extends AbstractLifeCycle implements LoginService
-{
- private static final Logger LOG = Log.getLogger(MappedLoginService.class);
-
- protected IdentityService _identityService=new DefaultIdentityService();
- protected String _name;
- protected final ConcurrentMap<String, UserIdentity> _users=new ConcurrentHashMap<String, UserIdentity>();
-
- /* ------------------------------------------------------------ */
- protected MappedLoginService()
- {
- }
-
- /* ------------------------------------------------------------ */
- /** Get the name.
- * @return the name
- */
- public String getName()
- {
- return _name;
- }
-
- /* ------------------------------------------------------------ */
- /** Get the identityService.
- * @return the identityService
- */
- public IdentityService getIdentityService()
- {
- return _identityService;
- }
-
- /* ------------------------------------------------------------ */
- /** Get the users.
- * @return the users
- */
- public ConcurrentMap<String, UserIdentity> getUsers()
- {
- return _users;
- }
-
- /* ------------------------------------------------------------ */
- /** Set the identityService.
- * @param identityService the identityService to set
- */
- public void setIdentityService(IdentityService identityService)
- {
- if (isRunning())
- throw new IllegalStateException("Running");
- _identityService = identityService;
- }
-
- /* ------------------------------------------------------------ */
- /** Set the name.
- * @param name the name to set
- */
- public void setName(String name)
- {
- if (isRunning())
- throw new IllegalStateException("Running");
- _name = name;
- }
-
- /* ------------------------------------------------------------ */
- /** Set the users.
- * @param users the users to set
- */
- public void setUsers(Map<String, UserIdentity> users)
- {
- if (isRunning())
- throw new IllegalStateException("Running");
- _users.clear();
- _users.putAll(users);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
- */
- @Override
- protected void doStart() throws Exception
- {
- loadUsers();
- super.doStart();
- }
-
- /* ------------------------------------------------------------ */
- @Override
- protected void doStop() throws Exception
- {
- super.doStop();
- }
-
- /* ------------------------------------------------------------ */
- public void logout(UserIdentity identity)
- {
- LOG.debug("logout {}",identity);
-
- //TODO should remove the user?????
- }
-
- /* ------------------------------------------------------------ */
- @Override
- public String toString()
- {
- return this.getClass().getSimpleName()+"["+_name+"]";
- }
-
- /* ------------------------------------------------------------ */
- /** Put user into realm.
- * Called by implementations to put the user data loaded from
- * file/db etc into the user structure.
- * @param userName User name
- * @param info a UserIdentity instance, or a String password or Credential instance
- * @return User instance
- */
- protected synchronized UserIdentity putUser(String userName, Object info)
- {
- final UserIdentity identity;
- if (info instanceof UserIdentity)
- identity=(UserIdentity)info;
- else
- {
- Credential credential = (info instanceof Credential)?(Credential)info:Credential.getCredential(info.toString());
-
- Principal userPrincipal = new KnownUser(userName,credential);
- Subject subject = new Subject();
- subject.getPrincipals().add(userPrincipal);
- subject.getPrivateCredentials().add(credential);
- subject.setReadOnly();
- identity=_identityService.newUserIdentity(subject,userPrincipal,IdentityService.NO_ROLES);
- }
-
- _users.put(userName,identity);
- return identity;
- }
-
- /* ------------------------------------------------------------ */
- /** Put user into realm.
- * @param userName The user to add
- * @param credential The users Credentials
- * @param roles The users roles
- * @return UserIdentity
- */
- public synchronized UserIdentity putUser(String userName, Credential credential, String[] roles)
- {
- Principal userPrincipal = new KnownUser(userName,credential);
- Subject subject = new Subject();
- subject.getPrincipals().add(userPrincipal);
- subject.getPrivateCredentials().add(credential);
-
- if (roles!=null)
- for (String role : roles)
- subject.getPrincipals().add(new RolePrincipal(role));
-
- subject.setReadOnly();
- UserIdentity identity=_identityService.newUserIdentity(subject,userPrincipal,roles);
- _users.put(userName,identity);
- return identity;
- }
-
-
-
-
- public synchronized UserIdentity putUser (KnownUser userPrincipal, String[] roles)
- {
- Subject subject = new Subject();
- subject.getPrincipals().add(userPrincipal);
- subject.getPrivateCredentials().add(userPrincipal._credential);
- if (roles!=null)
- for (String role : roles)
- subject.getPrincipals().add(new RolePrincipal(role));
- subject.setReadOnly();
- UserIdentity identity=_identityService.newUserIdentity(subject,userPrincipal,roles);
- _users.put(userPrincipal._name,identity);
- return identity;
- }
-
-
- /* ------------------------------------------------------------ */
- public void removeUser(String username)
- {
- _users.remove(username);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @see org.eclipse.jetty.security.LoginService#login(java.lang.String, java.lang.Object, ServletRequest)
- */
- public UserIdentity login(String username, Object credentials, ServletRequest request)
- {
- if (username == null)
- return null;
-
- UserIdentity user = _users.get(username);
-
- if (user==null)
- {
- KnownUser userPrincipal = loadUserInfo(username);
- if (userPrincipal.authenticate(credentials))
- {
- //safe to load the roles
- String[] roles = loadRoleInfo(userPrincipal);
- user = putUser(userPrincipal, roles);
- return user;
- }
- }
- else
- {
- UserPrincipal principal = (UserPrincipal)user.getUserPrincipal();
- if (principal.authenticate(credentials))
- return user;
- }
- return null;
- }
-
- /* ------------------------------------------------------------ */
- public boolean validate(UserIdentity user)
- {
- if (_users.containsKey(user.getUserPrincipal().getName()))
- return true;
-
- if (loadUser(user.getUserPrincipal().getName())!=null)
- return true;
-
- return false;
- }
- /* ------------------------------------------------------------ */
- protected abstract String[] loadRoleInfo (KnownUser user);
- /* ------------------------------------------------------------ */
- protected abstract KnownUser loadUserInfo (String username);
- /* ------------------------------------------------------------ */
- protected abstract UserIdentity loadUser(String username);
-
- /* ------------------------------------------------------------ */
- protected abstract void loadUsers() throws IOException;
-
-
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- public interface UserPrincipal extends Principal,Serializable
- {
- boolean authenticate(Object credentials);
- public boolean isAuthenticated();
- }
-
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- public static class RolePrincipal implements Principal,Serializable
- {
- private static final long serialVersionUID = 2998397924051854402L;
- private final String _roleName;
- public RolePrincipal(String name)
- {
- _roleName=name;
- }
- public String getName()
- {
- return _roleName;
- }
- }
-
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- public static class Anonymous implements UserPrincipal,Serializable
- {
- private static final long serialVersionUID = 1097640442553284845L;
-
- public boolean isAuthenticated()
- {
- return false;
- }
-
- public String getName()
- {
- return "Anonymous";
- }
-
- public boolean authenticate(Object credentials)
- {
- return false;
- }
-
- }
-
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- /* ------------------------------------------------------------ */
- public static class KnownUser implements UserPrincipal,Serializable
- {
- private static final long serialVersionUID = -6226920753748399662L;
- private final String _name;
- private final Credential _credential;
-
- /* -------------------------------------------------------- */
- public KnownUser(String name,Credential credential)
- {
- _name=name;
- _credential=credential;
- }
-
- /* -------------------------------------------------------- */
- public boolean authenticate(Object credentials)
- {
- return _credential!=null && _credential.check(credentials);
- }
-
- /* ------------------------------------------------------------ */
- public String getName()
- {
- return _name;
- }
-
- /* -------------------------------------------------------- */
- public boolean isAuthenticated()
- {
- return true;
- }
-
- /* -------------------------------------------------------- */
- @Override
- public String toString()
- {
- return _name;
- }
- }
-}
-
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java b/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java
index 0bab932957..2d7a6368a6 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java
@@ -33,8 +33,7 @@ import java.util.Set;
import javax.security.auth.Subject;
-import org.eclipse.jetty.security.MappedLoginService.KnownUser;
-import org.eclipse.jetty.security.MappedLoginService.RolePrincipal;
+
import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.PathWatcher;
import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
@@ -64,17 +63,17 @@ public class PropertyUserStore extends AbstractLifeCycle implements PathWatcher.
{
private static final Logger LOG = Log.getLogger(PropertyUserStore.class);
- private Path _configPath;
- private Resource _configResource;
+ protected Path _configPath;
+ protected Resource _configResource;
- private PathWatcher pathWatcher;
- private boolean hotReload = false; // default is not to reload
+ protected PathWatcher pathWatcher;
+ protected boolean hotReload = false; // default is not to reload
- private IdentityService _identityService = new DefaultIdentityService();
- private boolean _firstLoad = true; // true if first load, false from that point on
- private final List<String> _knownUsers = new ArrayList<String>();
- private final Map<String, UserIdentity> _knownUserIdentities = new HashMap<String, UserIdentity>();
- private List<UserListener> _listeners;
+ protected IdentityService _identityService = new DefaultIdentityService();
+ protected boolean _firstLoad = true; // true if first load, false from that point on
+ protected final List<String> _knownUsers = new ArrayList<String>();
+ protected final Map<String, UserIdentity> _knownUserIdentities = new HashMap<String, UserIdentity>();
+ protected List<UserListener> _listeners;
/**
* Get the config (as a string)
@@ -186,27 +185,7 @@ public class PropertyUserStore extends AbstractLifeCycle implements PathWatcher.
this.hotReload = enable;
}
- /* ------------------------------------------------------------ */
- /**
- * sets the refresh interval (in seconds)
- * @param sec the refresh interval
- * @deprecated use {@link #setHotReload(boolean)} instead
- */
- @Deprecated
- public void setRefreshInterval(int sec)
- {
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return refresh interval in seconds for how often the properties file should be checked for changes
- * @deprecated use {@link #isHotReload()} instead
- */
- @Deprecated
- public int getRefreshInterval()
- {
- return (hotReload)?1:0;
- }
+
@Override
public String toString()
@@ -221,7 +200,7 @@ public class PropertyUserStore extends AbstractLifeCycle implements PathWatcher.
}
/* ------------------------------------------------------------ */
- private void loadUsers() throws IOException
+ protected void loadUsers() throws IOException
{
if (_configPath == null)
return;
@@ -259,7 +238,7 @@ public class PropertyUserStore extends AbstractLifeCycle implements PathWatcher.
known.add(username);
Credential credential = Credential.getCredential(credentials);
- Principal userPrincipal = new KnownUser(username,credential);
+ Principal userPrincipal = new AbstractLoginService.UserPrincipal(username,credential);
Subject subject = new Subject();
subject.getPrincipals().add(userPrincipal);
subject.getPrivateCredentials().add(credential);
@@ -268,7 +247,7 @@ public class PropertyUserStore extends AbstractLifeCycle implements PathWatcher.
{
for (String role : roleArray)
{
- subject.getPrincipals().add(new RolePrincipal(role));
+ subject.getPrincipals().add(new AbstractLoginService.RolePrincipal(role));
}
}
diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java
index 7da1a9b889..abf0c7ace5 100644
--- a/jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java
+++ b/jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java
@@ -62,7 +62,8 @@ public class AliasedConstraintTest
private static Server server;
private static LocalConnector connector;
private static ConstraintSecurityHandler security;
-
+
+
@BeforeClass
public static void startServer() throws Exception
{
@@ -73,7 +74,8 @@ public class AliasedConstraintTest
ContextHandler context = new ContextHandler();
SessionHandler session = new SessionHandler();
- HashLoginService loginService = new HashLoginService(TEST_REALM);
+ TestLoginService loginService = new TestLoginService(TEST_REALM);
+
loginService.putUser("user0",new Password("password"),new String[] {});
loginService.putUser("user",new Password("password"),new String[] { "user" });
loginService.putUser("user2",new Password("password"),new String[] { "user" });
diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java
index 4a37e6c82c..288bd7df88 100644
--- a/jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java
+++ b/jetty-security/src/test/java/org/eclipse/jetty/security/ConstraintTest.java
@@ -85,7 +85,8 @@ public class ConstraintTest
ContextHandler _context = new ContextHandler();
SessionHandler _session = new SessionHandler();
- HashLoginService _loginService = new HashLoginService(TEST_REALM);
+ TestLoginService _loginService = new TestLoginService(TEST_REALM);
+
_loginService.putUser("user0", new Password("password"), new String[]{});
_loginService.putUser("user",new Password("password"), new String[] {"user"});
_loginService.putUser("user2",new Password("password"), new String[] {"user"});
diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/SpecExampleConstraintTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/SpecExampleConstraintTest.java
index 007d5ed978..004eeab755 100644
--- a/jetty-security/src/test/java/org/eclipse/jetty/security/SpecExampleConstraintTest.java
+++ b/jetty-security/src/test/java/org/eclipse/jetty/security/SpecExampleConstraintTest.java
@@ -69,8 +69,9 @@ public class SpecExampleConstraintTest
ContextHandler _context = new ContextHandler();
_session = new SessionHandler();
- HashLoginService _loginService = new HashLoginService(TEST_REALM);
- _loginService.putUser("fred",new Password("password"));
+ TestLoginService _loginService = new TestLoginService(TEST_REALM);
+
+ _loginService.putUser("fred",new Password("password"), IdentityService.NO_ROLES);
_loginService.putUser("harry",new Password("password"), new String[] {"HOMEOWNER"});
_loginService.putUser("chris",new Password("password"), new String[] {"CONTRACTOR"});
_loginService.putUser("steven", new Password("password"), new String[] {"SALESCLERK"});
diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/TestLoginService.java b/jetty-security/src/test/java/org/eclipse/jetty/security/TestLoginService.java
new file mode 100644
index 0000000000..222fe136e2
--- /dev/null
+++ b/jetty-security/src/test/java/org/eclipse/jetty/security/TestLoginService.java
@@ -0,0 +1,69 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+
+package org.eclipse.jetty.security;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jetty.util.security.Credential;
+
+/**
+ * TestLoginService
+ *
+ *
+ */
+public class TestLoginService extends AbstractLoginService
+{
+ protected Map<String, UserPrincipal> _users = new HashMap<>();
+ protected Map<String, String[]> _roles = new HashMap<>();
+
+
+
+ public TestLoginService(String name)
+ {
+ setName(name);
+ }
+
+ public void putUser (String username, Credential credential, String[] roles)
+ {
+ UserPrincipal userPrincipal = new UserPrincipal(username,credential);
+ _users.put(username, userPrincipal);
+ _roles.put(username, roles);
+ }
+
+ /**
+ * @see org.eclipse.jetty.security.AbstractLoginService#loadRoleInfo(org.eclipse.jetty.security.AbstractLoginService.UserPrincipal)
+ */
+ @Override
+ protected String[] loadRoleInfo(UserPrincipal user)
+ {
+ return _roles.get(user.getName());
+ }
+
+ /**
+ * @see org.eclipse.jetty.security.AbstractLoginService#loadUserInfo(java.lang.String)
+ */
+ @Override
+ protected UserPrincipal loadUserInfo(String username)
+ {
+ return _users.get(username);
+ }
+
+}
diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml
index 744862eb12..1572142ecd 100644
--- a/jetty-server/pom.xml
+++ b/jetty-server/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
- <version>9.3.7-SNAPSHOT</version>
+ <version>9.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-server</artifactId>
diff --git a/jetty-server/src/main/config/etc/jetty-http-forwarded.xml b/jetty-server/src/main/config/etc/jetty-http-forwarded.xml
new file mode 100644
index 0000000000..0aacbb2468
--- /dev/null
+++ b/jetty-server/src/main/config/etc/jetty-http-forwarded.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
+<Configure id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
+ <Call name="addCustomizer">
+ <Arg>
+ <New class="org.eclipse.jetty.server.ForwardedRequestCustomizer">
+ <Set name="forwardedHostHeader"><Property name="jetty.httpConfig.forwardedHostHeader" default="X-Forwarded-Host"/></Set>
+ <Set name="forwardedServerHeader"><Property name="jetty.httpConfig.forwardedServerHeader" default="X-Forwarded-Server"/></Set>
+ <Set name="forwardedProtoHeader"><Property name="jetty.httpConfig.forwardedProtoHeader" default="X-Forwarded-Proto"/></Set>
+ <Set name="forwardedForHeader"><Property name="jetty.httpConfig.forwardedForHeader" default="X-Forwarded-For"/></Set>
+ <Set name="forwardedSslSessionIdHeader"><Property name="jetty.httpConfig.forwardedSslSessionIdHeader" /></Set>
+ <Set name="forwardedCipherSuiteHeader"><Property name="jetty.httpConfig.forwardedCipherSuiteHeader" /></Set>
+ </New>
+ </Arg>
+ </Call>
+</Configure>
+
diff --git a/jetty-server/src/main/config/etc/jetty.xml b/jetty-server/src/main/config/etc/jetty.xml
index 5412979cac..8e6d1a4ae5 100644
--- a/jetty-server/src/main/config/etc/jetty.xml
+++ b/jetty-server/src/main/config/etc/jetty.xml
@@ -89,11 +89,6 @@
<Set name="delayDispatchUntilContent"><Property name="jetty.httpConfig.delayDispatchUntilContent" deprecated="jetty.delayDispatchUntilContent" default="true"/></Set>
<Set name="maxErrorDispatches"><Property name="jetty.httpConfig.maxErrorDispatches" default="10"/></Set>
<Set name="blockingTimeout"><Property name="jetty.httpConfig.blockingTimeout" default="-1"/></Set>
- <!-- Uncomment to enable handling of X-Forwarded- style headers
- <Call name="addCustomizer">
- <Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
- </Call>
- -->
</New>
<!-- =========================================================== -->
diff --git a/jetty-server/src/main/config/modules/continuation.mod b/jetty-server/src/main/config/modules/continuation.mod
index 231c09d0f3..af03ae41ce 100644
--- a/jetty-server/src/main/config/modules/continuation.mod
+++ b/jetty-server/src/main/config/modules/continuation.mod
@@ -1,6 +1,7 @@
-#
-# Classic Jetty Continuation Support Module
-#
+[description]
+Enables support for Continuation style asynchronous
+Servlets. Now deprecated in favour of Servlet 3.1
+API
[lib]
lib/jetty-continuation-${jetty.version}.jar
diff --git a/jetty-server/src/main/config/modules/debug.mod b/jetty-server/src/main/config/modules/debug.mod
index 0141699461..7b75ecc0e7 100644
--- a/jetty-server/src/main/config/modules/debug.mod
+++ b/jetty-server/src/main/config/modules/debug.mod
@@ -1,6 +1,7 @@
-#
-# Debug module
-#
+[description]
+Enables the DebugListener to generate additional
+logging regarding detailed request handling events.
+Renames threads to include request URI.
[depend]
deploy
diff --git a/jetty-server/src/main/config/modules/debuglog.mod b/jetty-server/src/main/config/modules/debuglog.mod
index ba8b60a727..a76f728a5b 100644
--- a/jetty-server/src/main/config/modules/debuglog.mod
+++ b/jetty-server/src/main/config/modules/debuglog.mod
@@ -1,6 +1,6 @@
-#
-# Debug module
-#
+[description]
+Deprecated Debug Log using the DebugHandle.
+Replaced with the debug module.
[depend]
server
diff --git a/jetty-server/src/main/config/modules/ext.mod b/jetty-server/src/main/config/modules/ext.mod
index 56b10f7ea4..4171f8dfc2 100644
--- a/jetty-server/src/main/config/modules/ext.mod
+++ b/jetty-server/src/main/config/modules/ext.mod
@@ -1,6 +1,6 @@
-#
-# Module to add all lib/ext/**.jar files to classpath
-#
+[description]
+Adds all jar files discovered in $JETTY_HOME/lib/ext
+and $JETTY_BASE/lib/ext to the servers classpath.
[lib]
lib/ext/**.jar
diff --git a/jetty-server/src/main/config/modules/gzip.mod b/jetty-server/src/main/config/modules/gzip.mod
index 1efc834648..65663a1606 100644
--- a/jetty-server/src/main/config/modules/gzip.mod
+++ b/jetty-server/src/main/config/modules/gzip.mod
@@ -1,7 +1,6 @@
-#
-# GZIP module
-# Applies GzipHandler to entire server
-#
+[description]
+Enable GzipHandler for dynamic gzip compression
+for the entire server.
[depend]
server
diff --git a/jetty-server/src/main/config/modules/home-base-warning.mod b/jetty-server/src/main/config/modules/home-base-warning.mod
index 28e5757e81..3e599f0788 100644
--- a/jetty-server/src/main/config/modules/home-base-warning.mod
+++ b/jetty-server/src/main/config/modules/home-base-warning.mod
@@ -1,6 +1,6 @@
-#
-# Home and Base Warning
-#
+[description]
+Generates a warning that server has been run from $JETTY_HOME
+rather than from a $JETTY_BASE.
[xml]
etc/home-base-warning.xml
diff --git a/jetty-server/src/main/config/modules/http-forwarded.mod b/jetty-server/src/main/config/modules/http-forwarded.mod
new file mode 100644
index 0000000000..60f10da736
--- /dev/null
+++ b/jetty-server/src/main/config/modules/http-forwarded.mod
@@ -0,0 +1,20 @@
+[description]
+Adds a forwarded request customizer to the HTTP Connector
+to process forwarded-for style headers from a proxy.
+
+[depend]
+http
+
+[xml]
+etc/jetty-http-forwarded.xml
+
+[ini-template]
+### ForwardedRequestCustomizer Configuration
+
+# jetty.httpConfig.forwardedHostHeader=X-Forwarded-Host
+# jetty.httpConfig.forwardedServerHeader=X-Forwarded-Server
+# jetty.httpConfig.forwardedProtoHeader=X-Forwarded-Proto
+# jetty.httpConfig.forwardedForHeader=X-Forwarded-For
+# jetty.httpConfig.forwardedSslSessionIdHeader=
+# jetty.httpConfig.forwardedCipherSuiteHeader=
+
diff --git a/jetty-server/src/main/config/modules/http.mod b/jetty-server/src/main/config/modules/http.mod
index 01e986243e..c59ee4b4d9 100644
--- a/jetty-server/src/main/config/modules/http.mod
+++ b/jetty-server/src/main/config/modules/http.mod
@@ -1,6 +1,7 @@
-#
-# Jetty HTTP Connector
-#
+[description]
+Enables a HTTP connector on the server.
+By default HTTP/1 is support, but HTTP2C can
+be added to the connector with the http2c module.
[depend]
server
diff --git a/jetty-server/src/main/config/modules/https.mod b/jetty-server/src/main/config/modules/https.mod
index 092e0d70c7..6ffbd69d0c 100644
--- a/jetty-server/src/main/config/modules/https.mod
+++ b/jetty-server/src/main/config/modules/https.mod
@@ -1,12 +1,12 @@
-#
-# Jetty HTTPS Connector
-#
+[description]
+Adds HTTPS protocol support to the TLS(SSL) Connector
[depend]
ssl
[optional]
http2
+http-forwarded
[xml]
etc/jetty-https.xml
diff --git a/jetty-server/src/main/config/modules/ipaccess.mod b/jetty-server/src/main/config/modules/ipaccess.mod
index 956ea0f2e3..68f04dfc57 100644
--- a/jetty-server/src/main/config/modules/ipaccess.mod
+++ b/jetty-server/src/main/config/modules/ipaccess.mod
@@ -1,6 +1,6 @@
-#
-# IPAccess module
-#
+[description]
+Enable the ipaccess handler to apply a white/black list
+control of the remote IP of requests.
[depend]
server
diff --git a/jetty-server/src/main/config/modules/jdbc-sessions.mod b/jetty-server/src/main/config/modules/jdbc-sessions.mod
index d77ff043e2..9fe2beba15 100644
--- a/jetty-server/src/main/config/modules/jdbc-sessions.mod
+++ b/jetty-server/src/main/config/modules/jdbc-sessions.mod
@@ -1,6 +1,5 @@
-#
-# Jetty JDBC Session module
-#
+[description]
+Enables JDBC Session management.
[depend]
annotations
@@ -9,7 +8,6 @@ webapp
[xml]
etc/jetty-jdbc-sessions.xml
-
[ini-template]
## JDBC Session config
diff --git a/jetty-server/src/main/config/modules/jvm.mod b/jetty-server/src/main/config/modules/jvm.mod
index 195521c57f..296c1b6a2b 100644
--- a/jetty-server/src/main/config/modules/jvm.mod
+++ b/jetty-server/src/main/config/modules/jvm.mod
@@ -1,3 +1,6 @@
+[description]
+A noop module that creates an ini template useful for
+setting JVM arguments (eg -Xmx )
[ini-template]
## JVM Configuration
## If JVM args are include in an ini file then --exec is needed
diff --git a/jetty-server/src/main/config/modules/lowresources.mod b/jetty-server/src/main/config/modules/lowresources.mod
index 2f765d9af2..257829afd8 100644
--- a/jetty-server/src/main/config/modules/lowresources.mod
+++ b/jetty-server/src/main/config/modules/lowresources.mod
@@ -1,6 +1,7 @@
-#
-# Low Resources module
-#
+[description]
+Enables a low resource monitor on the server
+that can take actions if threads and/or connections
+cross configured threshholds.
[depend]
server
diff --git a/jetty-server/src/main/config/modules/proxy-protocol-ssl.mod b/jetty-server/src/main/config/modules/proxy-protocol-ssl.mod
index 764d24b847..374763d0b5 100644
--- a/jetty-server/src/main/config/modules/proxy-protocol-ssl.mod
+++ b/jetty-server/src/main/config/modules/proxy-protocol-ssl.mod
@@ -1,6 +1,9 @@
-#
-# PROXY Protocol Module - SSL
-#
+[description]
+Enables the Proxy Protocol on the TLS(SSL) Connector.
+http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt
+This allows a Proxy operating in TCP mode to transport
+details of the proxied connection to the server.
+Both V1 and V2 versions of the protocol are supported.
[depend]
ssl
diff --git a/jetty-server/src/main/config/modules/proxy-protocol.mod b/jetty-server/src/main/config/modules/proxy-protocol.mod
index 9df2700f4e..48820e5c14 100644
--- a/jetty-server/src/main/config/modules/proxy-protocol.mod
+++ b/jetty-server/src/main/config/modules/proxy-protocol.mod
@@ -1,6 +1,10 @@
-#
-# PROXY Protocol Module - HTTP
-#
+[description]
+Enables the Proxy Protocol on the HTTP Connector.
+http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt
+This allows a proxy operating in TCP mode to
+transport details of the proxied connection to
+the server.
+Both V1 and V2 versions of the protocol are supported.
[depend]
http
diff --git a/jetty-server/src/main/config/modules/requestlog.mod b/jetty-server/src/main/config/modules/requestlog.mod
index e27b246ea2..c849f65f31 100644
--- a/jetty-server/src/main/config/modules/requestlog.mod
+++ b/jetty-server/src/main/config/modules/requestlog.mod
@@ -1,6 +1,5 @@
-#
-# Request Log module
-#
+[description]
+Enables a NCSA style request log.
[depend]
server
diff --git a/jetty-server/src/main/config/modules/resources.mod b/jetty-server/src/main/config/modules/resources.mod
index 8647d81325..5648948640 100644
--- a/jetty-server/src/main/config/modules/resources.mod
+++ b/jetty-server/src/main/config/modules/resources.mod
@@ -1,6 +1,7 @@
-#
-# Module to add resources directory to classpath
-#
+[description]
+Adds the $JETTY_HOME/resources and/or $JETTY_BASE/resources
+directory to the server classpath. Useful for configuration
+property files (eg jetty-logging.properties)
[lib]
resources/
diff --git a/jetty-server/src/main/config/modules/server.mod b/jetty-server/src/main/config/modules/server.mod
index 14d6b58e88..19e21c56fe 100644
--- a/jetty-server/src/main/config/modules/server.mod
+++ b/jetty-server/src/main/config/modules/server.mod
@@ -1,6 +1,5 @@
-#
-# Base Server Module
-#
+[description]
+Enables the core Jetty server on the classpath.
[optional]
jvm
diff --git a/jetty-server/src/main/config/modules/ssl.mod b/jetty-server/src/main/config/modules/ssl.mod
index 292780a1cb..acc8d380c9 100644
--- a/jetty-server/src/main/config/modules/ssl.mod
+++ b/jetty-server/src/main/config/modules/ssl.mod
@@ -1,6 +1,7 @@
-#
-# SSL Keystore module
-#
+[description]
+Enables a TLS(SSL) Connector on the server.
+This may be used for HTTPS and/or HTTP2 by enabling
+the associated support modules.
[name]
ssl
diff --git a/jetty-server/src/main/config/modules/stats.mod b/jetty-server/src/main/config/modules/stats.mod
index 0922469cdf..838d54a904 100644
--- a/jetty-server/src/main/config/modules/stats.mod
+++ b/jetty-server/src/main/config/modules/stats.mod
@@ -1,6 +1,6 @@
-#
-# Stats module
-#
+[description]
+Enable detailed statistics collection for the server,
+available via JMX.
[depend]
server
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
index bfd8206df9..c46ed08be5 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
@@ -253,9 +253,11 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
@Override
protected void doStart() throws Exception
{
+ if(_defaultProtocol==null)
+ throw new IllegalStateException("No default protocol for "+this);
_defaultConnectionFactory = getConnectionFactory(_defaultProtocol);
if(_defaultConnectionFactory==null)
- throw new IllegalStateException("No protocol factory for default protocol: "+_defaultProtocol);
+ throw new IllegalStateException("No protocol factory for default protocol '"+_defaultProtocol+"' in "+this);
super.doStart();
@@ -298,7 +300,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
// If we have a stop timeout
long stopTimeout = getStopTimeout();
CountDownLatch stopping=_stopping;
- if (stopTimeout > 0 && stopping!=null)
+ if (stopTimeout > 0 && stopping!=null && getAcceptors()>0)
stopping.await(stopTimeout,TimeUnit.MILLISECONDS);
_stopping=null;
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java
index ab46bd5217..036b5142ad 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java
@@ -142,7 +142,7 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement
buf.append("] \"");
append(buf,request.getMethod());
buf.append(' ');
- append(buf,request.getHttpURI().toString());
+ append(buf,request.getOriginalURI());
buf.append(' ');
append(buf,request.getProtocol());
buf.append("\" ");
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/DebugListener.java b/jetty-server/src/main/java/org/eclipse/jetty/server/DebugListener.java
index e1f6a3e36b..955a655775 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/DebugListener.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/DebugListener.java
@@ -33,7 +33,6 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandler.Context;
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
index 68798b87a7..1a04bd749a 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
@@ -31,16 +31,15 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.jetty.http.HttpFields;
-import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpURI;
-import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.Attributes;
import org.eclipse.jetty.util.MultiMap;
public class Dispatcher implements RequestDispatcher
{
+ public final static String __ERROR_DISPATCH="org.eclipse.jetty.server.Dispatcher.ERROR";
+
/** Dispatch include attribute names */
public final static String __INCLUDE_PREFIX="javax.servlet.include.";
@@ -76,7 +75,15 @@ public class Dispatcher implements RequestDispatcher
public void error(ServletRequest request, ServletResponse response) throws ServletException, IOException
{
- forward(request, response, DispatcherType.ERROR);
+ try
+ {
+ request.setAttribute(__ERROR_DISPATCH,Boolean.TRUE);
+ forward(request, response, DispatcherType.ERROR);
+ }
+ finally
+ {
+ request.setAttribute(__ERROR_DISPATCH,null);
+ }
}
@Override
@@ -129,7 +136,7 @@ public class Dispatcher implements RequestDispatcher
protected void forward(ServletRequest request, ServletResponse response, DispatcherType dispatch) throws ServletException, IOException
{
- Request baseRequest=Request.getBaseRequest(request);
+ Request baseRequest=Request.getBaseRequest(request);
Response base_response=baseRequest.getResponse();
base_response.resetForForward();
@@ -137,21 +144,18 @@ public class Dispatcher implements RequestDispatcher
request = new ServletRequestHttpWrapper(request);
if (!(response instanceof HttpServletResponse))
response = new ServletResponseHttpWrapper(response);
-
- final boolean old_handled=baseRequest.isHandled();
-
+
final HttpURI old_uri=baseRequest.getHttpURI();
final String old_context_path=baseRequest.getContextPath();
final String old_servlet_path=baseRequest.getServletPath();
final String old_path_info=baseRequest.getPathInfo();
-
+
final MultiMap<String> old_query_params=baseRequest.getQueryParameters();
final Attributes old_attr=baseRequest.getAttributes();
final DispatcherType old_type=baseRequest.getDispatcherType();
try
{
- baseRequest.setHandled(false);
baseRequest.setDispatcherType(dispatch);
if (_named!=null)
@@ -182,18 +186,18 @@ public class Dispatcher implements RequestDispatcher
attr._contextPath=old_context_path;
attr._servletPath=old_servlet_path;
}
-
+
HttpURI uri = new HttpURI(old_uri.getScheme(),old_uri.getHost(),old_uri.getPort(),
_uri.getPath(),_uri.getParam(),_uri.getQuery(),_uri.getFragment());
-
+
baseRequest.setHttpURI(uri);
-
+
baseRequest.setContextPath(_contextHandler.getContextPath());
baseRequest.setServletPath(null);
baseRequest.setPathInfo(_pathInContext);
if (_uri.getQuery()!=null || old_uri.getQuery()!=null)
baseRequest.mergeQueryParameters(old_uri.getQuery(),_uri.getQuery(), true);
-
+
baseRequest.setAttributes(attr);
_contextHandler.handle(_pathInContext, baseRequest, (HttpServletRequest)request, (HttpServletResponse)response);
@@ -204,7 +208,6 @@ public class Dispatcher implements RequestDispatcher
}
finally
{
- baseRequest.setHandled(old_handled);
baseRequest.setHttpURI(old_uri);
baseRequest.setContextPath(old_context_path);
baseRequest.setServletPath(old_servlet_path);
@@ -215,35 +218,7 @@ public class Dispatcher implements RequestDispatcher
baseRequest.setDispatcherType(old_type);
}
}
-
- /**
- * <p>Pushes a secondary resource identified by this dispatcher.</p>
- *
- * @param request the primary request
- * @deprecated Use {@link Request#getPushBuilder()} instead
- */
- @Deprecated
- public void push(ServletRequest request)
- {
- Request baseRequest = Request.getBaseRequest(request);
- HttpFields fields = new HttpFields(baseRequest.getHttpFields());
-
- String query=baseRequest.getQueryString();
- if (_uri.hasQuery())
- {
- if (query==null)
- query=_uri.getQuery();
- else
- query=query+"&"+_uri.getQuery(); // TODO is this correct semantic?
- }
-
- HttpURI uri = HttpURI.createHttpURI(request.getScheme(),request.getServerName(),request.getServerPort(),_uri.getPath(),baseRequest.getHttpURI().getParam(),query,null);
-
- MetaData.Request push = new MetaData.Request(HttpMethod.GET.asString(),uri,baseRequest.getHttpVersion(),fields);
-
- baseRequest.getHttpChannel().getHttpTransport().push(push);
- }
-
+
@Override
public String toString()
{
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java
index 813ffd06d6..16aba09eec 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ForwardedRequestCustomizer.java
@@ -215,6 +215,7 @@ public class ForwardedRequestCustomizer implements Customizer
{
request.setAttribute("javax.servlet.request.ssl_session_id", ssl_session_id);
request.setScheme(HttpScheme.HTTPS.asString());
+ request.setSecure(true);
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
index 874ae5bb5a..942f12bde6 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
@@ -18,25 +18,24 @@
package org.eclipse.jetty.server;
+import static javax.servlet.RequestDispatcher.ERROR_EXCEPTION;
+import static javax.servlet.RequestDispatcher.ERROR_STATUS_CODE;
+
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.List;
-import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
import javax.servlet.DispatcherType;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.UnavailableException;
-import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.http.BadMessageException;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpGenerator;
import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData;
@@ -44,6 +43,7 @@ import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ChannelEndPoint;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.EofException;
+import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.server.HttpChannelState.Action;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ErrorHandler;
@@ -262,6 +262,8 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
handle();
}
+ AtomicReference<Action> caller = new AtomicReference<>();
+
/**
* @return True if the channel is ready to continue handling (ie it is not suspended)
*/
@@ -333,68 +335,32 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
case ERROR_DISPATCH:
{
- Throwable ex = _state.getAsyncContextEvent().getThrowable();
-
- // Check for error dispatch loops
- Integer loop_detect = (Integer)_request.getAttribute("org.eclipse.jetty.server.ERROR_DISPATCH");
- if (loop_detect==null)
- loop_detect=1;
+ if (_response.isCommitted())
+ {
+ LOG.warn("Error Dispatch already committed");
+ _transport.abort((Throwable)_request.getAttribute(ERROR_EXCEPTION));
+ }
else
- loop_detect=loop_detect+1;
- _request.setAttribute("org.eclipse.jetty.server.ERROR_DISPATCH",loop_detect);
- if (loop_detect > getHttpConfiguration().getMaxErrorDispatches())
{
- LOG.warn("ERROR_DISPATCH loop detected on {} {}",_request,ex);
+ _response.reset();
+ Integer icode = (Integer)_request.getAttribute(ERROR_STATUS_CODE);
+ int code = icode!=null?icode.intValue():HttpStatus.INTERNAL_SERVER_ERROR_500;
+ _response.setStatus(code);
+ _request.setAttribute(ERROR_STATUS_CODE,code);
+ if (icode==null)
+ _request.setAttribute(ERROR_STATUS_CODE,code);
+ _request.setHandled(false);
+ _response.getHttpOutput().reopen();
+
try
{
- _response.sendError(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ _request.setDispatcherType(DispatcherType.ERROR);
+ getServer().handle(this);
}
finally
{
- _state.errorComplete();
+ _request.setDispatcherType(null);
}
- break loop;
- }
-
- _request.setHandled(false);
- _response.resetBuffer();
- _response.getHttpOutput().reopen();
-
-
- String reason;
- if (ex == null || ex instanceof TimeoutException)
- {
- reason = "Async Timeout";
- }
- else
- {
- reason = HttpStatus.Code.INTERNAL_SERVER_ERROR.getMessage();
- _request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, ex);
- }
-
- _request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE, 500);
- _request.setAttribute(RequestDispatcher.ERROR_MESSAGE, reason);
- _request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI, _request.getRequestURI());
-
- _response.setStatusWithReason(HttpStatus.INTERNAL_SERVER_ERROR_500, reason);
-
- ErrorHandler eh = ErrorHandler.getErrorHandler(getServer(), _state.getContextHandler());
- if (eh instanceof ErrorHandler.ErrorPageMapper)
- {
- String error_page = ((ErrorHandler.ErrorPageMapper)eh).getErrorPage((HttpServletRequest)_state.getAsyncContextEvent().getSuppliedRequest());
- if (error_page != null)
- _state.getAsyncContextEvent().setDispatchPath(error_page);
- }
-
-
- try
- {
- _request.setDispatcherType(DispatcherType.ERROR);
- getServer().handleAsync(this);
- }
- finally
- {
- _request.setDispatcherType(null);
}
break;
}
@@ -419,24 +385,14 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
break;
}
- case ASYNC_ERROR:
- {
- _state.onError();
- break;
- }
-
case COMPLETE:
{
- // TODO do onComplete here for continuations to work
-// _state.onComplete();
-
if (!_response.isCommitted() && !_request.isHandled())
- _response.sendError(404);
+ _response.sendError(HttpStatus.NOT_FOUND_404);
else
_response.closeOutput();
_request.setHandled(true);
- // TODO do onComplete here to detect errors in final flush
_state.onComplete();
onCompleted();
@@ -450,26 +406,12 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
}
}
}
- catch (EofException|QuietServletException|BadMessageException e)
- {
- if (LOG.isDebugEnabled())
- LOG.debug(e);
- handleException(e);
- }
- catch (Throwable e)
- {
- if ("ContinuationThrowable".equals(e.getClass().getSimpleName()))
- {
- LOG.ignore(e);
- }
+ catch (Throwable failure)
+ {
+ if ("org.eclipse.jetty.continuation.ContinuationThrowable".equals(failure.getClass().getName()))
+ LOG.ignore(failure);
else
- {
- if (_connector.isStarted())
- LOG.warn(String.valueOf(_request.getHttpURI()), e);
- else
- LOG.debug(String.valueOf(_request.getHttpURI()), e);
- handleException(e);
- }
+ handleException(failure);
}
action = _state.unhandle();
@@ -482,6 +424,23 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
return !suspended;
}
+ protected void sendError(int code, String reason)
+ {
+ try
+ {
+ _response.sendError(code, reason);
+ }
+ catch (Throwable x)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Could not send error " + code + " " + reason, x);
+ }
+ finally
+ {
+ _state.errorComplete();
+ }
+ }
+
/**
* <p>Sends an error 500, performing a special logic to detect whether the request is suspended,
* to avoid concurrent writes from the application.</p>
@@ -489,69 +448,61 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
* spawned thread writes the response content; in such case, we attempt to commit the error directly
* bypassing the {@link ErrorHandler} mechanisms and the response OutputStream.</p>
*
- * @param x the Throwable that caused the problem
+ * @param failure the Throwable that caused the problem
*/
- protected void handleException(Throwable x)
+ protected void handleException(Throwable failure)
{
- if (_state.isAsyncStarted())
+ // Unwrap wrapping Jetty exceptions.
+ if (failure instanceof RuntimeIOException)
+ failure = failure.getCause();
+
+ if (failure instanceof QuietServletException || !getServer().isRunning())
{
- // Handle exception via AsyncListener onError
- Throwable root = _state.getAsyncContextEvent().getThrowable();
- if (root==null)
- {
- _state.error(x);
- }
+ if (LOG.isDebugEnabled())
+ LOG.debug(_request.getRequestURI(), failure);
+ }
+ else if (failure instanceof BadMessageException)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.warn(_request.getRequestURI(), failure);
else
- {
- // TODO Can this happen? Should this just be ISE???
- // We've already processed an error before!
- root.addSuppressed(x);
- LOG.warn("Error while handling async error: ", root);
- abort(x);
- _state.errorComplete();
- }
+ LOG.warn("{} {}",_request.getRequestURI(), failure.getMessage());
}
else
{
+ LOG.info(_request.getRequestURI(), failure);
+ }
+
+ try
+ {
try
{
- // Handle error normally
- _request.setHandled(true);
- _request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
- _request.setAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE, x.getClass());
-
- if (isCommitted())
+ _state.onError(failure);
+ }
+ catch (Exception e)
+ {
+ LOG.warn(e);
+ // Error could not be handled, probably due to error thrown from error dispatch
+ if (_response.isCommitted())
{
- abort(x);
- if (LOG.isDebugEnabled())
- LOG.debug("Could not send response error 500, already committed", x);
+ LOG.warn("ERROR Dispatch failed: ",failure);
+ _transport.abort(failure);
}
else
{
- _response.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
-
- if (x instanceof BadMessageException)
- {
- BadMessageException bme = (BadMessageException)x;
- _response.sendError(bme.getCode(), bme.getReason());
- }
- else if (x instanceof UnavailableException)
- {
- if (((UnavailableException)x).isPermanent())
- _response.sendError(HttpStatus.NOT_FOUND_404);
- else
- _response.sendError(HttpStatus.SERVICE_UNAVAILABLE_503);
- }
- else
- _response.sendError(HttpStatus.INTERNAL_SERVER_ERROR_500);
+ // Minimal response
+ Integer code=(Integer)_request.getAttribute(ERROR_STATUS_CODE);
+ _response.reset();
+ _response.setStatus(code==null?500:code.intValue());
+ _response.flushBuffer();
}
}
- catch (Throwable e)
- {
- abort(e);
- if (LOG.isDebugEnabled())
- LOG.debug("Could not commit response error 500", e);
- }
+ }
+ catch(Exception e)
+ {
+ failure.addSuppressed(e);
+ LOG.warn("ERROR Dispatch failed: ",failure);
+ _transport.abort(failure);
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java
index 8a2b1cb761..2c16602ec4 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java
@@ -18,16 +18,23 @@
package org.eclipse.jetty.server;
+import static javax.servlet.RequestDispatcher.ERROR_EXCEPTION;
+import static javax.servlet.RequestDispatcher.ERROR_MESSAGE;
+import static javax.servlet.RequestDispatcher.ERROR_STATUS_CODE;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicReference;
import javax.servlet.AsyncListener;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletResponse;
+import javax.servlet.UnavailableException;
+import org.eclipse.jetty.http.BadMessageException;
+import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandler.Context;
import org.eclipse.jetty.util.log.Log;
@@ -45,12 +52,13 @@ public class HttpChannelState
private final static long DEFAULT_TIMEOUT=Long.getLong("org.eclipse.jetty.server.HttpChannelState.DEFAULT_TIMEOUT",30000L);
/**
- * The dispatched state of the HttpChannel, used to control the overall lifecycle
+ * The state of the HttpChannel,used to control the overall lifecycle.
*/
public enum State
{
IDLE, // Idle request
DISPATCHED, // Request dispatched to filter/servlet
+ THROWN, // Exception thrown while DISPATCHED
ASYNC_WAIT, // Suspended and waiting
ASYNC_WOKEN, // Dispatch to handle from ASYNC_WAIT
ASYNC_IO, // Dispatched for async IO
@@ -67,7 +75,6 @@ public class HttpChannelState
DISPATCH, // handle a normal request dispatch
ASYNC_DISPATCH, // handle an async request dispatch
ERROR_DISPATCH, // handle a normal error
- ASYNC_ERROR, // handle an async error
WRITE_CALLBACK, // handle an IO write callback
READ_CALLBACK, // handle an IO read callback
COMPLETE, // Complete the response
@@ -76,14 +83,12 @@ public class HttpChannelState
}
/**
- * The state of the servlet async API. This can lead or follow the
- * channel dispatch state and also includes reasons such as expired,
- * dispatched or completed.
+ * The state of the servlet async API.
*/
public enum Async
{
STARTED, // AsyncContext.startAsync() has been called
- DISPATCH, //
+ DISPATCH, // AsyncContext.dispatch() has been called
COMPLETE, // AsyncContext.complete() has been called
EXPIRING, // AsyncContext timeout just happened
EXPIRED, // AsyncContext timeout has been processed
@@ -160,12 +165,18 @@ public class HttpChannelState
{
try(Locker.Lock lock= _locker.lock())
{
- return String.format("%s@%x{s=%s a=%s i=%b r=%s w=%b}",getClass().getSimpleName(),hashCode(),_state,_async,_initial,
- _asyncReadPossible?(_asyncReadUnready?"PU":"P!U"):(_asyncReadUnready?"!PU":"!P!U"),
- _asyncWrite);
+ return toStringLocked();
}
}
+ public String toStringLocked()
+ {
+ return String.format("%s@%x{s=%s a=%s i=%b r=%s w=%b}",getClass().getSimpleName(),hashCode(),_state,_async,_initial,
+ _asyncReadPossible?(_asyncReadUnready?"PU":"P!U"):(_asyncReadUnready?"!PU":"!P!U"),
+ _asyncWrite);
+ }
+
+
private String getStatusStringLocked()
{
return String.format("s=%s i=%b a=%s",_state,_initial,_async);
@@ -184,10 +195,11 @@ public class HttpChannelState
*/
protected Action handling()
{
- if(DEBUG)
- LOG.debug("{} handling {}",this,_state);
try(Locker.Lock lock= _locker.lock())
{
+ if(DEBUG)
+ LOG.debug("handling {}",toStringLocked());
+
switch(_state)
{
case IDLE:
@@ -228,17 +240,15 @@ public class HttpChannelState
_state=State.DISPATCHED;
_async=null;
return Action.ASYNC_DISPATCH;
- case EXPIRING:
- break;
case EXPIRED:
+ case ERRORED:
_state=State.DISPATCHED;
_async=null;
return Action.ERROR_DISPATCH;
case STARTED:
- return Action.WAIT;
+ case EXPIRING:
case ERRORING:
- _state=State.DISPATCHED;
- return Action.ASYNC_ERROR;
+ return Action.WAIT;
default:
throw new IllegalStateException(getStatusStringLocked());
@@ -264,6 +274,9 @@ public class HttpChannelState
try(Locker.Lock lock= _locker.lock())
{
+ if(DEBUG)
+ LOG.debug("startAsync {}",toStringLocked());
+
if (_state!=State.DISPATCHED || _async!=null)
throw new IllegalStateException(this.getStatusStringLocked());
@@ -304,19 +317,10 @@ public class HttpChannelState
}
}
- protected void error(Throwable th)
- {
- try(Locker.Lock lock= _locker.lock())
- {
- if (_event!=null)
- _event.addThrowable(th);
- _async=Async.ERRORING;
- }
- }
/**
* Signal that the HttpConnection has finished handling the request.
- * For blocking connectors, this call may block if the request has
+ * For blocking connectors,this call may block if the request has
* been suspended (startAsync called).
* @return next actions
* be handled again (eg because of a resume that happened before unhandle was called)
@@ -327,17 +331,21 @@ public class HttpChannelState
AsyncContextEvent schedule_event=null;
boolean read_interested=false;
- if(DEBUG)
- LOG.debug("{} unhandle {}",this,_state);
-
try(Locker.Lock lock= _locker.lock())
{
+ if(DEBUG)
+ LOG.debug("unhandle {}",toStringLocked());
+
switch(_state)
{
case COMPLETING:
case COMPLETED:
return Action.TERMINATED;
+ case THROWN:
+ _state=State.DISPATCHED;
+ return Action.ERROR_DISPATCH;
+
case DISPATCHED:
case ASYNC_IO:
break;
@@ -363,12 +371,6 @@ public class HttpChannelState
action=Action.ASYNC_DISPATCH;
break;
- case EXPIRED:
- _state=State.DISPATCHED;
- _async=null;
- action = Action.ERROR_DISPATCH;
- break;
-
case STARTED:
if (_asyncReadUnready && _asyncReadPossible)
{
@@ -392,26 +394,27 @@ public class HttpChannelState
break;
case EXPIRING:
- schedule_event=_event;
+ // onTimeout callbacks still being called, so just WAIT
_state=State.ASYNC_WAIT;
action=Action.WAIT;
break;
- case ERRORING:
+ case EXPIRED:
+ // onTimeout handling is complete, but did not dispatch as
+ // we were handling. So do the error dispatch here
_state=State.DISPATCHED;
- action=Action.ASYNC_ERROR;
+ _async=null;
+ action=Action.ERROR_DISPATCH;
break;
-
+
case ERRORED:
_state=State.DISPATCHED;
- action=Action.ERROR_DISPATCH;
_async=null;
+ action=Action.ERROR_DISPATCH;
break;
default:
- _state=State.COMPLETING;
- action=Action.COMPLETE;
- break;
+ throw new IllegalStateException(this.getStatusStringLocked());
}
}
else
@@ -431,9 +434,12 @@ public class HttpChannelState
public void dispatch(ServletContext context, String path)
{
boolean dispatch=false;
- AsyncContextEvent event=null;
+ AsyncContextEvent event;
try(Locker.Lock lock= _locker.lock())
{
+ if(DEBUG)
+ LOG.debug("dispatch {} -> {}",toStringLocked(),path);
+
boolean started=false;
event=_event;
switch(_async)
@@ -442,6 +448,7 @@ public class HttpChannelState
started=true;
break;
case EXPIRING:
+ case ERRORING:
case ERRORED:
break;
default:
@@ -484,6 +491,9 @@ public class HttpChannelState
AsyncContextEvent event;
try(Locker.Lock lock= _locker.lock())
{
+ if(DEBUG)
+ LOG.debug("onTimeout {}",toStringLocked());
+
if (_async!=Async.STARTED)
return;
_async=Async.EXPIRING;
@@ -492,12 +502,10 @@ public class HttpChannelState
}
- if (LOG.isDebugEnabled())
- LOG.debug("Async timeout {}",this);
-
+ final AtomicReference<Throwable> error=new AtomicReference<Throwable>();
if (listeners!=nu