From 66af591b8c31905d338e5b58043bf3c7503bcdb2 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 7 Sep 2011 17:52:40 -0500 Subject: [PATCH 001/134] Updating VERSION.txt top section --- VERSION.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 09d47000044..c39820c9a06 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,4 +1,13 @@ -jetty-7.5.1-SNAPSHOT +jetty-7.5.1.v20110907 - 07 September 2011 + + 350634 Added Resource.newResource(File) + + 356190 fix monodb tests for changed test api + + 356428 removed timed waits from test + + 356693 reduce visibility to webapp of websocket implementations + + 356695 jetty server jars are provided for websockets + + 356726 Instead of the sessionDestroyed called sessionCreated after + invalidate session + + 356751 Add null protection to ServletContextHandler.doStop + + 356823 correctly decode close codes. Send not utf-8 close code. jetty-7.5.0.v20110901 - 01 September 2011 + 356421 Upgraded websocket to draft 13 support From ce55c8c6016def58c2900e06fb00f52fb3837bac Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 7 Sep 2011 18:12:09 -0500 Subject: [PATCH 002/134] [maven-release-plugin] prepare release jetty-7.5.1.v20110907 --- example-jetty-embedded/pom.xml | 2 +- jetty-aggregate/jetty-all-server/pom.xml | 2 +- jetty-aggregate/jetty-all/pom.xml | 2 +- jetty-aggregate/jetty-client/pom.xml | 2 +- jetty-aggregate/jetty-plus/pom.xml | 2 +- jetty-aggregate/jetty-server/pom.xml | 2 +- jetty-aggregate/jetty-servlet/pom.xml | 2 +- jetty-aggregate/jetty-webapp/pom.xml | 2 +- jetty-aggregate/pom.xml | 2 +- jetty-ajp/pom.xml | 2 +- jetty-annotations/pom.xml | 2 +- jetty-client/pom.xml | 2 +- jetty-continuation/pom.xml | 2 +- jetty-deploy/pom.xml | 2 +- jetty-distribution/pom.xml | 2 +- jetty-http/pom.xml | 2 +- jetty-io/pom.xml | 2 +- jetty-jaspi/pom.xml | 2 +- jetty-jmx/pom.xml | 2 +- jetty-jndi/pom.xml | 2 +- jetty-jsp-2.1/pom.xml | 2 +- jetty-monitor/pom.xml | 2 +- jetty-nested/pom.xml | 2 +- jetty-nosql/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-logback/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot/pom.xml | 2 +- jetty-osgi/jetty-osgi-equinoxtools/pom.xml | 2 +- jetty-osgi/jetty-osgi-httpservice/pom.xml | 2 +- jetty-osgi/pom.xml | 2 +- jetty-osgi/test-jetty-osgi/pom.xml | 2 +- jetty-overlay-deployer/pom.xml | 2 +- jetty-plus/pom.xml | 2 +- jetty-policy/pom.xml | 2 +- jetty-rewrite/pom.xml | 2 +- jetty-security/pom.xml | 2 +- jetty-server/pom.xml | 2 +- jetty-servlet/pom.xml | 2 +- jetty-servlets/pom.xml | 2 +- jetty-start/pom.xml | 2 +- jetty-util/pom.xml | 2 +- jetty-webapp/pom.xml | 2 +- jetty-websocket/pom.xml | 2 +- jetty-xml/pom.xml | 2 +- pom.xml | 2 +- test-continuation-jetty6/pom.xml | 2 +- test-continuation/pom.xml | 2 +- test-jetty-nested/pom.xml | 2 +- test-jetty-servlet/pom.xml | 2 +- test-jetty-webapp/pom.xml | 2 +- tests/pom.xml | 2 +- tests/test-integration/pom.xml | 2 +- tests/test-loginservice/pom.xml | 2 +- tests/test-sessions/pom.xml | 2 +- tests/test-sessions/test-hash-sessions/pom.xml | 2 +- tests/test-sessions/test-jdbc-sessions/pom.xml | 2 +- tests/test-sessions/test-sessions-common/pom.xml | 2 +- tests/test-webapps/pom.xml | 2 +- tests/test-webapps/test-webapp-rfc2616/pom.xml | 2 +- 60 files changed, 60 insertions(+), 60 deletions(-) diff --git a/example-jetty-embedded/pom.xml b/example-jetty-embedded/pom.xml index 1ccafded294..eb2ce72cc29 100644 --- a/example-jetty-embedded/pom.xml +++ b/example-jetty-embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 example-jetty-embedded diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index 0f685d76257..66bbff3042d 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index ffbb59f3130..4bc1f5820d5 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-client/pom.xml b/jetty-aggregate/jetty-client/pom.xml index 695c9dc30e1..00eeabeb670 100644 --- a/jetty-aggregate/jetty-client/pom.xml +++ b/jetty-aggregate/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-plus/pom.xml b/jetty-aggregate/jetty-plus/pom.xml index b03a21d166e..830f33ca176 100644 --- a/jetty-aggregate/jetty-plus/pom.xml +++ b/jetty-aggregate/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-server/pom.xml b/jetty-aggregate/jetty-server/pom.xml index 92dd6814e13..d7c088ad10c 100644 --- a/jetty-aggregate/jetty-server/pom.xml +++ b/jetty-aggregate/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-servlet/pom.xml b/jetty-aggregate/jetty-servlet/pom.xml index e7ccc3091b0..fc4ba72fd36 100644 --- a/jetty-aggregate/jetty-servlet/pom.xml +++ b/jetty-aggregate/jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index 935c9c30c8c..22b85bfbb68 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/pom.xml b/jetty-aggregate/pom.xml index b9e4d48f5d2..908fc3a3a54 100644 --- a/jetty-aggregate/pom.xml +++ b/jetty-aggregate/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 org.eclipse.jetty.aggregate jetty-aggregate-project diff --git a/jetty-ajp/pom.xml b/jetty-ajp/pom.xml index 7580b263ecd..3d0c8d16d0b 100644 --- a/jetty-ajp/pom.xml +++ b/jetty-ajp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-ajp diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index a9beb33f195..cf4c20cc117 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-annotations diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index a9ac913e862..3f92c03b90c 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index bfa68e99b19..305284173ea 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-continuation diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index 246b83b36b5..5cac0902af4 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-deploy diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 435aabc0487..58a924cd0c2 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 jetty-distribution Jetty :: Distribution Assemblies diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index e8f316130e7..cdffb1217e3 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index 8e5ea20cea4..c8f87622699 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index 4897b815aed..db756d6ebf7 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-jaspi diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index 54e471e1801..a923c40e5f1 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-jmx diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index 649a3d287d4..e2405a7d98a 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-jndi diff --git a/jetty-jsp-2.1/pom.xml b/jetty-jsp-2.1/pom.xml index 7be6ce4d4fb..06c0d0ea6aa 100644 --- a/jetty-jsp-2.1/pom.xml +++ b/jetty-jsp-2.1/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-jsp-2.1 diff --git a/jetty-monitor/pom.xml b/jetty-monitor/pom.xml index c0b6794a126..ef7b15af5b0 100644 --- a/jetty-monitor/pom.xml +++ b/jetty-monitor/pom.xml @@ -19,7 +19,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-monitor diff --git a/jetty-nested/pom.xml b/jetty-nested/pom.xml index 523e1bc3a0d..707d831b90d 100644 --- a/jetty-nested/pom.xml +++ b/jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 jetty-nested Jetty :: Nested diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index c62a1e3c793..dd3367db839 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-nosql diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index 677f5ce8a0a..181d7e8b258 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-logback/pom.xml b/jetty-osgi/jetty-osgi-boot-logback/pom.xml index 5999213db8a..9a22ca3c19e 100644 --- a/jetty-osgi/jetty-osgi-boot-logback/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-logback/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index 23a0b8550ad..707d1857a52 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index 7e9de39efe2..2d566db7a96 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml index b474b7ff62c..5e4e712e9e6 100644 --- a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml +++ b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index e8212fe1f67..0248437123a 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 ../pom.xml 4.0.0 diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index ae696607c06..97c7ce9bc24 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 ../pom.xml org.eclipse.jetty.osgi diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 8df9f3823b0..cd8c9030ecb 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 ../pom.xml 4.0.0 diff --git a/jetty-overlay-deployer/pom.xml b/jetty-overlay-deployer/pom.xml index d0347e44f19..3ddd7b96500 100644 --- a/jetty-overlay-deployer/pom.xml +++ b/jetty-overlay-deployer/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-overlay-deployer diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index 38729dcce37..f89d3c901e4 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-plus diff --git a/jetty-policy/pom.xml b/jetty-policy/pom.xml index 18fd8b3d2f3..c51c0477083 100644 --- a/jetty-policy/pom.xml +++ b/jetty-policy/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 org.eclipse.jetty jetty-policy diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index dd0b4bbc429..1cf0c015037 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-rewrite diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index f87a115664e..c2ef8846091 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-security diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index 44d0479a0a1..deffa597f53 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-server diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index e2e4c342532..83a83a4e515 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-servlet diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index f70b03052b9..b336d5f531e 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-servlets diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index 2a72142d1e4..f54e31a93ca 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-start diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index 130cc720dbe..58086e21393 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-util diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index bf5936f5d98..61803152697 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-webapp diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index 28856e3a1bd..da32edb2cab 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index 43de789eba6..5abf703b0df 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 jetty-xml diff --git a/pom.xml b/pom.xml index 4647d86977f..e3a70f3eedf 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 Jetty :: Project ${jetty.url} pom diff --git a/test-continuation-jetty6/pom.xml b/test-continuation-jetty6/pom.xml index 78998bc33c7..dae0ffb089f 100644 --- a/test-continuation-jetty6/pom.xml +++ b/test-continuation-jetty6/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 test-continuation-jetty6 diff --git a/test-continuation/pom.xml b/test-continuation/pom.xml index f5472b090a8..31e1a8b2199 100644 --- a/test-continuation/pom.xml +++ b/test-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 test-continuation diff --git a/test-jetty-nested/pom.xml b/test-jetty-nested/pom.xml index fd26d1ce70c..f75a12ab22c 100644 --- a/test-jetty-nested/pom.xml +++ b/test-jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 test-jetty-nested Jetty :: Nested Test diff --git a/test-jetty-servlet/pom.xml b/test-jetty-servlet/pom.xml index b2b7d132e3d..c91b693ab85 100644 --- a/test-jetty-servlet/pom.xml +++ b/test-jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 test-jetty-servlet diff --git a/test-jetty-webapp/pom.xml b/test-jetty-webapp/pom.xml index 779a7d84943..2e621ca89ac 100644 --- a/test-jetty-webapp/pom.xml +++ b/test-jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 org.eclipse.jetty diff --git a/tests/pom.xml b/tests/pom.xml index a9cdb87fa46..b564c570a7d 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110907 org.eclipse.jetty.tests tests-parent diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index 08d90fb3462..796d5324b33 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -20,7 +20,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110907 4.0.0 test-integration diff --git a/tests/test-loginservice/pom.xml b/tests/test-loginservice/pom.xml index 83a40a8b980..6dc432a640c 100644 --- a/tests/test-loginservice/pom.xml +++ b/tests/test-loginservice/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110907 test-loginservice Jetty Tests :: Login Service diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml index bf9f8455215..dcf181721a6 100644 --- a/tests/test-sessions/pom.xml +++ b/tests/test-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110907 test-sessions-parent Jetty Tests :: Sessions :: Parent diff --git a/tests/test-sessions/test-hash-sessions/pom.xml b/tests/test-sessions/test-hash-sessions/pom.xml index 3b7664027fb..74c5aad81cf 100644 --- a/tests/test-sessions/test-hash-sessions/pom.xml +++ b/tests/test-sessions/test-hash-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110907 test-hash-sessions Jetty Tests :: Sessions :: Hash diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index 7f4c41397e6..9ca06057751 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110907 test-jdbc-sessions Jetty Tests :: Sessions :: JDBC diff --git a/tests/test-sessions/test-sessions-common/pom.xml b/tests/test-sessions/test-sessions-common/pom.xml index 5173618c30c..41bab8e95c1 100644 --- a/tests/test-sessions/test-sessions-common/pom.xml +++ b/tests/test-sessions/test-sessions-common/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110907 test-sessions-common Jetty Tests :: Sessions :: Common diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index aa6d292a3b8..5aa76404842 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110907 test-webapps-parent Jetty Tests :: WebApps :: Parent diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index 0980eae60c5..2c8c3d75769 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-webapps-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110907 test-webapp-rfc2616 Jetty Tests :: WebApp :: RFC2616 From 6b614a54f04a38f9edef1ddc9de85e37fd49f9ff Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 7 Sep 2011 18:12:16 -0500 Subject: [PATCH 003/134] [maven-release-plugin] prepare for next development iteration --- example-jetty-embedded/pom.xml | 2 +- jetty-aggregate/jetty-all-server/pom.xml | 2 +- jetty-aggregate/jetty-all/pom.xml | 2 +- jetty-aggregate/jetty-client/pom.xml | 2 +- jetty-aggregate/jetty-plus/pom.xml | 2 +- jetty-aggregate/jetty-server/pom.xml | 2 +- jetty-aggregate/jetty-servlet/pom.xml | 2 +- jetty-aggregate/jetty-webapp/pom.xml | 2 +- jetty-aggregate/pom.xml | 2 +- jetty-ajp/pom.xml | 2 +- jetty-annotations/pom.xml | 2 +- jetty-client/pom.xml | 2 +- jetty-continuation/pom.xml | 2 +- jetty-deploy/pom.xml | 2 +- jetty-distribution/pom.xml | 2 +- jetty-http/pom.xml | 2 +- jetty-io/pom.xml | 2 +- jetty-jaspi/pom.xml | 2 +- jetty-jmx/pom.xml | 2 +- jetty-jndi/pom.xml | 2 +- jetty-jsp-2.1/pom.xml | 2 +- jetty-monitor/pom.xml | 2 +- jetty-nested/pom.xml | 2 +- jetty-nosql/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-logback/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot/pom.xml | 2 +- jetty-osgi/jetty-osgi-equinoxtools/pom.xml | 2 +- jetty-osgi/jetty-osgi-httpservice/pom.xml | 2 +- jetty-osgi/pom.xml | 2 +- jetty-osgi/test-jetty-osgi/pom.xml | 2 +- jetty-overlay-deployer/pom.xml | 2 +- jetty-plus/pom.xml | 2 +- jetty-policy/pom.xml | 2 +- jetty-rewrite/pom.xml | 2 +- jetty-security/pom.xml | 2 +- jetty-server/pom.xml | 2 +- jetty-servlet/pom.xml | 2 +- jetty-servlets/pom.xml | 2 +- jetty-start/pom.xml | 2 +- jetty-util/pom.xml | 2 +- jetty-webapp/pom.xml | 2 +- jetty-websocket/pom.xml | 2 +- jetty-xml/pom.xml | 2 +- pom.xml | 2 +- test-continuation-jetty6/pom.xml | 2 +- test-continuation/pom.xml | 2 +- test-jetty-nested/pom.xml | 2 +- test-jetty-servlet/pom.xml | 2 +- test-jetty-webapp/pom.xml | 2 +- tests/pom.xml | 2 +- tests/test-integration/pom.xml | 2 +- tests/test-loginservice/pom.xml | 2 +- tests/test-sessions/pom.xml | 2 +- tests/test-sessions/test-hash-sessions/pom.xml | 2 +- tests/test-sessions/test-jdbc-sessions/pom.xml | 2 +- tests/test-sessions/test-sessions-common/pom.xml | 2 +- tests/test-webapps/pom.xml | 2 +- tests/test-webapps/test-webapp-rfc2616/pom.xml | 2 +- 60 files changed, 60 insertions(+), 60 deletions(-) diff --git a/example-jetty-embedded/pom.xml b/example-jetty-embedded/pom.xml index eb2ce72cc29..43a88915769 100644 --- a/example-jetty-embedded/pom.xml +++ b/example-jetty-embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 example-jetty-embedded diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index 66bbff3042d..7e6c16a86e8 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index 4bc1f5820d5..be1cfab7da2 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-client/pom.xml b/jetty-aggregate/jetty-client/pom.xml index 00eeabeb670..aa987775861 100644 --- a/jetty-aggregate/jetty-client/pom.xml +++ b/jetty-aggregate/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-plus/pom.xml b/jetty-aggregate/jetty-plus/pom.xml index 830f33ca176..b42b44a4725 100644 --- a/jetty-aggregate/jetty-plus/pom.xml +++ b/jetty-aggregate/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-server/pom.xml b/jetty-aggregate/jetty-server/pom.xml index d7c088ad10c..bf5c6d4fb02 100644 --- a/jetty-aggregate/jetty-server/pom.xml +++ b/jetty-aggregate/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-servlet/pom.xml b/jetty-aggregate/jetty-servlet/pom.xml index fc4ba72fd36..066c8733d8b 100644 --- a/jetty-aggregate/jetty-servlet/pom.xml +++ b/jetty-aggregate/jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index 22b85bfbb68..9413b7d44df 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/pom.xml b/jetty-aggregate/pom.xml index 908fc3a3a54..57046ec5725 100644 --- a/jetty-aggregate/pom.xml +++ b/jetty-aggregate/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT org.eclipse.jetty.aggregate jetty-aggregate-project diff --git a/jetty-ajp/pom.xml b/jetty-ajp/pom.xml index 3d0c8d16d0b..ae866a9d0b7 100644 --- a/jetty-ajp/pom.xml +++ b/jetty-ajp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-ajp diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index cf4c20cc117..92d1a530c29 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-annotations diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index 3f92c03b90c..a4b2982c9d3 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index 305284173ea..f3d5f2a3256 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-continuation diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index 5cac0902af4..5d2e2b8a2ae 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-deploy diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 58a924cd0c2..6f8abcd6cb5 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT jetty-distribution Jetty :: Distribution Assemblies diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index cdffb1217e3..e73ef910bff 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index c8f87622699..f009450a3a8 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index db756d6ebf7..f08550b68d3 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-jaspi diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index a923c40e5f1..304a7120fa1 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-jmx diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index e2405a7d98a..31420e2e5ce 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-jndi diff --git a/jetty-jsp-2.1/pom.xml b/jetty-jsp-2.1/pom.xml index 06c0d0ea6aa..ca42f774f54 100644 --- a/jetty-jsp-2.1/pom.xml +++ b/jetty-jsp-2.1/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-jsp-2.1 diff --git a/jetty-monitor/pom.xml b/jetty-monitor/pom.xml index ef7b15af5b0..584213da673 100644 --- a/jetty-monitor/pom.xml +++ b/jetty-monitor/pom.xml @@ -19,7 +19,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-monitor diff --git a/jetty-nested/pom.xml b/jetty-nested/pom.xml index 707d831b90d..6c0a5f0b2c9 100644 --- a/jetty-nested/pom.xml +++ b/jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT jetty-nested Jetty :: Nested diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index dd3367db839..80e4650a125 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-nosql diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index 181d7e8b258..f2dbf3ccdb9 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-logback/pom.xml b/jetty-osgi/jetty-osgi-boot-logback/pom.xml index 9a22ca3c19e..35c52da69af 100644 --- a/jetty-osgi/jetty-osgi-boot-logback/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-logback/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index 707d1857a52..e8bee79d3f5 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index 2d566db7a96..bf836058343 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml index 5e4e712e9e6..075e0e811f1 100644 --- a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml +++ b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index 0248437123a..77b5a62df4d 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index 97c7ce9bc24..d257ef8bd4e 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT ../pom.xml org.eclipse.jetty.osgi diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index cd8c9030ecb..7d64e1fac9b 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-overlay-deployer/pom.xml b/jetty-overlay-deployer/pom.xml index 3ddd7b96500..0be54212822 100644 --- a/jetty-overlay-deployer/pom.xml +++ b/jetty-overlay-deployer/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-overlay-deployer diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index f89d3c901e4..2e8be6ca72d 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-plus diff --git a/jetty-policy/pom.xml b/jetty-policy/pom.xml index c51c0477083..52ed445f169 100644 --- a/jetty-policy/pom.xml +++ b/jetty-policy/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT org.eclipse.jetty jetty-policy diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index 1cf0c015037..a08b6edc75d 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-rewrite diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index c2ef8846091..2cdd1fad3a1 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-security diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index deffa597f53..13f653d8f21 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-server diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index 83a83a4e515..c6bcd38f54b 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-servlet diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index b336d5f531e..c6bb0a28b87 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-servlets diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index f54e31a93ca..5137dc15650 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-start diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index 58086e21393..bfb2d4c2295 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-util diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index 61803152697..38b7636cce7 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-webapp diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index da32edb2cab..7f3e2cedc84 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index 5abf703b0df..34102277dd1 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 jetty-xml diff --git a/pom.xml b/pom.xml index e3a70f3eedf..82675bfea23 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT Jetty :: Project ${jetty.url} pom diff --git a/test-continuation-jetty6/pom.xml b/test-continuation-jetty6/pom.xml index dae0ffb089f..15baaa4b0f1 100644 --- a/test-continuation-jetty6/pom.xml +++ b/test-continuation-jetty6/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 test-continuation-jetty6 diff --git a/test-continuation/pom.xml b/test-continuation/pom.xml index 31e1a8b2199..60e86df9a01 100644 --- a/test-continuation/pom.xml +++ b/test-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 test-continuation diff --git a/test-jetty-nested/pom.xml b/test-jetty-nested/pom.xml index f75a12ab22c..cc2b6aeeefe 100644 --- a/test-jetty-nested/pom.xml +++ b/test-jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT test-jetty-nested Jetty :: Nested Test diff --git a/test-jetty-servlet/pom.xml b/test-jetty-servlet/pom.xml index c91b693ab85..7f7117e8fcc 100644 --- a/test-jetty-servlet/pom.xml +++ b/test-jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 test-jetty-servlet diff --git a/test-jetty-webapp/pom.xml b/test-jetty-webapp/pom.xml index 2e621ca89ac..7cacb8acec7 100644 --- a/test-jetty-webapp/pom.xml +++ b/test-jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/tests/pom.xml b/tests/pom.xml index b564c570a7d..1216cd35407 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110907 + 7.5.2-SNAPSHOT org.eclipse.jetty.tests tests-parent diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index 796d5324b33..c691ebdbdc3 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -20,7 +20,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1.v20110907 + 7.5.2-SNAPSHOT 4.0.0 test-integration diff --git a/tests/test-loginservice/pom.xml b/tests/test-loginservice/pom.xml index 6dc432a640c..857235f27e7 100644 --- a/tests/test-loginservice/pom.xml +++ b/tests/test-loginservice/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1.v20110907 + 7.5.2-SNAPSHOT test-loginservice Jetty Tests :: Login Service diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml index dcf181721a6..d3c4048480d 100644 --- a/tests/test-sessions/pom.xml +++ b/tests/test-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1.v20110907 + 7.5.2-SNAPSHOT test-sessions-parent Jetty Tests :: Sessions :: Parent diff --git a/tests/test-sessions/test-hash-sessions/pom.xml b/tests/test-sessions/test-hash-sessions/pom.xml index 74c5aad81cf..a455bc9b8d9 100644 --- a/tests/test-sessions/test-hash-sessions/pom.xml +++ b/tests/test-sessions/test-hash-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1.v20110907 + 7.5.2-SNAPSHOT test-hash-sessions Jetty Tests :: Sessions :: Hash diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index 9ca06057751..6aee00cdced 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1.v20110907 + 7.5.2-SNAPSHOT test-jdbc-sessions Jetty Tests :: Sessions :: JDBC diff --git a/tests/test-sessions/test-sessions-common/pom.xml b/tests/test-sessions/test-sessions-common/pom.xml index 41bab8e95c1..a04f775a610 100644 --- a/tests/test-sessions/test-sessions-common/pom.xml +++ b/tests/test-sessions/test-sessions-common/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1.v20110907 + 7.5.2-SNAPSHOT test-sessions-common Jetty Tests :: Sessions :: Common diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index 5aa76404842..095c1eaa062 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1.v20110907 + 7.5.2-SNAPSHOT test-webapps-parent Jetty Tests :: WebApps :: Parent diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index 2c8c3d75769..e4d1d99f049 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-webapps-parent - 7.5.1.v20110907 + 7.5.2-SNAPSHOT test-webapp-rfc2616 Jetty Tests :: WebApp :: RFC2616 From 37d0f53b0a3bd29f5997c9c1502724791dddae47 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 8 Sep 2011 11:40:37 -0500 Subject: [PATCH 004/134] updating version.txt and resetting pom versions to 7.5.1-SNAPSHOT --- VERSION.txt | 3 ++- example-jetty-embedded/pom.xml | 2 +- jetty-aggregate/jetty-all-server/pom.xml | 2 +- jetty-aggregate/jetty-all/pom.xml | 2 +- jetty-aggregate/jetty-client/pom.xml | 2 +- jetty-aggregate/jetty-plus/pom.xml | 2 +- jetty-aggregate/jetty-server/pom.xml | 2 +- jetty-aggregate/jetty-servlet/pom.xml | 2 +- jetty-aggregate/jetty-webapp/pom.xml | 2 +- jetty-aggregate/pom.xml | 2 +- jetty-ajp/pom.xml | 2 +- jetty-annotations/pom.xml | 2 +- jetty-client/pom.xml | 2 +- jetty-continuation/pom.xml | 2 +- jetty-deploy/pom.xml | 2 +- jetty-distribution/pom.xml | 2 +- jetty-http/pom.xml | 2 +- jetty-io/pom.xml | 2 +- jetty-jaspi/pom.xml | 2 +- jetty-jmx/pom.xml | 2 +- jetty-jndi/pom.xml | 2 +- jetty-jsp-2.1/pom.xml | 2 +- jetty-monitor/pom.xml | 2 +- jetty-nested/pom.xml | 2 +- jetty-nosql/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-logback/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot/pom.xml | 2 +- jetty-osgi/jetty-osgi-equinoxtools/pom.xml | 2 +- jetty-osgi/jetty-osgi-httpservice/pom.xml | 2 +- jetty-osgi/pom.xml | 2 +- jetty-osgi/test-jetty-osgi/pom.xml | 2 +- jetty-overlay-deployer/pom.xml | 2 +- jetty-plus/pom.xml | 2 +- jetty-policy/pom.xml | 2 +- jetty-rewrite/pom.xml | 2 +- jetty-security/pom.xml | 2 +- jetty-server/pom.xml | 2 +- jetty-servlet/pom.xml | 2 +- jetty-servlets/pom.xml | 2 +- jetty-start/pom.xml | 2 +- jetty-util/pom.xml | 2 +- jetty-webapp/pom.xml | 2 +- jetty-websocket/pom.xml | 2 +- jetty-xml/pom.xml | 2 +- pom.xml | 2 +- test-continuation-jetty6/pom.xml | 2 +- test-continuation/pom.xml | 2 +- test-jetty-nested/pom.xml | 2 +- test-jetty-servlet/pom.xml | 2 +- test-jetty-webapp/pom.xml | 2 +- tests/pom.xml | 2 +- tests/test-integration/pom.xml | 2 +- tests/test-loginservice/pom.xml | 2 +- tests/test-sessions/pom.xml | 2 +- tests/test-sessions/test-hash-sessions/pom.xml | 2 +- tests/test-sessions/test-jdbc-sessions/pom.xml | 2 +- tests/test-sessions/test-sessions-common/pom.xml | 2 +- tests/test-webapps/pom.xml | 2 +- tests/test-webapps/test-webapp-rfc2616/pom.xml | 2 +- 61 files changed, 62 insertions(+), 61 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index c39820c9a06..229055636ea 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,4 +1,4 @@ -jetty-7.5.1.v20110907 - 07 September 2011 +jetty-7.5.1.v20110908 - 08 September 2011 + 350634 Added Resource.newResource(File) + 356190 fix monodb tests for changed test api + 356428 removed timed waits from test @@ -8,6 +8,7 @@ jetty-7.5.1.v20110907 - 07 September 2011 invalidate session + 356751 Add null protection to ServletContextHandler.doStop + 356823 correctly decode close codes. Send not utf-8 close code. + + 357058 Acceptor thread blocking jetty-7.5.0.v20110901 - 01 September 2011 + 356421 Upgraded websocket to draft 13 support diff --git a/example-jetty-embedded/pom.xml b/example-jetty-embedded/pom.xml index 43a88915769..1ccafded294 100644 --- a/example-jetty-embedded/pom.xml +++ b/example-jetty-embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 example-jetty-embedded diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index 7e6c16a86e8..0f685d76257 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index be1cfab7da2..ffbb59f3130 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-client/pom.xml b/jetty-aggregate/jetty-client/pom.xml index aa987775861..695c9dc30e1 100644 --- a/jetty-aggregate/jetty-client/pom.xml +++ b/jetty-aggregate/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-plus/pom.xml b/jetty-aggregate/jetty-plus/pom.xml index b42b44a4725..b03a21d166e 100644 --- a/jetty-aggregate/jetty-plus/pom.xml +++ b/jetty-aggregate/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-server/pom.xml b/jetty-aggregate/jetty-server/pom.xml index bf5c6d4fb02..92dd6814e13 100644 --- a/jetty-aggregate/jetty-server/pom.xml +++ b/jetty-aggregate/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-servlet/pom.xml b/jetty-aggregate/jetty-servlet/pom.xml index 066c8733d8b..e7ccc3091b0 100644 --- a/jetty-aggregate/jetty-servlet/pom.xml +++ b/jetty-aggregate/jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index 9413b7d44df..935c9c30c8c 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/pom.xml b/jetty-aggregate/pom.xml index 57046ec5725..b9e4d48f5d2 100644 --- a/jetty-aggregate/pom.xml +++ b/jetty-aggregate/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT org.eclipse.jetty.aggregate jetty-aggregate-project diff --git a/jetty-ajp/pom.xml b/jetty-ajp/pom.xml index ae866a9d0b7..7580b263ecd 100644 --- a/jetty-ajp/pom.xml +++ b/jetty-ajp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-ajp diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index 92d1a530c29..a9beb33f195 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-annotations diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index a4b2982c9d3..a9ac913e862 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index f3d5f2a3256..bfa68e99b19 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-continuation diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index 5d2e2b8a2ae..246b83b36b5 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-deploy diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 6f8abcd6cb5..435aabc0487 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT jetty-distribution Jetty :: Distribution Assemblies diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index e73ef910bff..e8f316130e7 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index f009450a3a8..8e5ea20cea4 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index f08550b68d3..4897b815aed 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-jaspi diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index 304a7120fa1..54e471e1801 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-jmx diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index 31420e2e5ce..649a3d287d4 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-jndi diff --git a/jetty-jsp-2.1/pom.xml b/jetty-jsp-2.1/pom.xml index ca42f774f54..7be6ce4d4fb 100644 --- a/jetty-jsp-2.1/pom.xml +++ b/jetty-jsp-2.1/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-jsp-2.1 diff --git a/jetty-monitor/pom.xml b/jetty-monitor/pom.xml index 584213da673..c0b6794a126 100644 --- a/jetty-monitor/pom.xml +++ b/jetty-monitor/pom.xml @@ -19,7 +19,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-monitor diff --git a/jetty-nested/pom.xml b/jetty-nested/pom.xml index 6c0a5f0b2c9..523e1bc3a0d 100644 --- a/jetty-nested/pom.xml +++ b/jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT jetty-nested Jetty :: Nested diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index 80e4650a125..c62a1e3c793 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-nosql diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index f2dbf3ccdb9..677f5ce8a0a 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-logback/pom.xml b/jetty-osgi/jetty-osgi-boot-logback/pom.xml index 35c52da69af..5999213db8a 100644 --- a/jetty-osgi/jetty-osgi-boot-logback/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-logback/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index e8bee79d3f5..23a0b8550ad 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index bf836058343..7e9de39efe2 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml index 075e0e811f1..b474b7ff62c 100644 --- a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml +++ b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index 77b5a62df4d..e8212fe1f67 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index d257ef8bd4e..ae696607c06 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml org.eclipse.jetty.osgi diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 7d64e1fac9b..8df9f3823b0 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-overlay-deployer/pom.xml b/jetty-overlay-deployer/pom.xml index 0be54212822..d0347e44f19 100644 --- a/jetty-overlay-deployer/pom.xml +++ b/jetty-overlay-deployer/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-overlay-deployer diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index 2e8be6ca72d..38729dcce37 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-plus diff --git a/jetty-policy/pom.xml b/jetty-policy/pom.xml index 52ed445f169..18fd8b3d2f3 100644 --- a/jetty-policy/pom.xml +++ b/jetty-policy/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT org.eclipse.jetty jetty-policy diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index a08b6edc75d..dd0b4bbc429 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-rewrite diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index 2cdd1fad3a1..f87a115664e 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-security diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index 13f653d8f21..44d0479a0a1 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-server diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index c6bcd38f54b..e2e4c342532 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-servlet diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index c6bb0a28b87..f70b03052b9 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-servlets diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index 5137dc15650..2a72142d1e4 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-start diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index bfb2d4c2295..130cc720dbe 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-util diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index 38b7636cce7..bf5936f5d98 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-webapp diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index 7f3e2cedc84..28856e3a1bd 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index 34102277dd1..43de789eba6 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 jetty-xml diff --git a/pom.xml b/pom.xml index 82675bfea23..4647d86977f 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT Jetty :: Project ${jetty.url} pom diff --git a/test-continuation-jetty6/pom.xml b/test-continuation-jetty6/pom.xml index 15baaa4b0f1..78998bc33c7 100644 --- a/test-continuation-jetty6/pom.xml +++ b/test-continuation-jetty6/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 test-continuation-jetty6 diff --git a/test-continuation/pom.xml b/test-continuation/pom.xml index 60e86df9a01..f5472b090a8 100644 --- a/test-continuation/pom.xml +++ b/test-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 test-continuation diff --git a/test-jetty-nested/pom.xml b/test-jetty-nested/pom.xml index cc2b6aeeefe..fd26d1ce70c 100644 --- a/test-jetty-nested/pom.xml +++ b/test-jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT test-jetty-nested Jetty :: Nested Test diff --git a/test-jetty-servlet/pom.xml b/test-jetty-servlet/pom.xml index 7f7117e8fcc..b2b7d132e3d 100644 --- a/test-jetty-servlet/pom.xml +++ b/test-jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 test-jetty-servlet diff --git a/test-jetty-webapp/pom.xml b/test-jetty-webapp/pom.xml index 7cacb8acec7..779a7d84943 100644 --- a/test-jetty-webapp/pom.xml +++ b/test-jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/tests/pom.xml b/tests/pom.xml index 1216cd35407..a9cdb87fa46 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty jetty-project - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT org.eclipse.jetty.tests tests-parent diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index c691ebdbdc3..08d90fb3462 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -20,7 +20,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT 4.0.0 test-integration diff --git a/tests/test-loginservice/pom.xml b/tests/test-loginservice/pom.xml index 857235f27e7..83a40a8b980 100644 --- a/tests/test-loginservice/pom.xml +++ b/tests/test-loginservice/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT test-loginservice Jetty Tests :: Login Service diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml index d3c4048480d..bf9f8455215 100644 --- a/tests/test-sessions/pom.xml +++ b/tests/test-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT test-sessions-parent Jetty Tests :: Sessions :: Parent diff --git a/tests/test-sessions/test-hash-sessions/pom.xml b/tests/test-sessions/test-hash-sessions/pom.xml index a455bc9b8d9..3b7664027fb 100644 --- a/tests/test-sessions/test-hash-sessions/pom.xml +++ b/tests/test-sessions/test-hash-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT test-hash-sessions Jetty Tests :: Sessions :: Hash diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index 6aee00cdced..7f4c41397e6 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT test-jdbc-sessions Jetty Tests :: Sessions :: JDBC diff --git a/tests/test-sessions/test-sessions-common/pom.xml b/tests/test-sessions/test-sessions-common/pom.xml index a04f775a610..5173618c30c 100644 --- a/tests/test-sessions/test-sessions-common/pom.xml +++ b/tests/test-sessions/test-sessions-common/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT test-sessions-common Jetty Tests :: Sessions :: Common diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index 095c1eaa062..aa6d292a3b8 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT test-webapps-parent Jetty Tests :: WebApps :: Parent diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index e4d1d99f049..0980eae60c5 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-webapps-parent - 7.5.2-SNAPSHOT + 7.5.1-SNAPSHOT test-webapp-rfc2616 Jetty Tests :: WebApp :: RFC2616 From 932245a114b41c77850339666eae103edec88d39 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 8 Sep 2011 12:00:10 -0500 Subject: [PATCH 005/134] [maven-release-plugin] prepare release jetty-7.5.1.v20110908 --- example-jetty-embedded/pom.xml | 2 +- jetty-aggregate/jetty-all-server/pom.xml | 2 +- jetty-aggregate/jetty-all/pom.xml | 2 +- jetty-aggregate/jetty-client/pom.xml | 2 +- jetty-aggregate/jetty-plus/pom.xml | 2 +- jetty-aggregate/jetty-server/pom.xml | 2 +- jetty-aggregate/jetty-servlet/pom.xml | 2 +- jetty-aggregate/jetty-webapp/pom.xml | 2 +- jetty-aggregate/pom.xml | 2 +- jetty-ajp/pom.xml | 2 +- jetty-annotations/pom.xml | 2 +- jetty-client/pom.xml | 2 +- jetty-continuation/pom.xml | 2 +- jetty-deploy/pom.xml | 2 +- jetty-distribution/pom.xml | 2 +- jetty-http/pom.xml | 2 +- jetty-io/pom.xml | 2 +- jetty-jaspi/pom.xml | 2 +- jetty-jmx/pom.xml | 2 +- jetty-jndi/pom.xml | 2 +- jetty-jsp-2.1/pom.xml | 2 +- jetty-monitor/pom.xml | 2 +- jetty-nested/pom.xml | 2 +- jetty-nosql/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-logback/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot/pom.xml | 2 +- jetty-osgi/jetty-osgi-equinoxtools/pom.xml | 2 +- jetty-osgi/jetty-osgi-httpservice/pom.xml | 2 +- jetty-osgi/pom.xml | 2 +- jetty-osgi/test-jetty-osgi/pom.xml | 2 +- jetty-overlay-deployer/pom.xml | 2 +- jetty-plus/pom.xml | 2 +- jetty-policy/pom.xml | 2 +- jetty-rewrite/pom.xml | 2 +- jetty-security/pom.xml | 2 +- jetty-server/pom.xml | 2 +- jetty-servlet/pom.xml | 2 +- jetty-servlets/pom.xml | 2 +- jetty-start/pom.xml | 2 +- jetty-util/pom.xml | 2 +- jetty-webapp/pom.xml | 2 +- jetty-websocket/pom.xml | 2 +- jetty-xml/pom.xml | 2 +- pom.xml | 2 +- test-continuation-jetty6/pom.xml | 2 +- test-continuation/pom.xml | 2 +- test-jetty-nested/pom.xml | 2 +- test-jetty-servlet/pom.xml | 2 +- test-jetty-webapp/pom.xml | 2 +- tests/pom.xml | 2 +- tests/test-integration/pom.xml | 2 +- tests/test-loginservice/pom.xml | 2 +- tests/test-sessions/pom.xml | 2 +- tests/test-sessions/test-hash-sessions/pom.xml | 2 +- tests/test-sessions/test-jdbc-sessions/pom.xml | 2 +- tests/test-sessions/test-sessions-common/pom.xml | 2 +- tests/test-webapps/pom.xml | 2 +- tests/test-webapps/test-webapp-rfc2616/pom.xml | 2 +- 60 files changed, 60 insertions(+), 60 deletions(-) diff --git a/example-jetty-embedded/pom.xml b/example-jetty-embedded/pom.xml index 1ccafded294..2df479aef31 100644 --- a/example-jetty-embedded/pom.xml +++ b/example-jetty-embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 example-jetty-embedded diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index 0f685d76257..7c4069de208 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index ffbb59f3130..181ebaef695 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-client/pom.xml b/jetty-aggregate/jetty-client/pom.xml index 695c9dc30e1..7900a38532c 100644 --- a/jetty-aggregate/jetty-client/pom.xml +++ b/jetty-aggregate/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-plus/pom.xml b/jetty-aggregate/jetty-plus/pom.xml index b03a21d166e..85424eb26c1 100644 --- a/jetty-aggregate/jetty-plus/pom.xml +++ b/jetty-aggregate/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-server/pom.xml b/jetty-aggregate/jetty-server/pom.xml index 92dd6814e13..98a970f5e09 100644 --- a/jetty-aggregate/jetty-server/pom.xml +++ b/jetty-aggregate/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-servlet/pom.xml b/jetty-aggregate/jetty-servlet/pom.xml index e7ccc3091b0..2c049b03d33 100644 --- a/jetty-aggregate/jetty-servlet/pom.xml +++ b/jetty-aggregate/jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index 935c9c30c8c..459859ba17f 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/pom.xml b/jetty-aggregate/pom.xml index b9e4d48f5d2..b2e22f2e67b 100644 --- a/jetty-aggregate/pom.xml +++ b/jetty-aggregate/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 org.eclipse.jetty.aggregate jetty-aggregate-project diff --git a/jetty-ajp/pom.xml b/jetty-ajp/pom.xml index 7580b263ecd..42112996fcd 100644 --- a/jetty-ajp/pom.xml +++ b/jetty-ajp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-ajp diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index a9beb33f195..f7a584cb7c0 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-annotations diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index a9ac913e862..27d1e48192c 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index bfa68e99b19..8567f70abe2 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-continuation diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index 246b83b36b5..bbf818fea71 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-deploy diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 435aabc0487..083f64969a4 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 jetty-distribution Jetty :: Distribution Assemblies diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index e8f316130e7..de9a0ff7d3f 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index 8e5ea20cea4..54900c3ce1d 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index 4897b815aed..5973bd0a9a6 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-jaspi diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index 54e471e1801..6611f5e7b6c 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-jmx diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index 649a3d287d4..68975b0ef0d 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-jndi diff --git a/jetty-jsp-2.1/pom.xml b/jetty-jsp-2.1/pom.xml index 7be6ce4d4fb..ac24945a0be 100644 --- a/jetty-jsp-2.1/pom.xml +++ b/jetty-jsp-2.1/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-jsp-2.1 diff --git a/jetty-monitor/pom.xml b/jetty-monitor/pom.xml index c0b6794a126..171a6e6e287 100644 --- a/jetty-monitor/pom.xml +++ b/jetty-monitor/pom.xml @@ -19,7 +19,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-monitor diff --git a/jetty-nested/pom.xml b/jetty-nested/pom.xml index 523e1bc3a0d..8bd2020878d 100644 --- a/jetty-nested/pom.xml +++ b/jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 jetty-nested Jetty :: Nested diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index c62a1e3c793..4645cb16c89 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-nosql diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index 677f5ce8a0a..0dd1d06bae0 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-logback/pom.xml b/jetty-osgi/jetty-osgi-boot-logback/pom.xml index 5999213db8a..910f8a4f77e 100644 --- a/jetty-osgi/jetty-osgi-boot-logback/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-logback/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index 23a0b8550ad..5c3b2f6a84f 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index 7e9de39efe2..592f31bafcb 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml index b474b7ff62c..4df84e61ec0 100644 --- a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml +++ b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index e8212fe1f67..5502b2aa565 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 ../pom.xml 4.0.0 diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index ae696607c06..4e9f212d892 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 ../pom.xml org.eclipse.jetty.osgi diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 8df9f3823b0..caba7ad43b9 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 ../pom.xml 4.0.0 diff --git a/jetty-overlay-deployer/pom.xml b/jetty-overlay-deployer/pom.xml index d0347e44f19..7b7fe6abeca 100644 --- a/jetty-overlay-deployer/pom.xml +++ b/jetty-overlay-deployer/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-overlay-deployer diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index 38729dcce37..33d41aea514 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-plus diff --git a/jetty-policy/pom.xml b/jetty-policy/pom.xml index 18fd8b3d2f3..ea532fe15e2 100644 --- a/jetty-policy/pom.xml +++ b/jetty-policy/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 org.eclipse.jetty jetty-policy diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index dd0b4bbc429..45fa91c750c 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-rewrite diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index f87a115664e..c53a8993cc4 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-security diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index 44d0479a0a1..24270020389 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-server diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index e2e4c342532..f5d08d3288a 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-servlet diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index f70b03052b9..c2edec80c5a 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-servlets diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index 2a72142d1e4..f4999dccced 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-start diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index 130cc720dbe..276442a75b7 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-util diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index bf5936f5d98..adce8270b57 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-webapp diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index 28856e3a1bd..fc2205d309d 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index 43de789eba6..cf2e632fcbd 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 jetty-xml diff --git a/pom.xml b/pom.xml index 4647d86977f..b6f8b7d086e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 Jetty :: Project ${jetty.url} pom diff --git a/test-continuation-jetty6/pom.xml b/test-continuation-jetty6/pom.xml index 78998bc33c7..e23d86cfffc 100644 --- a/test-continuation-jetty6/pom.xml +++ b/test-continuation-jetty6/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 test-continuation-jetty6 diff --git a/test-continuation/pom.xml b/test-continuation/pom.xml index f5472b090a8..1753282cba2 100644 --- a/test-continuation/pom.xml +++ b/test-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 test-continuation diff --git a/test-jetty-nested/pom.xml b/test-jetty-nested/pom.xml index fd26d1ce70c..1cf038a3fe6 100644 --- a/test-jetty-nested/pom.xml +++ b/test-jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 test-jetty-nested Jetty :: Nested Test diff --git a/test-jetty-servlet/pom.xml b/test-jetty-servlet/pom.xml index b2b7d132e3d..f79df4a99b0 100644 --- a/test-jetty-servlet/pom.xml +++ b/test-jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 test-jetty-servlet diff --git a/test-jetty-webapp/pom.xml b/test-jetty-webapp/pom.xml index 779a7d84943..35f6f98d369 100644 --- a/test-jetty-webapp/pom.xml +++ b/test-jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 org.eclipse.jetty diff --git a/tests/pom.xml b/tests/pom.xml index a9cdb87fa46..89a4677b943 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty jetty-project - 7.5.1-SNAPSHOT + 7.5.1.v20110908 org.eclipse.jetty.tests tests-parent diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index 08d90fb3462..230ccc29a4a 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -20,7 +20,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110908 4.0.0 test-integration diff --git a/tests/test-loginservice/pom.xml b/tests/test-loginservice/pom.xml index 83a40a8b980..c08b474eb64 100644 --- a/tests/test-loginservice/pom.xml +++ b/tests/test-loginservice/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110908 test-loginservice Jetty Tests :: Login Service diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml index bf9f8455215..301f45c27f2 100644 --- a/tests/test-sessions/pom.xml +++ b/tests/test-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110908 test-sessions-parent Jetty Tests :: Sessions :: Parent diff --git a/tests/test-sessions/test-hash-sessions/pom.xml b/tests/test-sessions/test-hash-sessions/pom.xml index 3b7664027fb..1b6d664796c 100644 --- a/tests/test-sessions/test-hash-sessions/pom.xml +++ b/tests/test-sessions/test-hash-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110908 test-hash-sessions Jetty Tests :: Sessions :: Hash diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index 7f4c41397e6..b67542bcac0 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110908 test-jdbc-sessions Jetty Tests :: Sessions :: JDBC diff --git a/tests/test-sessions/test-sessions-common/pom.xml b/tests/test-sessions/test-sessions-common/pom.xml index 5173618c30c..21d427bb314 100644 --- a/tests/test-sessions/test-sessions-common/pom.xml +++ b/tests/test-sessions/test-sessions-common/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110908 test-sessions-common Jetty Tests :: Sessions :: Common diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index aa6d292a3b8..2a97671964a 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110908 test-webapps-parent Jetty Tests :: WebApps :: Parent diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index 0980eae60c5..c328702b722 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-webapps-parent - 7.5.1-SNAPSHOT + 7.5.1.v20110908 test-webapp-rfc2616 Jetty Tests :: WebApp :: RFC2616 From ebdb89dc2313972c53c376f1e16662c70f01687c Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 8 Sep 2011 12:00:16 -0500 Subject: [PATCH 006/134] [maven-release-plugin] prepare for next development iteration --- example-jetty-embedded/pom.xml | 2 +- jetty-aggregate/jetty-all-server/pom.xml | 2 +- jetty-aggregate/jetty-all/pom.xml | 2 +- jetty-aggregate/jetty-client/pom.xml | 2 +- jetty-aggregate/jetty-plus/pom.xml | 2 +- jetty-aggregate/jetty-server/pom.xml | 2 +- jetty-aggregate/jetty-servlet/pom.xml | 2 +- jetty-aggregate/jetty-webapp/pom.xml | 2 +- jetty-aggregate/pom.xml | 2 +- jetty-ajp/pom.xml | 2 +- jetty-annotations/pom.xml | 2 +- jetty-client/pom.xml | 2 +- jetty-continuation/pom.xml | 2 +- jetty-deploy/pom.xml | 2 +- jetty-distribution/pom.xml | 2 +- jetty-http/pom.xml | 2 +- jetty-io/pom.xml | 2 +- jetty-jaspi/pom.xml | 2 +- jetty-jmx/pom.xml | 2 +- jetty-jndi/pom.xml | 2 +- jetty-jsp-2.1/pom.xml | 2 +- jetty-monitor/pom.xml | 2 +- jetty-nested/pom.xml | 2 +- jetty-nosql/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-logback/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot/pom.xml | 2 +- jetty-osgi/jetty-osgi-equinoxtools/pom.xml | 2 +- jetty-osgi/jetty-osgi-httpservice/pom.xml | 2 +- jetty-osgi/pom.xml | 2 +- jetty-osgi/test-jetty-osgi/pom.xml | 2 +- jetty-overlay-deployer/pom.xml | 2 +- jetty-plus/pom.xml | 2 +- jetty-policy/pom.xml | 2 +- jetty-rewrite/pom.xml | 2 +- jetty-security/pom.xml | 2 +- jetty-server/pom.xml | 2 +- jetty-servlet/pom.xml | 2 +- jetty-servlets/pom.xml | 2 +- jetty-start/pom.xml | 2 +- jetty-util/pom.xml | 2 +- jetty-webapp/pom.xml | 2 +- jetty-websocket/pom.xml | 2 +- jetty-xml/pom.xml | 2 +- pom.xml | 2 +- test-continuation-jetty6/pom.xml | 2 +- test-continuation/pom.xml | 2 +- test-jetty-nested/pom.xml | 2 +- test-jetty-servlet/pom.xml | 2 +- test-jetty-webapp/pom.xml | 2 +- tests/pom.xml | 2 +- tests/test-integration/pom.xml | 2 +- tests/test-loginservice/pom.xml | 2 +- tests/test-sessions/pom.xml | 2 +- tests/test-sessions/test-hash-sessions/pom.xml | 2 +- tests/test-sessions/test-jdbc-sessions/pom.xml | 2 +- tests/test-sessions/test-sessions-common/pom.xml | 2 +- tests/test-webapps/pom.xml | 2 +- tests/test-webapps/test-webapp-rfc2616/pom.xml | 2 +- 60 files changed, 60 insertions(+), 60 deletions(-) diff --git a/example-jetty-embedded/pom.xml b/example-jetty-embedded/pom.xml index 2df479aef31..43a88915769 100644 --- a/example-jetty-embedded/pom.xml +++ b/example-jetty-embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 example-jetty-embedded diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index 7c4069de208..7e6c16a86e8 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index 181ebaef695..be1cfab7da2 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-client/pom.xml b/jetty-aggregate/jetty-client/pom.xml index 7900a38532c..aa987775861 100644 --- a/jetty-aggregate/jetty-client/pom.xml +++ b/jetty-aggregate/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-plus/pom.xml b/jetty-aggregate/jetty-plus/pom.xml index 85424eb26c1..b42b44a4725 100644 --- a/jetty-aggregate/jetty-plus/pom.xml +++ b/jetty-aggregate/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-server/pom.xml b/jetty-aggregate/jetty-server/pom.xml index 98a970f5e09..bf5c6d4fb02 100644 --- a/jetty-aggregate/jetty-server/pom.xml +++ b/jetty-aggregate/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-servlet/pom.xml b/jetty-aggregate/jetty-servlet/pom.xml index 2c049b03d33..066c8733d8b 100644 --- a/jetty-aggregate/jetty-servlet/pom.xml +++ b/jetty-aggregate/jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index 459859ba17f..9413b7d44df 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.aggregate jetty-aggregate-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty.aggregate diff --git a/jetty-aggregate/pom.xml b/jetty-aggregate/pom.xml index b2e22f2e67b..57046ec5725 100644 --- a/jetty-aggregate/pom.xml +++ b/jetty-aggregate/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT org.eclipse.jetty.aggregate jetty-aggregate-project diff --git a/jetty-ajp/pom.xml b/jetty-ajp/pom.xml index 42112996fcd..ae866a9d0b7 100644 --- a/jetty-ajp/pom.xml +++ b/jetty-ajp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-ajp diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index f7a584cb7c0..92d1a530c29 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-annotations diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index 27d1e48192c..a4b2982c9d3 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index 8567f70abe2..f3d5f2a3256 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-continuation diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index bbf818fea71..5d2e2b8a2ae 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-deploy diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 083f64969a4..6f8abcd6cb5 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT jetty-distribution Jetty :: Distribution Assemblies diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index de9a0ff7d3f..e73ef910bff 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index 54900c3ce1d..f009450a3a8 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -2,7 +2,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index 5973bd0a9a6..f08550b68d3 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-jaspi diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index 6611f5e7b6c..304a7120fa1 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-jmx diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index 68975b0ef0d..31420e2e5ce 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-jndi diff --git a/jetty-jsp-2.1/pom.xml b/jetty-jsp-2.1/pom.xml index ac24945a0be..ca42f774f54 100644 --- a/jetty-jsp-2.1/pom.xml +++ b/jetty-jsp-2.1/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-jsp-2.1 diff --git a/jetty-monitor/pom.xml b/jetty-monitor/pom.xml index 171a6e6e287..584213da673 100644 --- a/jetty-monitor/pom.xml +++ b/jetty-monitor/pom.xml @@ -19,7 +19,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-monitor diff --git a/jetty-nested/pom.xml b/jetty-nested/pom.xml index 8bd2020878d..6c0a5f0b2c9 100644 --- a/jetty-nested/pom.xml +++ b/jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT jetty-nested Jetty :: Nested diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index 4645cb16c89..80e4650a125 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-nosql diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index 0dd1d06bae0..f2dbf3ccdb9 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-logback/pom.xml b/jetty-osgi/jetty-osgi-boot-logback/pom.xml index 910f8a4f77e..35c52da69af 100644 --- a/jetty-osgi/jetty-osgi-boot-logback/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-logback/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index 5c3b2f6a84f..e8bee79d3f5 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index 592f31bafcb..bf836058343 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml index 4df84e61ec0..075e0e811f1 100644 --- a/jetty-osgi/jetty-osgi-equinoxtools/pom.xml +++ b/jetty-osgi/jetty-osgi-equinoxtools/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index 5502b2aa565..77b5a62df4d 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index 4e9f212d892..d257ef8bd4e 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT ../pom.xml org.eclipse.jetty.osgi diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index caba7ad43b9..7d64e1fac9b 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-overlay-deployer/pom.xml b/jetty-overlay-deployer/pom.xml index 7b7fe6abeca..0be54212822 100644 --- a/jetty-overlay-deployer/pom.xml +++ b/jetty-overlay-deployer/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-overlay-deployer diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index 33d41aea514..2e8be6ca72d 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-plus diff --git a/jetty-policy/pom.xml b/jetty-policy/pom.xml index ea532fe15e2..52ed445f169 100644 --- a/jetty-policy/pom.xml +++ b/jetty-policy/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT org.eclipse.jetty jetty-policy diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index 45fa91c750c..a08b6edc75d 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-rewrite diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index c53a8993cc4..2cdd1fad3a1 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-security diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index 24270020389..13f653d8f21 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-server diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index f5d08d3288a..c6bcd38f54b 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-servlet diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index c2edec80c5a..c6bb0a28b87 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-servlets diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index f4999dccced..5137dc15650 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-start diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index 276442a75b7..bfb2d4c2295 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-util diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index adce8270b57..38b7636cce7 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-webapp diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index fc2205d309d..7f3e2cedc84 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index cf2e632fcbd..34102277dd1 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 jetty-xml diff --git a/pom.xml b/pom.xml index b6f8b7d086e..82675bfea23 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT Jetty :: Project ${jetty.url} pom diff --git a/test-continuation-jetty6/pom.xml b/test-continuation-jetty6/pom.xml index e23d86cfffc..15baaa4b0f1 100644 --- a/test-continuation-jetty6/pom.xml +++ b/test-continuation-jetty6/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 test-continuation-jetty6 diff --git a/test-continuation/pom.xml b/test-continuation/pom.xml index 1753282cba2..60e86df9a01 100644 --- a/test-continuation/pom.xml +++ b/test-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 test-continuation diff --git a/test-jetty-nested/pom.xml b/test-jetty-nested/pom.xml index 1cf038a3fe6..cc2b6aeeefe 100644 --- a/test-jetty-nested/pom.xml +++ b/test-jetty-nested/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT test-jetty-nested Jetty :: Nested Test diff --git a/test-jetty-servlet/pom.xml b/test-jetty-servlet/pom.xml index f79df4a99b0..7f7117e8fcc 100644 --- a/test-jetty-servlet/pom.xml +++ b/test-jetty-servlet/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 test-jetty-servlet diff --git a/test-jetty-webapp/pom.xml b/test-jetty-webapp/pom.xml index 35f6f98d369..7cacb8acec7 100644 --- a/test-jetty-webapp/pom.xml +++ b/test-jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/tests/pom.xml b/tests/pom.xml index 89a4677b943..1216cd35407 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty jetty-project - 7.5.1.v20110908 + 7.5.2-SNAPSHOT org.eclipse.jetty.tests tests-parent diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index 230ccc29a4a..c691ebdbdc3 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -20,7 +20,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1.v20110908 + 7.5.2-SNAPSHOT 4.0.0 test-integration diff --git a/tests/test-loginservice/pom.xml b/tests/test-loginservice/pom.xml index c08b474eb64..857235f27e7 100644 --- a/tests/test-loginservice/pom.xml +++ b/tests/test-loginservice/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1.v20110908 + 7.5.2-SNAPSHOT test-loginservice Jetty Tests :: Login Service diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml index 301f45c27f2..d3c4048480d 100644 --- a/tests/test-sessions/pom.xml +++ b/tests/test-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1.v20110908 + 7.5.2-SNAPSHOT test-sessions-parent Jetty Tests :: Sessions :: Parent diff --git a/tests/test-sessions/test-hash-sessions/pom.xml b/tests/test-sessions/test-hash-sessions/pom.xml index 1b6d664796c..a455bc9b8d9 100644 --- a/tests/test-sessions/test-hash-sessions/pom.xml +++ b/tests/test-sessions/test-hash-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1.v20110908 + 7.5.2-SNAPSHOT test-hash-sessions Jetty Tests :: Sessions :: Hash diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index b67542bcac0..6aee00cdced 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1.v20110908 + 7.5.2-SNAPSHOT test-jdbc-sessions Jetty Tests :: Sessions :: JDBC diff --git a/tests/test-sessions/test-sessions-common/pom.xml b/tests/test-sessions/test-sessions-common/pom.xml index 21d427bb314..a04f775a610 100644 --- a/tests/test-sessions/test-sessions-common/pom.xml +++ b/tests/test-sessions/test-sessions-common/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-sessions-parent - 7.5.1.v20110908 + 7.5.2-SNAPSHOT test-sessions-common Jetty Tests :: Sessions :: Common diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index 2a97671964a..095c1eaa062 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests tests-parent - 7.5.1.v20110908 + 7.5.2-SNAPSHOT test-webapps-parent Jetty Tests :: WebApps :: Parent diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index c328702b722..e4d1d99f049 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -21,7 +21,7 @@ org.eclipse.jetty.tests test-webapps-parent - 7.5.1.v20110908 + 7.5.2-SNAPSHOT test-webapp-rfc2616 Jetty Tests :: WebApp :: RFC2616 From 03c0192cdbff5c66dc704578abc372c7d1b0017a Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 8 Sep 2011 10:29:27 -0700 Subject: [PATCH 007/134] Making image files from src/main/javadoc actually show up in javadoc:aggregate and -javadoc.jar files --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 4647d86977f..8bd937d88d4 100644 --- a/pom.xml +++ b/pom.xml @@ -266,6 +266,11 @@ org.apache.maven.plugins maven-javadoc-plugin 2.8 + + true + true + true + org.apache.maven.plugins From 0046c5a9c25769419132c0274fe1e1d3a709fdc1 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 8 Sep 2011 12:45:59 -0500 Subject: [PATCH 008/134] set for next release --- VERSION.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VERSION.txt b/VERSION.txt index 229055636ea..e0abfa17b93 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,3 +1,5 @@ +jetty-7.5.2-SNAPSHOT + jetty-7.5.1.v20110908 - 08 September 2011 + 350634 Added Resource.newResource(File) + 356190 fix monodb tests for changed test api From 4c885ca3add0f7c463f20cbb92d275ae3e5d7b26 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 9 Sep 2011 12:10:01 +1000 Subject: [PATCH 009/134] 357178 websockets draft 14 support --- .../websocket/WebSocketConnectionD13.java | 60 +++++++++++++------ .../jetty/websocket/WebSocketFactory.java | 42 +++++++++---- .../websocket/WebSocketMessageD00Test.java | 1 + .../websocket/WebSocketMessageD13Test.java | 2 +- 4 files changed, 73 insertions(+), 32 deletions(-) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java index 03f4ca9d61c..bcda94485a8 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java @@ -42,7 +42,8 @@ import org.eclipse.jetty.websocket.WebSocket.OnTextMessage; public class WebSocketConnectionD13 extends AbstractConnection implements WebSocketConnection { private static final Logger LOG = Log.getLogger(WebSocketConnectionD13.class); - private static final boolean STRICT=true; + private static final boolean STRICT=Boolean.getBoolean("org.eclipse.jetty.websocket.STRICT"); + private static final boolean BRUTAL=Boolean.getBoolean("org.eclipse.jetty.websocket.BRUTAL"); final static byte OP_CONTINUATION = 0x00; final static byte OP_TEXT = 0x01; @@ -62,7 +63,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc final static int CLOSE_UNDEFINED=1004; final static int CLOSE_NO_CODE=1005; final static int CLOSE_NO_CLOSE=1006; - final static int CLOSE_NOT_UTF8=1007; + final static int CLOSE_BAD_PAYLOAD=1007; final static int CLOSE_POLICY_VIOLATION=1008; final static int CLOSE_MESSAGE_TOO_LARGE=1009; final static int CLOSE_REQUIRED_EXTENSION=1010; @@ -641,19 +642,13 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc { if (isControlFrame(opcode) && buffer.length()>125) { - _connection.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"Control frame too large"); + errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Control frame too large"); return; } if ((flags&0x7)!=0) { - _connection.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"RSV bits set 0x"+Integer.toHexString(flags)); - return; - } - - if (_opcode!=-1 && opcode!=WebSocketConnectionD13.OP_CONTINUATION) - { - _connection.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad continuation"+Integer.toHexString(opcode)); + errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"RSV bits set 0x"+Integer.toHexString(flags)); return; } @@ -681,7 +676,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc { if (_opcode==-1) { - _connection.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad Continuation"); + errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad Continuation"); return; } @@ -756,6 +751,12 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc case WebSocketConnectionD13.OP_TEXT: { + if (STRICT && _opcode!=-1) + { + errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode)); + return; + } + if(_onTextMessage!=null) { if (_connection.getMaxTextMessageSize()<=0) @@ -766,7 +767,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc else { LOG.warn("Frame discarded. Text aggregation disabled for {}",_endp); - _connection.close(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,"Text frame aggregation disabled"); + errorClose(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,"Text frame aggregation disabled"); } } // append bytes to message buffer (if they fit) @@ -788,9 +789,15 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } break; } - + case WebSocketConnectionD13.OP_BINARY: { + if (STRICT && _opcode!=-1) + { + errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode)); + return; + } + if (_onBinaryMessage!=null && checkBinaryMessageSize(0,buffer.length())) { if (lastFrame) @@ -808,25 +815,23 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc else { LOG.warn("Frame discarded. Binary aggregation disabed for {}",_endp); - _connection.close(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,"Binary frame aggregation disabled"); + errorClose(WebSocketConnectionD13.CLOSE_POLICY_VIOLATION,"Binary frame aggregation disabled"); } } break; } - + default: if (STRICT) - _connection.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad opcode 0x"+Integer.toHexString(opcode)); + errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad opcode 0x"+Integer.toHexString(opcode)); return; - } } catch(Utf8Appendable.NotUtf8Exception notUtf8) { - LOG.warn(notUtf8); LOG.warn("{} for {}",notUtf8,_endp); LOG.debug(notUtf8); - _connection.close(WebSocketConnectionD13.CLOSE_NOT_UTF8,"Invalid UTF-8"); + errorClose(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,"Invalid UTF-8"); } catch(ThreadDeath th) { @@ -838,6 +843,23 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc } } + private void errorClose(int code, String message) + { + _connection.close(code,message); + if (BRUTAL) + { + try + { + _endp.close(); + } + catch (IOException e) + { + LOG.warn(e.toString()); + LOG.debug(e); + } + } + } + private boolean checkBinaryMessageSize(int bufferLen, int length) { int max = _connection.getMaxBinaryMessageSize(); diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java index 4752ac67d28..9ac710573c1 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java @@ -227,11 +227,13 @@ public class WebSocketFactory connection = new WebSocketConnectionD12(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); break; case 13: + case 14: extensions= initExtensions(extensions_requested,8-WebSocketConnectionD13.OP_EXT_DATA, 16-WebSocketConnectionD13.OP_EXT_CTRL,3); connection = new WebSocketConnectionD13(websocket, endp, _buffers, http.getTimeStamp(), _maxIdleTime, protocol,extensions,draft); break; default: LOG.warn("Unsupported Websocket version: "+draft); + response.setHeader("Sec-WebSocket-Version","0,6,12,13,14"); throw new HttpException(400, "Unsupported draft specification: " + draft); } @@ -251,6 +253,8 @@ public class WebSocketFactory request.setAttribute("org.eclipse.jetty.io.Connection", connection); } + /** + */ protected String[] parseProtocols(String protocol) { if (protocol == null) @@ -264,6 +268,8 @@ public class WebSocketFactory return protocols; } + /** + */ public boolean acceptWebSocket(HttpServletRequest request, HttpServletResponse response) throws IOException { @@ -280,24 +286,34 @@ public class WebSocketFactory // Try each requested protocol WebSocket websocket = null; - String protocol = request.getHeader("Sec-WebSocket-Protocol"); - if (protocol == null) // TODO remove once draft period is over - protocol = request.getHeader("WebSocket-Protocol"); - for (String p : parseProtocols(protocol)) + + Enumeration protocols = request.getHeaders("Sec-WebSocket-Protocol"); + String protocol=null; + while (protocol==null && protocols!=null && protocols.hasMoreElements()) { - websocket = _acceptor.doWebSocketConnect(request, p); - if (websocket != null) + String candidate = protocols.nextElement(); + for (String p : parseProtocols(candidate)) { - protocol = p; - break; + websocket = _acceptor.doWebSocketConnect(request, p); + if (websocket != null) + { + protocol = p; + break; + } } } // Did we get a websocket? if (websocket == null) { - response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); - return false; + // Try with no protocol + websocket = _acceptor.doWebSocketConnect(request, null); + + if (websocket==null) + { + response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); + return false; + } } // Send the upgrade @@ -308,6 +324,8 @@ public class WebSocketFactory return false; } + /** + */ public List initExtensions(List requested,int maxDataOpcodes,int maxControlOpcodes,int maxReservedBits) { List extensions = new ArrayList(); @@ -339,6 +357,8 @@ public class WebSocketFactory return extensions; } + /** + */ private Extension newExtension(String name) { try @@ -354,6 +374,4 @@ public class WebSocketFactory return null; } - - } diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java index 99781856907..53b31f1bf30 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD00Test.java @@ -84,6 +84,7 @@ public class WebSocketMessageD00Test InputStream input = socket.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(input, "ISO-8859-1")); String responseLine = reader.readLine(); + System.err.println(responseLine); assertTrue(responseLine.startsWith("HTTP/1.1 101 WebSocket Protocol Handshake")); // Read until we find an empty line, which signals the end of the http response String line; diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD13Test.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD13Test.java index 6c4e8ae253a..e48885c2f01 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD13Test.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketMessageD13Test.java @@ -998,7 +998,7 @@ public class WebSocketMessageD13Test assertEquals(0x80|WebSocketConnectionD13.OP_CLOSE,input.read()); assertEquals(15,input.read()); int code=(0xff&input.read())*0x100+(0xff&input.read()); - assertEquals(WebSocketConnectionD13.CLOSE_NOT_UTF8,code); + assertEquals(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,code); lookFor("Invalid UTF-8",input); } From 45f5fd39fe8edee1a4d7df2eaa4fcb0ede6f5f9f Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 9 Sep 2011 17:07:24 +1000 Subject: [PATCH 010/134] 357188 Send content buffer directly --- .../jetty/nested/NestedConnection.java | 3 +- .../eclipse/jetty/nested/NestedGenerator.java | 86 ++++++++++++++----- .../eclipse/jetty/nested/NestedServer.java | 2 +- 3 files changed, 67 insertions(+), 24 deletions(-) diff --git a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnection.java b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnection.java index 045afc17e35..b377fc6f0bc 100644 --- a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnection.java +++ b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnection.java @@ -88,7 +88,8 @@ public class NestedConnection extends HttpConnection { getServer().handle(this); completeResponse(); - _generator.flushBuffer(); + while (!_generator.isComplete() && _endp.isOpen()) + _generator.flushBuffer(); _endp.flush(); } finally diff --git a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedGenerator.java b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedGenerator.java index 3ab098ccf1c..b9c970207e8 100644 --- a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedGenerator.java +++ b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedGenerator.java @@ -43,7 +43,7 @@ public class NestedGenerator extends AbstractGenerator public void addContent(Buffer content, boolean last) throws IOException { - // LOG.debug("addContent {} {}",content.length(),last); + LOG.debug("addContent {} {}",content.length(),last); if (_noContent) { content.clear(); @@ -70,7 +70,6 @@ public class NestedGenerator extends AbstractGenerator // Handle any unfinished business? if (_content != null && _content.length() > 0) { - flushBuffer(); if (_content != null && _content.length() > 0) throw new IllegalStateException("FULL"); @@ -86,20 +85,22 @@ public class NestedGenerator extends AbstractGenerator content.clear(); _content = null; } - else + else if (!last || _buffer!=null) { // Yes - so we better check we have a buffer - initContent(); + initBuffer(); // Copy _content to buffer; int len = 0; len = _buffer.put(_content); - // make sure there is space for a trailing null + // make sure there is space for a trailing null (???) if (len > 0 && _buffer.space() == 0) { len--; _buffer.setPutIndex(_buffer.putIndex() - 1); } + + LOG.debug("copied {} to buffer",len); _content.skip(len); @@ -139,7 +140,7 @@ public class NestedGenerator extends AbstractGenerator return false; // we better check we have a buffer - initContent(); + initBuffer(); // Copy _content to buffer; @@ -149,7 +150,7 @@ public class NestedGenerator extends AbstractGenerator } /* ------------------------------------------------------------ */ - private void initContent() throws IOException + private void initBuffer() throws IOException { if (_buffer == null) { @@ -176,7 +177,7 @@ public class NestedGenerator extends AbstractGenerator @Override public int prepareUncheckedAddContent() throws IOException { - initContent(); + initBuffer(); return _buffer.space(); } @@ -229,6 +230,26 @@ public class NestedGenerator extends AbstractGenerator _state = STATE_CONTENT; } + /* ------------------------------------------------------------ */ + /** + * Complete the message. + * + * @throws IOException + */ + @Override + public void complete() throws IOException + { + if (_state == STATE_END) + return; + + super.complete(); + + if (_state < STATE_FLUSHING) + _state = STATE_FLUSHING; + + flushBuffer(); + } + /* ------------------------------------------------------------ */ @Override public long flushBuffer() throws IOException @@ -236,23 +257,44 @@ public class NestedGenerator extends AbstractGenerator if (_state == STATE_HEADER) throw new IllegalStateException("State==HEADER"); - - if (_content != null && _content.length() < _buffer.space() && _state != STATE_FLUSHING) - { - initContent(); - _buffer.put(_content); - _content.clear(); - _content = null; - } + int len = 0; if (_buffer==null) - return 0; + { + + if (_content!=null && _content.length()>0) + { + // flush content directly + len = _endp.flush(_content); + if (len>0) + _content.skip(len); + } + } + else + { + if (_buffer.length()==0 && _content!=null && _content.length()>0) + { + // Copy content to buffer + _content.skip(_buffer.put(_content)); + } + + int size=_buffer.length(); + len =_endp.flush(_buffer); + LOG.debug("flushBuffer {} of {}",len,size); + if (len>0) + _buffer.skip(len); + } - int size=_buffer.length(); - int len = _buffer==null?0:_endp.flush(_buffer); - LOG.debug("flushBuffer {} of {}",len,size); - if (len>0) - _buffer.skip(len); + if (_content!=null && _content.length()==0) + _content=null; + if (_buffer!=null && _buffer.length()==0 && _content==null) + { + _buffers.returnBuffer(_buffer); + _buffer=null; + } + + if (_state==STATE_FLUSHING && _buffer==null && _content==null) + _state=STATE_END; return len; } diff --git a/test-jetty-nested/src/test/java/org/eclipse/jetty/nested/NestedServer.java b/test-jetty-nested/src/test/java/org/eclipse/jetty/nested/NestedServer.java index 2e6c950060d..7af54fc90b5 100644 --- a/test-jetty-nested/src/test/java/org/eclipse/jetty/nested/NestedServer.java +++ b/test-jetty-nested/src/test/java/org/eclipse/jetty/nested/NestedServer.java @@ -31,7 +31,7 @@ public class NestedServer WebAppContext webapp = new WebAppContext(); - webapp.setContextPath("/"); + webapp.setContextPath("/jnest"); webapp.setWar("src/main/webapp"); webapp.setParentLoaderPriority(true); server.setHandler(webapp); From f84c859bbcceb3b72a5d856fd3969c716b83b828 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 9 Sep 2011 09:51:52 -0700 Subject: [PATCH 011/134] 357216 - Logging via Log4J does not expand braces in format strings + Made JettyAwareLogger more resilient to logger downstream implementations by making it perform the slf4j message formatting before handing it off to the LocationAwareLogger method(s) --- .../jetty/util/log/JettyAwareLogger.java | 26 ++++++++++++++++--- .../java/org/eclipse/jetty/util/log/Log.java | 4 --- .../org/eclipse/jetty/util/log/Slf4jLog.java | 2 ++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/JettyAwareLogger.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/JettyAwareLogger.java index 8fffd91802a..52bb112079c 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/JettyAwareLogger.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/JettyAwareLogger.java @@ -13,9 +13,15 @@ package org.eclipse.jetty.util.log; import org.slf4j.Marker; +import org.slf4j.helpers.FormattingTuple; +import org.slf4j.helpers.MessageFormatter; - -/* ------------------------------------------------------------ */ +/** + * JettyAwareLogger is used to fix a FQCN bug that arises from how Jetty + * Log uses an indirect slf4j implementation. + * + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=276670 + */ class JettyAwareLogger implements org.slf4j.Logger { private static final int DEBUG = org.slf4j.spi.LocationAwareLogger.DEBUG_INT; @@ -24,6 +30,7 @@ class JettyAwareLogger implements org.slf4j.Logger private static final int TRACE = org.slf4j.spi.LocationAwareLogger.TRACE_INT; private static final int WARN = org.slf4j.spi.LocationAwareLogger.WARN_INT; + private static final String FQCN = Slf4jLog.class.getName(); private final org.slf4j.spi.LocationAwareLogger _logger; public JettyAwareLogger(org.slf4j.spi.LocationAwareLogger logger) @@ -586,8 +593,19 @@ class JettyAwareLogger implements org.slf4j.Logger return _logger.toString(); } - private void log(Marker marker, int level, String msg, Object[] objArray, Throwable t) + private void log(Marker marker, int level, String msg, Object[] argArray, Throwable t) { - _logger.log(marker,"org.eclipse.jetty.util.log.Log",level, msg, objArray,t); + if (argArray == null) + { + // Simple SLF4J Message (no args) + _logger.log(marker,FQCN,level,msg,null,t); + } + else + { + // Don't assume downstream handles argArray properly. + // Do it the SLF4J way here to eliminate that as a bug. + FormattingTuple ft = MessageFormatter.arrayFormat(msg,argArray); + _logger.log(marker,FQCN,level,ft.getMessage(),null,t); + } } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java index 400805b55f3..a1130ab6043 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java @@ -129,10 +129,6 @@ public class Log return __log; } - /** - * @deprecated anonymous logging is deprecated, use a named {@link Logger} obtained from {@link #getLogger(String)} - */ - @Deprecated static boolean isIgnored() { return __ignored; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Slf4jLog.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Slf4jLog.java index 82c0b7e9dce..bdd688f5fb8 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Slf4jLog.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Slf4jLog.java @@ -42,6 +42,8 @@ public class Slf4jLog implements Logger } org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger( name ); + // Fix LocationAwareLogger use to indicate FQCN of this class - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=276670 if (logger instanceof org.slf4j.spi.LocationAwareLogger) { _logger = new JettyAwareLogger((org.slf4j.spi.LocationAwareLogger)logger); From 2e7d84dec8e179ed8fe11f46d00adb2f8f751467 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Fri, 9 Sep 2011 15:42:01 -0500 Subject: [PATCH 012/134] Update to new parent pom that lets us import into indigo and m2eclipse --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8f0256af067..fcb8e146e5c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-parent - 18 + 19-SNAPSHOT org.eclipse.jetty jetty-project From 56269df4195fea5a31d0277e143c953b41bd6153 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Fri, 9 Sep 2011 16:08:15 -0500 Subject: [PATCH 013/134] remove extra groupId element --- jetty-aggregate/jetty-all-server/pom.xml | 1 - jetty-aggregate/jetty-all/pom.xml | 2 -- jetty-aggregate/jetty-client/pom.xml | 1 - jetty-aggregate/jetty-plus/pom.xml | 1 - jetty-aggregate/jetty-server/pom.xml | 1 - jetty-aggregate/jetty-servlet/pom.xml | 1 - jetty-aggregate/jetty-webapp/pom.xml | 1 - 7 files changed, 8 deletions(-) diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index 7e6c16a86e8..ec94c3d2af1 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -5,7 +5,6 @@ 7.5.2-SNAPSHOT 4.0.0 - org.eclipse.jetty.aggregate jetty-all-server Jetty :: Aggregate :: All Server diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index be1cfab7da2..c65e5c899af 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -5,10 +5,8 @@ 7.5.2-SNAPSHOT 4.0.0 - org.eclipse.jetty.aggregate jetty-all Jetty :: Aggregate :: All core Jetty - ${project.build.directory}/sources diff --git a/jetty-aggregate/jetty-client/pom.xml b/jetty-aggregate/jetty-client/pom.xml index aa987775861..31ef23da330 100644 --- a/jetty-aggregate/jetty-client/pom.xml +++ b/jetty-aggregate/jetty-client/pom.xml @@ -5,7 +5,6 @@ 7.5.2-SNAPSHOT 4.0.0 - org.eclipse.jetty.aggregate jetty-client Jetty :: Aggregate :: HTTP Client diff --git a/jetty-aggregate/jetty-plus/pom.xml b/jetty-aggregate/jetty-plus/pom.xml index b42b44a4725..4ae4e9bf450 100644 --- a/jetty-aggregate/jetty-plus/pom.xml +++ b/jetty-aggregate/jetty-plus/pom.xml @@ -5,7 +5,6 @@ 7.5.2-SNAPSHOT 4.0.0 - org.eclipse.jetty.aggregate jetty-plus Jetty :: Aggregate :: Plus Server diff --git a/jetty-aggregate/jetty-server/pom.xml b/jetty-aggregate/jetty-server/pom.xml index bf5c6d4fb02..92c03bc43bb 100644 --- a/jetty-aggregate/jetty-server/pom.xml +++ b/jetty-aggregate/jetty-server/pom.xml @@ -5,7 +5,6 @@ 7.5.2-SNAPSHOT 4.0.0 - org.eclipse.jetty.aggregate jetty-server Jetty :: Aggregate :: HTTP Server diff --git a/jetty-aggregate/jetty-servlet/pom.xml b/jetty-aggregate/jetty-servlet/pom.xml index 066c8733d8b..9f40904f08a 100644 --- a/jetty-aggregate/jetty-servlet/pom.xml +++ b/jetty-aggregate/jetty-servlet/pom.xml @@ -5,7 +5,6 @@ 7.5.2-SNAPSHOT 4.0.0 - org.eclipse.jetty.aggregate jetty-servlet Jetty :: Aggregate :: Servlet Server diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index 9413b7d44df..9db6c5896fa 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -5,7 +5,6 @@ 7.5.2-SNAPSHOT 4.0.0 - org.eclipse.jetty.aggregate jetty-webapp Jetty :: Aggregate :: WebApp Server From eab970e5c085f35a0420ede0623d706f0cb9f86b Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Fri, 9 Sep 2011 16:13:23 -0500 Subject: [PATCH 014/134] add and reformat the .gitignore --- .gitignore | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 56b34575555..11c793e1afe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,33 @@ -target/ +# eclipse .classpath .project .settings + +# maven +target/ */src/main/java/META-INF/ -.pmd + +# common junk *.log *.swp *.diff *.patch + +# intellij *.iml *.ipr *.iws .idea/ + +# Mac filesystem dust +/.DS_Store + +# pmd +.pmdruleset +.pmd + +# netbeans +/nbproject + +# vim +.*.sw[a-p] From c5e6378b846370eb5fd99e57de8a02f075f894bd Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 12 Sep 2011 13:14:09 +1000 Subject: [PATCH 015/134] 357338 Improve UTF-8 validation --- .../eclipse/jetty/util/Utf8Appendable.java | 157 ++++++++++-------- .../eclipse/jetty/util/Utf8StringBuffer.java | 8 +- .../eclipse/jetty/util/Utf8StringBuilder.java | 8 +- .../jetty/util/Utf8StringBufferTest.java | 8 +- .../jetty/util/Utf8StringBuilderTest.java | 58 +++++-- .../websocket/WebSocketConnectionD13.java | 20 ++- 6 files changed, 158 insertions(+), 101 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java index 6e2d73f20dd..b869f431b91 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java @@ -5,9 +5,11 @@ import java.util.IllegalFormatCodePointException; public abstract class Utf8Appendable { + private final char REPLACEMENT = '\ufffd'; protected final Appendable _appendable; - protected int _more; - protected int _bits; + protected int _expectedContinuationBytes; + protected int _codePoint; + protected int _minCodePoint; public Utf8Appendable(Appendable appendable) { @@ -63,91 +65,112 @@ public abstract class Utf8Appendable protected void appendByte(byte b) throws IOException { + // Check for invalid bytes + if (b==(byte)0xc0 || b==(byte)0xc1 || (int)b>=0xf5) + { + _appendable.append(REPLACEMENT); + _expectedContinuationBytes=0; + _codePoint=0; + throw new NotUtf8Exception(); + } + + // Is it plain ASCII? if (b>=0) { - if (_more>0) + // Were we expecting a continuation byte? + if (_expectedContinuationBytes>0) { - _appendable.append('?'); - _more=0; - _bits=0; + _appendable.append(REPLACEMENT); + _expectedContinuationBytes=0; + _codePoint=0; throw new NotUtf8Exception(); } else _appendable.append((char)(0x7f&b)); } - else if (_more==0) + // Else is this a start byte + else if (_expectedContinuationBytes==0) { - if ((b&0xc0)!=0xc0) + if ((b & 0xe0) == 0xc0) { - // 10xxxxxx - _appendable.append('?'); - _more=0; - _bits=0; - throw new NotUtf8Exception(); + //110xxxxx + _expectedContinuationBytes=1; + _codePoint=b&0x1f; + _minCodePoint=0x80; + } + else if ((b & 0xf0) == 0xe0) + { + //1110xxxx + _expectedContinuationBytes=2; + _codePoint=b&0x0f; + _minCodePoint=0x800; + } + else if ((b & 0xf8) == 0xf0) + { + //11110xxx + _expectedContinuationBytes=3; + _codePoint=b&0x07; + _minCodePoint=0x10000; + } + else if ((b & 0xfc) == 0xf8) + { + //111110xx + _expectedContinuationBytes=4; + _codePoint=b&0x03; + _minCodePoint=0x200000; + } + else if ((b & 0xfe) == 0xfc) + { + //1111110x + _expectedContinuationBytes=5; + _codePoint=b&0x01; + _minCodePoint=0x400000; } else - { - if ((b & 0xe0) == 0xc0) - { - //110xxxxx - _more=1; - _bits=b&0x1f; - } - else if ((b & 0xf0) == 0xe0) - { - //1110xxxx - _more=2; - _bits=b&0x0f; - } - else if ((b & 0xf8) == 0xf0) - { - //11110xxx - _more=3; - _bits=b&0x07; - } - else if ((b & 0xfc) == 0xf8) - { - //111110xx - _more=4; - _bits=b&0x03; - } - else if ((b & 0xfe) == 0xfc) - { - //1111110x - _more=5; - _bits=b&0x01; - } - else - { - throw new NotUtf8Exception(); - } + { + _appendable.append(REPLACEMENT); + _expectedContinuationBytes=0; + _codePoint=0; + throw new NotUtf8Exception(); } } + // else is this a continuation character + else if ((b&0xc0)==0x80) + { + // 10xxxxxx + _codePoint=(_codePoint<<6)|(b&0x3f); + + // was that the last continuation? + if (--_expectedContinuationBytes==0) + { + // If this a valid unicode point? + if (_codePoint<_minCodePoint || (_codePoint>=0xD800 && _codePoint<=0xDFFF)) + { + _appendable.append(REPLACEMENT); + _expectedContinuationBytes=0; + _codePoint=0; + throw new NotUtf8Exception(); + } + + _minCodePoint=0; + char[] chars = Character.toChars(_codePoint); + for (char c : chars) + _appendable.append(c); + } + } + // Else this is not a continuation character else { - if ((b&0xc0)==0xc0) - { // 11?????? - _appendable.append('?'); - _more=0; - _bits=0; - throw new NotUtf8Exception(); - } - else - { - // 10xxxxxx - _bits=(_bits<<6)|(b&0x3f); - if (--_more==0) - { - if (_bits>=0xD800 && _bits<=0xDFFF) - throw new NotUtf8Exception(); - _appendable.append(new String(Character.toChars(_bits))); - } - } + // ! 10xxxxxx + _appendable.append(REPLACEMENT); + _expectedContinuationBytes=0; + _codePoint=0; + throw new NotUtf8Exception(); } } - public static class NotUtf8Exception extends IllegalStateException + public static class NotUtf8Exception extends IllegalArgumentException { public NotUtf8Exception() { diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuffer.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuffer.java index 40de5306dce..bd730deabf3 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuffer.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuffer.java @@ -53,13 +53,13 @@ public class Utf8StringBuffer extends Utf8Appendable public void reset() { _buffer.setLength(0); - _more=0; - _bits=0; + _expectedContinuationBytes=0; + _codePoint=0; } public StringBuffer getStringBuffer() { - if (_more!=0) + if (_expectedContinuationBytes!=0) throw new NotUtf8Exception(); return _buffer; } @@ -67,7 +67,7 @@ public class Utf8StringBuffer extends Utf8Appendable @Override public String toString() { - if (_more!=0) + if (_expectedContinuationBytes!=0) throw new NotUtf8Exception(); return _buffer.toString(); } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuilder.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuilder.java index 7e4477163c3..541590f6424 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuilder.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuilder.java @@ -52,13 +52,13 @@ public class Utf8StringBuilder extends Utf8Appendable public void reset() { _buffer.setLength(0); - _more=0; - _bits=0; + _expectedContinuationBytes=0; + _codePoint=0; } public StringBuilder getStringBuilder() { - if (_more!=0) + if (_expectedContinuationBytes!=0) throw new NotUtf8Exception(); return _buffer; } @@ -66,7 +66,7 @@ public class Utf8StringBuilder extends Utf8Appendable @Override public String toString() { - if (_more!=0) + if (_expectedContinuationBytes!=0) throw new NotUtf8Exception(); return _buffer.toString(); } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java index 5b0c3afae54..9c44625e8fe 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java @@ -48,9 +48,9 @@ public class Utf8StringBufferTest buffer.toString(); assertTrue(false); } - catch(IllegalStateException e) + catch(Utf8Appendable.NotUtf8Exception e) { - assertTrue(e.toString().indexOf("!UTF-8")>=0); + assertTrue(true); } } @@ -70,11 +70,11 @@ public class Utf8StringBufferTest buffer.append(bytes[i]); assertTrue(false); } - catch(IllegalStateException e) + catch(Utf8Appendable.NotUtf8Exception e) { assertTrue(e.toString().indexOf("!UTF-8")>=0); } - assertEquals("abc?",buffer.toString()); + assertEquals("abc\ufffd",buffer.toString()); } @Test diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java index 9cfca551290..bfa0cccd870 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java @@ -25,19 +25,44 @@ public class Utf8StringBuilderTest public void testInvalid() throws Exception { - Utf8StringBuilder buffer = new Utf8StringBuilder(); - buffer.append((byte)0xED); - buffer.append((byte)0xA0); - try - { - buffer.append((byte)0x80); - assertTrue(false); - } - catch(Utf8Appendable.NotUtf8Exception e) - { - assertTrue(true); - } + String[] invalids = { + "c0af", + "EDA080", + "f08080af", + "f8808080af", + "e080af", + "F4908080", + "fbbfbfbfbf" + }; + for (String i : invalids) + { + byte[] bytes = TypeUtil.fromHexString(i); + + /* Test what JVM does + try + { + String s = new String(bytes,0,bytes.length,"UTF-8"); + System.err.println(i+": "+s); + } + catch(Exception e) + { + System.err.println(i+": "+e); + } + */ + + try + { + Utf8StringBuilder buffer = new Utf8StringBuilder(); + buffer.append(bytes,0,bytes.length); + + assertEquals(i,"not expected",buffer.toString()); + } + catch(IllegalArgumentException e) + { + assertTrue(i,true); + } + } } @Test @@ -69,7 +94,7 @@ public class Utf8StringBuilderTest buffer.toString(); assertTrue(false); } - catch(IllegalStateException e) + catch(Utf8Appendable.NotUtf8Exception e) { assertTrue(e.toString().indexOf("!UTF-8")>=0); } @@ -91,11 +116,11 @@ public class Utf8StringBuilderTest buffer.append(bytes[i]); assertTrue(false); } - catch(IllegalStateException e) + catch(Utf8Appendable.NotUtf8Exception e) { - assertTrue(e.toString().indexOf("!UTF-8")>=0); + assertTrue(true); } - assertEquals("abc?", buffer.toString()); + assertEquals("abc\ufffd", buffer.toString()); } @@ -106,6 +131,7 @@ public class Utf8StringBuilderTest String source="\uD842\uDF9F"; byte[] bytes=source.getBytes("UTF-8"); + // System.err.println(TypeUtil.toHexString(bytes)); String jvmcheck = new String(bytes,0,bytes.length,"UTF-8"); assertEquals(source,jvmcheck); diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java index bcda94485a8..9ac938c6e30 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java @@ -30,6 +30,7 @@ import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.util.B64Code; import org.eclipse.jetty.util.StringUtil; +import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.Utf8Appendable; import org.eclipse.jetty.util.Utf8StringBuilder; import org.eclipse.jetty.util.log.Log; @@ -628,6 +629,11 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc { boolean lastFrame = isLastFrame(flags); + System.err.println("flags "+flags); + System.err.println("opcode "+opcode); + System.err.println("buffer "+TypeUtil.toHexString(buffer.asArray())); + + synchronized(WebSocketConnectionD13.this) { // Ignore incoming after a close @@ -827,19 +833,21 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc return; } } + catch(ThreadDeath th) + { + throw th; + } catch(Utf8Appendable.NotUtf8Exception notUtf8) { LOG.warn("{} for {}",notUtf8,_endp); LOG.debug(notUtf8); errorClose(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,"Invalid UTF-8"); } - catch(ThreadDeath th) + catch(Throwable probablyNotUtf8) { - throw th; - } - catch(Throwable th) - { - LOG.warn(th); + LOG.warn("{} for {}",probablyNotUtf8,_endp); + LOG.debug(probablyNotUtf8); + errorClose(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,"Invalid Payload: "+probablyNotUtf8); } } From 55d229e73ccd5fd39c30f76b971e482bc906c1e2 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 13 Sep 2011 00:38:08 +1000 Subject: [PATCH 016/134] 357338 remove debug --- .../org/eclipse/jetty/websocket/WebSocketConnectionD13.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java index 9ac938c6e30..813b64220eb 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD13.java @@ -628,11 +628,6 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc public void onFrame(final byte flags, final byte opcode, final Buffer buffer) { boolean lastFrame = isLastFrame(flags); - - System.err.println("flags "+flags); - System.err.println("opcode "+opcode); - System.err.println("buffer "+TypeUtil.toHexString(buffer.asArray())); - synchronized(WebSocketConnectionD13.this) { From 9c43e04bb4add2e4f3d4b1b07c70463e90be56ee Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 12 Sep 2011 21:01:08 +0200 Subject: [PATCH 017/134] Guarding against NPE in case of concurrent stop(). --- .../eclipse/jetty/io/nio/SelectorManager.java | 154 +++++++++--------- 1 file changed, 78 insertions(+), 76 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index 5b80a68d9df..2a01ba3d2a4 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -4,11 +4,11 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.io.nio; @@ -30,7 +30,6 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; - import org.eclipse.jetty.io.ConnectedEndPoint; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; @@ -55,7 +54,7 @@ import org.eclipse.jetty.util.thread.Timeout.Task; public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable { public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio"); - + // TODO Tune these by approx system speed. private static final int __JVMBUG_THRESHHOLD=Integer.getInteger("org.eclipse.jetty.io.nio.JVMBUG_THRESHHOLD",0).intValue(); private static final int __MONITOR_PERIOD=Integer.getInteger("org.eclipse.jetty.io.nio.MONITOR_PERIOD",1000).intValue(); @@ -63,7 +62,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa private static final int __BUSY_PAUSE=Integer.getInteger("org.eclipse.jetty.io.nio.BUSY_PAUSE",50).intValue(); private static final int __BUSY_KEY=Integer.getInteger("org.eclipse.jetty.io.nio.BUSY_KEY",-1).intValue(); private static final int __IDLE_TICK=Integer.getInteger("org.eclipse.jetty.io.nio.IDLE_TICK",400).intValue(); - + private int _maxIdleTime; private int _lowResourcesMaxIdleTime; private long _lowResourcesConnections; @@ -72,7 +71,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa private volatile int _set; private boolean _deferringInterestedOps0=true; private int _selectorPriorityDelta=0; - + /* ------------------------------------------------------------ */ /** * @param maxIdleTime The maximum period in milli seconds that a connection may be idle before it is closed. @@ -82,18 +81,18 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { _maxIdleTime=(int)maxIdleTime; } - + /* ------------------------------------------------------------ */ /** * @param selectSets number of select sets to create */ public void setSelectSets(int selectSets) { - long lrc = _lowResourcesConnections * _selectSets; + long lrc = _lowResourcesConnections * _selectSets; _selectSets=selectSets; _lowResourcesConnections=lrc/_selectSets; } - + /* ------------------------------------------------------------ */ /** * @return the max idle time @@ -102,7 +101,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { return _maxIdleTime; } - + /* ------------------------------------------------------------ */ /** * @return the number of select sets in use @@ -114,14 +113,14 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa /* ------------------------------------------------------------ */ /** - * @param i + * @param i * @return The select set */ public SelectSet getSelectSet(int i) { return _selectSet[i]; } - + /* ------------------------------------------------------------ */ /** Register a channel * @param channel @@ -132,8 +131,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa // The ++ increment here is not atomic, but it does not matter. // so long as the value changes sometimes, then connections will // be distributed over the available sets. - - int s=_set++; + + int s=_set++; s=s%_selectSets; SelectSet[] sets=_selectSet; if (sets!=null) @@ -144,7 +143,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa } } - + /* ------------------------------------------------------------ */ /** Register a channel * @param channel @@ -154,8 +153,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa // The ++ increment here is not atomic, but it does not matter. // so long as the value changes sometimes, then connections will // be distributed over the available sets. - - int s=_set++; + + int s=_set++; s=s%_selectSets; SelectSet[] sets=_selectSet; if (sets!=null) @@ -165,14 +164,14 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa set.wakeup(); } } - + /* ------------------------------------------------------------ */ /** Register a {@link ServerSocketChannel} * @param acceptChannel */ public void register(ServerSocketChannel acceptChannel) { - int s=_set++; + int s=_set++; s=s%_selectSets; SelectSet set=_selectSet[s]; set.addChange(acceptChannel); @@ -196,8 +195,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { _selectorPriorityDelta=delta; } - - + + /* ------------------------------------------------------------ */ /** * @return the lowResourcesConnections @@ -237,7 +236,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { _lowResourcesMaxIdleTime=(int)lowResourcesMaxIdleTime; } - + /* ------------------------------------------------------------------------------- */ public abstract boolean dispatch(Runnable task); @@ -254,7 +253,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa _selectSet[i]= new SelectSet(i); super.doStart(); - + // start a thread to Select for (int i=0;i _changes = new ConcurrentLinkedQueue(); - + private volatile Selector _selector; - + private volatile Thread _selecting; private int _jvmBug; private int _selects; @@ -404,7 +403,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa private int _jvmFix2; private volatile long _idleTick; private ConcurrentMap _endPoints = new ConcurrentHashMap(); - + /* ------------------------------------------------------------ */ SelectSet(int acceptorID) throws Exception { @@ -420,7 +419,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa _monitorNext=_monitorStart+__MONITOR_PERIOD; _log=_monitorStart+60000; } - + /* ------------------------------------------------------------ */ public void addChange(Object change) { @@ -429,7 +428,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa /* ------------------------------------------------------------ */ public void addChange(SelectableChannel channel, Object att) - { + { if (att==null) addChange(channel); else if (att instanceof EndPoint) @@ -437,11 +436,11 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa else addChange(new ChannelAndAttachment(channel,att)); } - + /* ------------------------------------------------------------ */ /** * Select and dispatch tasks found from changes and the selector. - * + * * @throws IOException */ public void doSelect() throws IOException @@ -450,6 +449,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { _selecting=Thread.currentThread(); final Selector selector=_selector; + // Stopped concurrently ? + if (selector == null) + return; // Make any key changes required Object change; @@ -458,7 +460,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { Channel ch=null; SelectionKey key=null; - + try { if (change instanceof EndPoint) @@ -475,7 +477,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa final SelectableChannel channel=asc._channel; ch=channel; final Object att = asc._attachment; - + if ((channel instanceof SocketChannel) && ((SocketChannel)channel).isConnected()) { key = channel.register(selector,SelectionKey.OP_READ,att); @@ -517,7 +519,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { if (e instanceof ThreadDeath) throw (ThreadDeath)e; - + if (isRunning()) LOG.warn(e); else @@ -540,7 +542,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa _selects++; long now=System.currentTimeMillis(); - + // if no immediate things to do if (selected==0 && selector.selectedKeys().isEmpty()) { @@ -562,7 +564,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa _timeout.setNow(now); long to_next_timeout=_timeout.getTimeToNext(); - long wait = _changes.size()==0?__IDLE_TICK:0L; + long wait = _changes.size()==0?__IDLE_TICK:0L; if (wait > 0 && to_next_timeout >= 0 && wait > to_next_timeout) wait = to_next_timeout; @@ -574,21 +576,21 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa _selects++; now = System.currentTimeMillis(); _timeout.setNow(now); - + if (__JVMBUG_THRESHHOLD>0) checkJvmBugs(before, now, wait, selected); } } - + // have we been destroyed while sleeping if (_selector==null || !selector.isOpen()) return; // Look for things to do for (SelectionKey key: selector.selectedKeys()) - { + { SocketChannel channel=null; - + try { if (!key.isValid()) @@ -641,7 +643,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa SelectChannelEndPoint endpoint = createEndPoint(channel,key); key.attach(endpoint); if (key.isReadable()) - endpoint.schedule(); + endpoint.schedule(); } key = null; } @@ -665,15 +667,15 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { LOG.debug(e2); } - + if (key != null && !(key.channel() instanceof ServerSocketChannel) && key.isValid()) key.cancel(); } } - + // Everything always handled selector.selectedKeys().clear(); - + now=System.currentTimeMillis(); _timeout.setNow(now); Task task = _timeout.expired(); @@ -688,11 +690,11 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa if (now-_idleTick>__IDLE_TICK) { _idleTick=now; - + final long idle_now=((_lowResourcesConnections>0 && selector.keys().size()>_lowResourcesConnections)) ?(now+_maxIdleTime-_lowResourcesMaxIdleTime) :now; - + dispatch(new Runnable() { public void run() @@ -721,7 +723,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa _selecting=null; } } - + /* ------------------------------------------------------------ */ private void checkJvmBugs(long before, long now, long wait, int selected) throws IOException @@ -729,7 +731,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa Selector selector = _selector; if (selector==null) return; - + // Look for JVM bugs over a monitor period. // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6403933 // http://bugs.sun.com/view_bug.do?bug_id=6693490 @@ -748,7 +750,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa if (now>_log) { - if (_paused>0) + if (_paused>0) LOG.debug(this+" Busy selector - injecting delay "+_paused+" times"); if (_jvmFix2>0) @@ -842,9 +844,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa _busyKey=busy; } } - + /* ------------------------------------------------------------ */ - private void renewSelector() + private void renewSelector() { try { @@ -876,7 +878,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa throw new RuntimeException("recreating selector",e); } } - + /* ------------------------------------------------------------ */ public SelectorManager getManager() { @@ -891,9 +893,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa /* ------------------------------------------------------------ */ /** - * @param task The task to timeout. If it implements Runnable, then + * @param task The task to timeout. If it implements Runnable, then * expired will be called from a dispatched thread. - * + * * @param timeoutMs */ public void scheduleTimeout(Timeout.Task task, long timeoutMs) @@ -902,7 +904,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa throw new IllegalArgumentException("!Runnable"); _timeout.schedule(task, timeoutMs); } - + /* ------------------------------------------------------------ */ public void cancelTimeout(Timeout.Task task) { @@ -927,20 +929,20 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa renewSelector(); } }); - + renewSelector(); } } - + /* ------------------------------------------------------------ */ private SelectChannelEndPoint createEndPoint(SocketChannel channel, SelectionKey sKey) throws IOException { SelectChannelEndPoint endp = newEndPoint(channel,this,sKey); - endPointOpened(endp); + endPointOpened(endp); _endPoints.put(endp,this); return endp; } - + /* ------------------------------------------------------------ */ public void destroyEndPoint(SelectChannelEndPoint endp) { @@ -953,11 +955,11 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { return _selector; } - + /* ------------------------------------------------------------ */ void stop() throws Exception { - // Spin for a while waiting for selector to complete + // Spin for a while waiting for selector to complete // to avoid unneccessary closed channel exceptions try { @@ -994,8 +996,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa } } } - - + + _timeout.cancelAll(); try { @@ -1006,7 +1008,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa catch (IOException e) { LOG.ignore(e); - } + } _selector=null; } } @@ -1021,9 +1023,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa public void dump(Appendable out, String indent) throws IOException { out.append(String.valueOf(this)).append(" id=").append(String.valueOf(_setID)).append("\n"); - + Thread selecting = _selecting; - + Object where = "not selecting"; StackTraceElement[] trace =selecting==null?null:selecting.getStackTrace(); if (trace!=null) @@ -1039,9 +1041,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa Selector selector=_selector; final ArrayList dump = new ArrayList(selector.keys().size()*2); dump.add(where); - + final CountDownLatch latch = new CountDownLatch(1); - + addChange(new Runnable(){ public void run() { @@ -1049,7 +1051,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa latch.countDown(); } }); - + try { latch.await(5,TimeUnit.SECONDS); @@ -1081,7 +1083,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { final SelectableChannel _channel; final Object _attachment; - + public ChannelAndAttachment(SelectableChannel channel, Object attachment) { super(); @@ -1101,12 +1103,12 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { _deferringInterestedOps0 = deferringInterestedOps0; } - + /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ private interface ChangeTask extends Runnable {} - + } From fce4192fd95b715cae559c693e08d7a5f511c59b Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 12 Sep 2011 15:04:59 -0700 Subject: [PATCH 018/134] 353509 - jetty-client unit tests are running too long --- .../eclipse/jetty/client/HttpExchange.java | 2 + .../AbstractHttpExchangeCancelTest.java | 7 +- .../client/AsyncSslHttpExchangeTest.java | 22 +- ...ernalKeyStoreAsyncSslHttpExchangeTest.java | 28 +- .../jetty/client/HttpExchangeTest.java | 328 +++++++----------- .../jetty/client/SslHttpExchangeTest.java | 56 +-- .../AbstractSslServerAndClientCreator.java | 125 +++++++ .../AsyncSslServerAndClientCreator.java | 27 ++ ...eyStoreAsyncSslServerAndClientCreator.java | 27 ++ .../HttpServerAndClientCreator.java | 110 ++++++ .../helperClasses/ServerAndClientCreator.java | 11 + .../SslServerAndClientCreator.java | 19 + 12 files changed, 472 insertions(+), 290 deletions(-) create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ExternalKeyStoreAsyncSslServerAndClientCreator.java create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ServerAndClientCreator.java create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/SslServerAndClientCreator.java diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java index e97cc611654..f5d15028b43 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java @@ -571,6 +571,8 @@ public class HttpExchange if (uri.isOpaque()) throw new IllegalArgumentException("Opaque URI: "+uri); + + LOG.info("URI = {}", uri.toASCIIString()); String scheme = uri.getScheme(); int port = uri.getPort(); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java index cb5812780a2..c1d5c3da2c1 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java @@ -14,9 +14,7 @@ package org.eclipse.jetty.client; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.IOException; import java.net.SocketTimeoutException; @@ -34,7 +32,6 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.StdErrLog; import org.junit.After; import org.junit.Before; @@ -45,8 +42,6 @@ import org.junit.Test; */ public abstract class AbstractHttpExchangeCancelTest { - private static final Logger LOG = Log.getLogger(AbstractHttpExchangeCancelTest.class); - private Server server; private Connector connector; diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java index f5ac43dc403..2426cdfd79b 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java @@ -13,19 +13,19 @@ package org.eclipse.jetty.client; +import org.eclipse.jetty.client.helperClasses.AsyncSslServerAndClientCreator; +import org.eclipse.jetty.client.helperClasses.ServerAndClientCreator; +import org.junit.BeforeClass; + public class AsyncSslHttpExchangeTest extends SslHttpExchangeTest { - @Override - public void setUp() throws Exception + private static ServerAndClientCreator serverAndClientCreator = new AsyncSslServerAndClientCreator(); + + @BeforeClass + public static void setUpOnce() throws Exception { - _scheme="https"; - startServer(); - _httpClient=new HttpClient(); - _httpClient.setIdleTimeout(2000); - _httpClient.setTimeout(2500); - _httpClient.setConnectTimeout(1000); - _httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); - _httpClient.setMaxConnectionsPerAddress(2); - _httpClient.start(); + _server = serverAndClientCreator.createServer(); + _httpClient = serverAndClientCreator.createClient(3000L,3500L,2000); + _port = _server.getConnectors()[0].getLocalPort(); } } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java index 445947e3534..f3ccca1edab 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java @@ -13,28 +13,22 @@ package org.eclipse.jetty.client; -import java.io.FileInputStream; - -import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.client.helperClasses.ExternalKeyStoreAsyncSslServerAndClientCreator; +import org.eclipse.jetty.client.helperClasses.ServerAndClientCreator; +import org.junit.BeforeClass; import org.junit.Test; public class ExternalKeyStoreAsyncSslHttpExchangeTest extends SslHttpExchangeTest { - @Override - public void setUp() throws Exception + private static ServerAndClientCreator serverAndClientCreator = new ExternalKeyStoreAsyncSslServerAndClientCreator(); + + @BeforeClass + public static void setUpOnce() throws Exception { - _scheme = "https"; - startServer(); - _httpClient = new HttpClient(); - _httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); - _httpClient.setMaxConnectionsPerAddress(2); - - String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); - - _httpClient.setKeyStoreInputStream(new FileInputStream(keystore)); - _httpClient.setKeyStorePassword("storepwd"); - _httpClient.setKeyManagerPassword("keypwd"); - _httpClient.start(); + _scheme="https://"; + _server = serverAndClientCreator.createServer(); + _httpClient = serverAndClientCreator.createClient(3000L,3500L,2000); + _port = _server.getConnectors()[0].getLocalPort(); } @Override diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index 09de4467204..7490f0cfc5e 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -13,14 +13,9 @@ package org.eclipse.jetty.client; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.matchers.JUnitMatchers.containsString; +import static org.junit.Assert.*; +import static org.junit.matchers.JUnitMatchers.*; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -30,13 +25,10 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; 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.helperClasses.HttpServerAndClientCreator; +import org.eclipse.jetty.client.helperClasses.ServerAndClientCreator; import org.eclipse.jetty.client.security.ProxyAuthorization; import org.eclipse.jetty.http.HttpFields; -import org.eclipse.jetty.http.HttpHeaders; import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.Buffer; @@ -44,17 +36,11 @@ import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.nio.DirectNIOBuffer; -import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.AbstractHandler; -import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.toolchain.test.Stress; -import org.eclipse.jetty.util.IO; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; -import org.junit.After; -import org.junit.Before; +import org.eclipse.jetty.util.component.AbstractLifeCycle; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; /* ------------------------------------------------------------ */ @@ -63,37 +49,42 @@ import org.junit.Test; */ public class HttpExchangeTest { - private static final Logger LOG = Log.getLogger(HttpExchangeTest.class); - - protected int _maxConnectionsPerAddress = 2; - protected String _scheme = "http"; - protected Server _server; - protected int _port; - protected HttpClient _httpClient; - protected Connector _connector; - protected AtomicInteger _count = new AtomicInteger(); - - /* ------------------------------------------------------------ */ - @Before - public void setUp() throws Exception + protected static int _maxConnectionsPerAddress = 2; + protected static String _scheme = "http"; + protected static Server _server; + protected static int _port; + protected static HttpClient _httpClient; + protected static AtomicInteger _count = new AtomicInteger(); + protected static ServerAndClientCreator serverAndClientCreator = new HttpServerAndClientCreator(); + + protected static URI getBaseURI() { - startServer(); - _httpClient=new HttpClient(); - _httpClient.setIdleTimeout(3000); - _httpClient.setTimeout(3500); - _httpClient.setConnectTimeout(2000); - _httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); - _httpClient.setMaxConnectionsPerAddress(_maxConnectionsPerAddress); - _httpClient.start(); + return URI.create(_scheme + "://localhost:" + _port + "/"); } /* ------------------------------------------------------------ */ - @After - public void tearDown() throws Exception + @BeforeClass + public static void setUpOnce() throws Exception + { + _scheme = "http"; + _server = serverAndClientCreator.createServer(); + _httpClient = serverAndClientCreator.createClient(3000L,3500L,2000); + _port = _server.getConnectors()[0].getLocalPort(); + } + + /* ------------------------------------------------------------ */ + @AfterClass + public static void tearDownOnce() throws Exception { _httpClient.stop(); - Thread.sleep(500); - stopServer(); + long startTime = System.currentTimeMillis(); + while (!_httpClient.getState().equals(AbstractLifeCycle.STOPPED)) + { + if (System.currentTimeMillis() - startTime > 1000) + break; + Thread.sleep(5); + } + _server.stop(); } /* ------------------------------------------------------------ */ @@ -110,7 +101,7 @@ public class HttpExchangeTest { sender(1,false); sender(1,true); - + if (Stress.isEnabled()) { sender(100,false); @@ -128,44 +119,44 @@ public class HttpExchangeTest /* ------------------------------------------------------------ */ /** * Test sending data through the exchange. - * + * * @throws IOException */ - public void sender(final int nb,final boolean close) throws Exception + public void sender(final int nb, final boolean close) throws Exception { _count.set(0); - final CountDownLatch complete=new CountDownLatch(nb); - final CountDownLatch latch=new CountDownLatch(nb); + final CountDownLatch complete = new CountDownLatch(nb); + final CountDownLatch latch = new CountDownLatch(nb); HttpExchange[] httpExchange = new HttpExchange[nb]; - long start=System.currentTimeMillis(); - for (int i=0; i")); _httpClient.send(httpExchange); @@ -288,12 +279,14 @@ public class HttpExchangeTest for (int i=0;i<10;i++) { ContentExchange httpExchange=new ContentExchange(); - httpExchange.setURI(new URI(_scheme, null, "localhost", _port, "/", "i="+i, null)); + URI uri = getBaseURI().resolve("?i=" + i); + httpExchange.setURI(uri); httpExchange.setMethod(HttpMethods.GET); _httpClient.send(httpExchange); int status = httpExchange.waitForDone(); //httpExchange.waitForStatus(HttpExchange.STATUS_COMPLETED); String result=httpExchange.getResponseContent(); + assertNotNull("Should have received response content", result); assertEquals("i="+i,0,result.indexOf("")); assertEquals("i="+i,result.length()-10,result.indexOf("")); assertEquals(HttpExchange.STATUS_COMPLETED, status); @@ -308,17 +301,16 @@ public class HttpExchangeTest for (int i=0;i<10;i++) { ContentExchange httpExchange=new ContentExchange(); - httpExchange.setURL(_scheme+"://localhost:"+_port+"/?i="+i); + URI uri = getBaseURI().resolve("?i=" + i); + httpExchange.setURI(uri); httpExchange.setMethod(HttpMethods.GET); _httpClient.send(httpExchange); int status = httpExchange.waitForDone(); assertNotNull(httpExchange.getLocalAddress()); - //System.out.println("Local Address: " + httpExchange.getLocalAddress()); - - //httpExchange.waitForStatus(HttpExchange.STATUS_COMPLETED); String result=httpExchange.getResponseContent(); + assertNotNull("Should have received response content", result); assertEquals("i="+i,0,result.indexOf("")); assertEquals("i="+i,result.length()-10,result.indexOf("")); assertEquals(HttpExchange.STATUS_COMPLETED, status); @@ -355,7 +347,7 @@ public class HttpExchangeTest throwable.set(x); } }; - httpExchange.setURL(_scheme+"://localhost:"+_port+"/"); + httpExchange.setURI(getBaseURI()); httpExchange.setMethod("SLEEP"); _httpClient.send(httpExchange); new Thread() @@ -394,7 +386,7 @@ public class HttpExchangeTest niobuf.put(bytes); } - httpExchange.setURL(_scheme+"://localhost:"+_port+"/"); + httpExchange.setURI(getBaseURI()); httpExchange.setMethod(HttpMethods.POST); httpExchange.setRequestContentType("application/data"); httpExchange.setRequestContent(babuf); @@ -407,7 +399,7 @@ public class HttpExchangeTest assertEquals(babuf.length(),result.length()); httpExchange.reset(); - httpExchange.setURL(_scheme+"://localhost:"+_port+"/"); + httpExchange.setURI(getBaseURI()); httpExchange.setMethod(HttpMethods.POST); httpExchange.setRequestContentType("application/data"); httpExchange.setRequestContent(niobuf); @@ -426,7 +418,7 @@ public class HttpExchangeTest { }; - httpExchange.setURL(_scheme+"://localhost:"+_port); + httpExchange.setURI(getBaseURI()); httpExchange.setMethod(HttpMethods.POST); final String data="012345678901234567890123456789012345678901234567890123456789"; @@ -447,7 +439,7 @@ public class HttpExchangeTest @Override public int read(byte[] b, int off, int len) throws IOException { - if (_index>=data.length()) + if (_index >= data.length()) return -1; try @@ -458,28 +450,28 @@ public class HttpExchangeTest { e.printStackTrace(); } - - int l=0; - while (l<5 && _index=0) + while ((len = in.read(buffer)) >= 0) { out.write(buffer,0,len); } } catch (EofException e) { - System.err.println("HttpExchangeTest#copyStream: "+e); + System.err.println("HttpExchangeTest#copyStream: " + e); } catch (IOException e) { e.printStackTrace(); } } - - /* ------------------------------------------------------------ */ - protected void newServer() throws Exception - { - _server=new Server(); - _server.setGracefulShutdown(500); - _connector=new SelectChannelConnector(); - - _connector.setMaxIdleTime(3000000); - - _connector.setPort(0); - _server.setConnectors(new Connector[] { _connector }); - } - - /* ------------------------------------------------------------ */ - protected void startServer() throws Exception - { - newServer(); - _server.setHandler(new AbstractHandler() - { - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException - { - int i=0; - try - { - baseRequest.setHandled(true); - response.setStatus(200); - _count.incrementAndGet(); - - if (request.getServerName().equals("jetty.eclipse.org")) - { - response.getOutputStream().println("Proxy request: "+request.getRequestURL()); - response.getOutputStream().println(request.getHeader(HttpHeaders.PROXY_AUTHORIZATION)); - } - else if (request.getMethod().equalsIgnoreCase("GET")) - { - response.getOutputStream().println(""); - for (; i<100; i++) - { - response.getOutputStream().println(" "+i+""); - } - else if (request.getMethod().equalsIgnoreCase("OPTIONS")) - { - if ("*".equals(target)) - { - response.setContentLength(0); - response.setHeader("Allow","GET,HEAD,POST,PUT,DELETE,MOVE,OPTIONS,TRACE"); - } - } - else if (request.getMethod().equalsIgnoreCase("SLEEP")) - { - Thread.sleep(10000); - } - else - { - response.setContentType(request.getContentType()); - int size=request.getContentLength(); - ByteArrayOutputStream bout = new ByteArrayOutputStream(size>0?size:32768); - IO.copy(request.getInputStream(),bout); - response.getOutputStream().write(bout.toByteArray()); - } - } - catch(InterruptedException e) - { - LOG.debug(e); - } - catch(IOException e) - { - e.printStackTrace(); - throw e; - } - catch(Throwable e) - { - e.printStackTrace(); - throw new ServletException(e); - } - finally - { - } - } - }); - _server.start(); - _port=_connector.getLocalPort(); - } - - /* ------------------------------------------------------------ */ - private void stopServer() throws Exception - { - _server.stop(); - } - } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java index 6ea97bc5aa4..c7c8b887eb8 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java @@ -13,67 +13,35 @@ package org.eclipse.jetty.client; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.*; -import org.eclipse.jetty.http.ssl.SslContextFactory; +import org.eclipse.jetty.client.helperClasses.ServerAndClientCreator; +import org.eclipse.jetty.client.helperClasses.SslServerAndClientCreator; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ssl.SslSocketConnector; -import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.toolchain.test.Stress; import org.junit.Assume; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; /** * Functional testing for HttpExchange. - * - * - * */ public class SslHttpExchangeTest extends HttpExchangeTest { + protected static ServerAndClientCreator serverAndClientCreator = new SslServerAndClientCreator(); + /* ------------------------------------------------------------ */ - @Before - @Override - public void setUp() throws Exception + @BeforeClass + public static void setUpOnce() throws Exception { _scheme="https"; - startServer(); - _httpClient=new HttpClient(); - _httpClient.setIdleTimeout(2000); - _httpClient.setTimeout(2500); - _httpClient.setConnectTimeout(1000); - _httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); - _httpClient.setConnectorType(HttpClient.CONNECTOR_SOCKET); - _httpClient.setMaxConnectionsPerAddress(2); - _httpClient.start(); + _server = serverAndClientCreator.createServer(); + _httpClient = serverAndClientCreator.createClient(3000L,3500L,2000); + Connector[] connectors = _server.getConnectors(); + _port = connectors[0].getLocalPort(); } - /* ------------------------------------------------------------ */ - @Override - protected void newServer() - { - _server = new Server(); - //SslSelectChannelConnector connector = new SslSelectChannelConnector(); - SslSocketConnector connector = new SslSocketConnector(); - - String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); - - connector.setPort(0); - SslContextFactory cf = connector.getSslContextFactory(); - cf.setKeyStore(keystore); - cf.setKeyStorePassword("storepwd"); - cf.setKeyManagerPassword("keypwd"); - connector.setAllowRenegotiate(true); - - _server.setConnectors(new Connector[] - { connector }); - _connector=connector; - } - /* ------------------------------------------------------------ */ private void IgnoreTestOnBuggyIBM() { diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java new file mode 100644 index 00000000000..3d230ff2a29 --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java @@ -0,0 +1,125 @@ +// ======================================================================== +// Copyright (c) 2009-2009 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.helperClasses; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.http.HttpHeaders; +import org.eclipse.jetty.http.ssl.SslContextFactory; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.handler.AbstractHandler; +import org.eclipse.jetty.server.ssl.SslSocketConnector; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; + + +/* ------------------------------------------------------------ */ +/** + */ +public abstract class AbstractSslServerAndClientCreator implements ServerAndClientCreator +{ + private static final Logger LOG = Log.getLogger(AbstractSslServerAndClientCreator.class); + + /* ------------------------------------------------------------ */ + public Server createServer() throws Exception + { + Server server = new Server(); + // SslSelectChannelConnector connector = new SslSelectChannelConnector(); + SslSocketConnector connector = new SslSocketConnector(); + + String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); + + connector.setPort(0); + SslContextFactory cf = connector.getSslContextFactory(); + cf.setKeyStore(keystore); + cf.setKeyStorePassword("storepwd"); + cf.setKeyManagerPassword("keypwd"); + connector.setAllowRenegotiate(true); + + server.setConnectors(new Connector[]{ connector }); + server.setHandler(new AbstractHandler() + { + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, + ServletException + { + int i = 0; + try + { + baseRequest.setHandled(true); + response.setStatus(200); + + if (request.getServerName().equals("jetty.eclipse.org")) + { + response.getOutputStream().println("Proxy request: " + request.getRequestURL()); + response.getOutputStream().println(request.getHeader(HttpHeaders.PROXY_AUTHORIZATION)); + } + else if (request.getMethod().equalsIgnoreCase("GET")) + { + response.getOutputStream().println(""); + for (; i < 100; i++) + { + response.getOutputStream().println(" " + i + ""); + } + else if (request.getMethod().equalsIgnoreCase("SLEEP")) + { + Thread.sleep(10000); + } + else + { + response.setContentType(request.getContentType()); + int size = request.getContentLength(); + ByteArrayOutputStream bout = new ByteArrayOutputStream(size > 0?size:32768); + IO.copy(request.getInputStream(),bout); + response.getOutputStream().write(bout.toByteArray()); + } + } + catch (InterruptedException e) + { + LOG.debug(e); + } + catch (IOException e) + { + LOG.warn(e); + throw e; + } + catch (Throwable e) + { + LOG.warn(e); + throw new ServletException(e); + } + finally + { + } + } + }); + server.start(); + return server; + } + + +} diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java new file mode 100644 index 00000000000..564713fc65b --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java @@ -0,0 +1,27 @@ +package org.eclipse.jetty.client.helperClasses; + +import java.io.FileInputStream; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; + +public class AsyncSslServerAndClientCreator extends AbstractSslServerAndClientCreator implements ServerAndClientCreator +{ + + /* ------------------------------------------------------------ */ + public HttpClient createClient(long idleTimeout, long timeout, int connectTimeout) throws Exception + { + HttpClient httpClient = new HttpClient(); + httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.setMaxConnectionsPerAddress(2); + + String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); + + httpClient.setKeyStoreInputStream(new FileInputStream(keystore)); + httpClient.setKeyStorePassword("storepwd"); + httpClient.setKeyManagerPassword("keypwd"); + httpClient.start(); + return httpClient; + } + +} diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ExternalKeyStoreAsyncSslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ExternalKeyStoreAsyncSslServerAndClientCreator.java new file mode 100644 index 00000000000..584f4b1a64b --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ExternalKeyStoreAsyncSslServerAndClientCreator.java @@ -0,0 +1,27 @@ +package org.eclipse.jetty.client.helperClasses; + +import java.io.FileInputStream; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; + +public class ExternalKeyStoreAsyncSslServerAndClientCreator extends AbstractSslServerAndClientCreator implements ServerAndClientCreator +{ + + public HttpClient createClient(long idleTimeout, long timeout, int connectTimeout) throws Exception + { + HttpClient httpClient = new HttpClient(); + httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.setMaxConnectionsPerAddress(2); + + String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); + + httpClient.setKeyStoreInputStream(new FileInputStream(keystore)); + httpClient.setKeyStorePassword("storepwd"); + httpClient.setKeyManagerPassword("keypwd"); + httpClient.start(); + return httpClient; + } + + +} diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java new file mode 100644 index 00000000000..21019ff5b45 --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java @@ -0,0 +1,110 @@ +package org.eclipse.jetty.client.helperClasses; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.http.HttpHeaders; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.handler.AbstractHandler; +import org.eclipse.jetty.server.nio.SelectChannelConnector; +import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; + +public class HttpServerAndClientCreator implements ServerAndClientCreator +{ + private static final Logger LOG = Log.getLogger(HttpServerAndClientCreator.class); + + public HttpClient createClient(long idleTimeout, long timeout, int connectTimeout) throws Exception + { + HttpClient httpClient = new HttpClient(); + httpClient.setIdleTimeout(idleTimeout); + httpClient.setTimeout(timeout); + httpClient.setConnectTimeout(connectTimeout); + httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.setMaxConnectionsPerAddress(2); + httpClient.start(); + return httpClient; + } + + public Server createServer() throws Exception + { + Server _server = new Server(); + _server.setGracefulShutdown(500); + Connector _connector = new SelectChannelConnector(); + + _connector.setMaxIdleTime(3000000); + + _connector.setPort(0); + _server.setConnectors(new Connector[] + { _connector }); + _server.setHandler(new AbstractHandler() + { + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, + ServletException + { + int i = 0; + try + { + baseRequest.setHandled(true); + response.setStatus(200); + + if (request.getServerName().equals("jetty.eclipse.org")) + { + response.getOutputStream().println("Proxy request: " + request.getRequestURL()); + response.getOutputStream().println(request.getHeader(HttpHeaders.PROXY_AUTHORIZATION)); + } + else if (request.getMethod().equalsIgnoreCase("GET")) + { + response.getOutputStream().println(""); + for (; i < 100; i++) + { + response.getOutputStream().println(" " + i + ""); + } + else if (request.getMethod().equalsIgnoreCase("SLEEP")) + { + Thread.sleep(10000); + } + else + { + response.setContentType(request.getContentType()); + int size = request.getContentLength(); + ByteArrayOutputStream bout = new ByteArrayOutputStream(size > 0?size:32768); + IO.copy(request.getInputStream(),bout); + response.getOutputStream().write(bout.toByteArray()); + } + } + catch (InterruptedException e) + { + LOG.warn(e); + } + catch (IOException e) + { + LOG.warn(e); + throw e; + } + catch (Throwable e) + { + LOG.warn(e); + throw new ServletException(e); + } + finally + { + } + } + }); + _server.start(); + return _server; + } +} diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ServerAndClientCreator.java new file mode 100644 index 00000000000..015006f6802 --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/ServerAndClientCreator.java @@ -0,0 +1,11 @@ +package org.eclipse.jetty.client.helperClasses; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.server.Server; + +public interface ServerAndClientCreator +{ + Server createServer() throws Exception; + + HttpClient createClient(long idleTimeout, long timeout, int connectTimeout) throws Exception; +} diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/SslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/SslServerAndClientCreator.java new file mode 100644 index 00000000000..d0e0ad0a115 --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/SslServerAndClientCreator.java @@ -0,0 +1,19 @@ +package org.eclipse.jetty.client.helperClasses; + +import org.eclipse.jetty.client.HttpClient; + +public class SslServerAndClientCreator extends AbstractSslServerAndClientCreator implements ServerAndClientCreator +{ + + public HttpClient createClient(long idleTimeout, long timeout, int connectTimeout) throws Exception + { + HttpClient httpClient = new HttpClient(); + httpClient.setIdleTimeout(idleTimeout); + httpClient.setTimeout(timeout); + httpClient.setConnectTimeout(connectTimeout); + httpClient.setConnectorType(HttpClient.CONNECTOR_SOCKET); + httpClient.setMaxConnectionsPerAddress(2); + httpClient.start(); + return httpClient; + } +} From 61eba95ac64a58a20dbf626e6b888985a707f457 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Tue, 13 Sep 2011 17:57:50 +1000 Subject: [PATCH 019/134] JETTY-1430 local JNDI contexts don't carry environment --- .../jetty/jndi/BindingEnumeration.java | 69 ++ .../eclipse/jetty/jndi/NameEnumeration.java | 69 ++ .../org/eclipse/jetty/jndi/NamingContext.java | 200 +--- .../jetty/jndi/java/javaRootURLContext.java | 3 +- .../jetty/jndi/local/localContextRoot.java | 916 +++++++++++++++--- .../jetty/jndi/java/TestLocalJNDI.java | 147 +++ 6 files changed, 1111 insertions(+), 293 deletions(-) create mode 100644 jetty-jndi/src/main/java/org/eclipse/jetty/jndi/BindingEnumeration.java create mode 100644 jetty-jndi/src/main/java/org/eclipse/jetty/jndi/NameEnumeration.java diff --git a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/BindingEnumeration.java b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/BindingEnumeration.java new file mode 100644 index 00000000000..14a2b8fe35d --- /dev/null +++ b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/BindingEnumeration.java @@ -0,0 +1,69 @@ +// ======================================================================== +// Copyright (c) 2011 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.jndi; + +import java.util.Iterator; + +import javax.naming.Binding; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; + +/** BindingEnumeration + *

Implementation of NamingEnumeration + * + *

Notes

+ *

Used to return results of Context.listBindings(); + * + *

Usage

+ * + */ +public class BindingEnumeration implements NamingEnumeration +{ + Iterator _delegate; + + public BindingEnumeration (Iterator e) + { + _delegate = e; + } + + public void close() + throws NamingException + { + } + + public boolean hasMore () + throws NamingException + { + return _delegate.hasNext(); + } + + public Binding next() + throws NamingException + { + Binding b = (Binding)_delegate.next(); + return new Binding (b.getName(), b.getClassName(), b.getObject(), true); + } + + public boolean hasMoreElements() + { + return _delegate.hasNext(); + } + + public Binding nextElement() + { + Binding b = (Binding)_delegate.next(); + return new Binding (b.getName(), b.getClassName(), b.getObject(),true); + } +} \ No newline at end of file diff --git a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/NameEnumeration.java b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/NameEnumeration.java new file mode 100644 index 00000000000..432fa65f3df --- /dev/null +++ b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/NameEnumeration.java @@ -0,0 +1,69 @@ +// ======================================================================== +// Copyright (c) 2011 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.jndi; + +import java.util.Iterator; + +import javax.naming.Binding; +import javax.naming.NameClassPair; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; + +/** NameEnumeration + *

Implementation of NamingEnumeration interface. + * + *

Notes

+ *

Used for returning results of Context.list(); + * + *

Usage

+ * + */ +public class NameEnumeration implements NamingEnumeration +{ + Iterator _delegate; + + public NameEnumeration (Iterator e) + { + _delegate = e; + } + + public void close() + throws NamingException + { + } + + public boolean hasMore () + throws NamingException + { + return _delegate.hasNext(); + } + + public NameClassPair next() + throws NamingException + { + Binding b = _delegate.next(); + return new NameClassPair(b.getName(),b.getClassName(),true); + } + + public boolean hasMoreElements() + { + return _delegate.hasNext(); + } + + public NameClassPair nextElement() + { + Binding b = _delegate.next(); + return new NameClassPair(b.getName(),b.getClassName(),true); + } +} \ No newline at end of file diff --git a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/NamingContext.java b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/NamingContext.java index e6dec8bbae0..da2ee7d35b0 100644 --- a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/NamingContext.java +++ b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/NamingContext.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -31,7 +30,6 @@ import javax.naming.InitialContext; import javax.naming.LinkRef; import javax.naming.Name; import javax.naming.NameAlreadyBoundException; -import javax.naming.NameClassPair; import javax.naming.NameNotFoundException; import javax.naming.NameParser; import javax.naming.NamingEnumeration; @@ -53,17 +51,8 @@ import org.eclipse.jetty.util.log.Logger; *

Notes

*

All Names are expected to be Compound, not Composite. * - *

Usage

- *
+ * 
  */
-/*
-* 
-* -* @see -* -* -* @version 1.0 -*/ public class NamingContext implements Context, Cloneable, Dumpable { private final static Logger __log=NamingUtil.__log; @@ -101,123 +90,6 @@ public class NamingContext implements Context, Cloneable, Dumpable void unbind(NamingContext ctx, Binding binding); } - /*------------------------------------------------*/ - /** NameEnumeration - *

Implementation of NamingEnumeration interface. - * - *

Notes

- *

Used for returning results of Context.list(); - * - *

Usage

- *
-     */
-    /*
-     * 
- * - * @see - * - */ - public class NameEnumeration implements NamingEnumeration - { - Iterator _delegate; - - public NameEnumeration (Iterator e) - { - _delegate = e; - } - - public void close() - throws NamingException - { - } - - public boolean hasMore () - throws NamingException - { - return _delegate.hasNext(); - } - - public NameClassPair next() - throws NamingException - { - Binding b = _delegate.next(); - return new NameClassPair(b.getName(),b.getClassName(),true); - } - - public boolean hasMoreElements() - { - return _delegate.hasNext(); - } - - public NameClassPair nextElement() - { - Binding b = _delegate.next(); - return new NameClassPair(b.getName(),b.getClassName(),true); - } - } - - - - - - - /*------------------------------------------------*/ - /** BindingEnumeration - *

Implementation of NamingEnumeration - * - *

Notes

- *

Used to return results of Context.listBindings(); - * - *

Usage

- *
-     */
-    /*
-     * 
- * - * @see - * - */ - public class BindingEnumeration implements NamingEnumeration - { - Iterator _delegate; - - public BindingEnumeration (Iterator e) - { - _delegate = e; - } - - public void close() - throws NamingException - { - } - - public boolean hasMore () - throws NamingException - { - return _delegate.hasNext(); - } - - public Binding next() - throws NamingException - { - Binding b = (Binding)_delegate.next(); - return new Binding (b.getName(), b.getClassName(), b.getObject(), true); - } - - public boolean hasMoreElements() - { - return _delegate.hasNext(); - } - - public Binding nextElement() - { - Binding b = (Binding)_delegate.next(); - return new Binding (b.getName(), b.getClassName(), b.getObject(),true); - } - } - - - /*------------------------------------------------*/ /** * Constructor @@ -240,26 +112,6 @@ public class NamingContext implements Context, Cloneable, Dumpable } - /*------------------------------------------------*/ - /** - * Creates a new NamingContext instance. - * - * @param env a Hashtable value - */ - public NamingContext (Hashtable env) - { - if (env != null) - _env.putAll(env); - } - - /*------------------------------------------------*/ - /** - * Constructor - * - */ - public NamingContext () - { - } /*------------------------------------------------*/ @@ -312,8 +164,24 @@ public class NamingContext implements Context, Cloneable, Dumpable _parser = parser; } + + public void setEnv (Hashtable env) + { + _env.clear(); + _env.putAll(env); + } + + public Map getBindings () + { + return _bindings; + } + public void setBindings(Map bindings) + { + _bindings = bindings; + } + /*------------------------------------------------*/ /** * Bind a name to an object @@ -435,8 +303,6 @@ public class NamingContext implements Context, Cloneable, Dumpable ne.setRemainingName(name); throw ne; } - - Name cname = toCanonicalName (name); @@ -521,7 +387,7 @@ public class NamingContext implements Context, Cloneable, Dumpable /*------------------------------------------------*/ /** - * Not supported + * * * @param name name of subcontext to remove * @exception NamingException if an error occurs @@ -536,7 +402,7 @@ public class NamingContext implements Context, Cloneable, Dumpable /*------------------------------------------------*/ /** - * Not supported + * * * @param name name of subcontext to remove * @exception NamingException if an error occurs @@ -1128,7 +994,6 @@ public class NamingContext implements Context, Cloneable, Dumpable ctx = binding.getObject(); - if (ctx instanceof Reference) { //deference the object @@ -1154,8 +1019,7 @@ public class NamingContext implements Context, Cloneable, Dumpable } else throw new NotContextException ("Object bound at "+firstComponent +" is not a Context"); - } - + } } /*------------------------------------------------*/ @@ -1182,11 +1046,11 @@ public class NamingContext implements Context, Cloneable, Dumpable * @param newName a Name value * @exception NamingException if an error occurs */ public void rename(String oldName, - String newName) - throws NamingException - { - throw new OperationNotSupportedException(); - } + String newName) + throws NamingException + { + throw new OperationNotSupportedException(); + } @@ -1247,9 +1111,7 @@ public class NamingContext implements Context, Cloneable, Dumpable */ public void close () throws NamingException - { - - + { } @@ -1362,7 +1224,7 @@ public class NamingContext implements Context, Cloneable, Dumpable * @param name a Name value * @param obj an Object value */ - protected void addBinding (Name name, Object obj) throws NameAlreadyBoundException + public void addBinding (Name name, Object obj) throws NameAlreadyBoundException { String key = name.toString(); Binding binding=new Binding (key, obj); @@ -1394,7 +1256,7 @@ public class NamingContext implements Context, Cloneable, Dumpable * @param name a Name value * @return a Binding value */ - protected Binding getBinding (Name name) + public Binding getBinding (Name name) { return (Binding) _bindings.get(name.toString()); } @@ -1407,13 +1269,13 @@ public class NamingContext implements Context, Cloneable, Dumpable * @param name as a String * @return null or the Binding */ - protected Binding getBinding (String name) + public Binding getBinding (String name) { return (Binding) _bindings.get(name); } /*------------------------------------------------*/ - protected void removeBinding (Name name) + public void removeBinding (Name name) { String key = name.toString(); if (__log.isDebugEnabled()) @@ -1455,7 +1317,7 @@ public class NamingContext implements Context, Cloneable, Dumpable } /* ------------------------------------------------------------ */ - private boolean isLocked() + public boolean isLocked() { if ((_env.get(LOCK_PROPERTY) == null) && (_env.get(UNLOCK_PROPERTY) == null)) return false; diff --git a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/java/javaRootURLContext.java b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/java/javaRootURLContext.java index 09dcfc8f49a..d26b8475b18 100644 --- a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/java/javaRootURLContext.java +++ b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/java/javaRootURLContext.java @@ -67,8 +67,7 @@ public class javaRootURLContext implements Context try { __javaNameParser = new javaNameParser(); - __nameRoot = new NamingContext(); - __nameRoot.setNameParser(__javaNameParser); + __nameRoot = new NamingContext(null,null,null,__javaNameParser); StringRefAddr parserAddr = new StringRefAddr("parser", __javaNameParser.getClass().getName()); diff --git a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/local/localContextRoot.java b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/local/localContextRoot.java index 7c187a7166e..a915ad1917d 100644 --- a/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/local/localContextRoot.java +++ b/jetty-jndi/src/main/java/org/eclipse/jetty/jndi/local/localContextRoot.java @@ -13,36 +13,63 @@ package org.eclipse.jetty.jndi.local; +import java.util.Collections; +import java.util.HashMap; import java.util.Hashtable; +import java.util.List; +import java.util.Map; import java.util.Properties; +import javax.naming.Binding; import javax.naming.CompoundName; import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.LinkRef; import javax.naming.Name; +import javax.naming.NameAlreadyBoundException; +import javax.naming.NameClassPair; +import javax.naming.NameNotFoundException; import javax.naming.NameParser; import javax.naming.NamingEnumeration; import javax.naming.NamingException; +import javax.naming.NotContextException; +import javax.naming.OperationNotSupportedException; +import javax.naming.Reference; +import javax.naming.Referenceable; +import javax.naming.spi.NamingManager; +import org.eclipse.jetty.jndi.BindingEnumeration; +import org.eclipse.jetty.jndi.NameEnumeration; import org.eclipse.jetty.jndi.NamingContext; +import org.eclipse.jetty.jndi.NamingUtil; +import org.eclipse.jetty.util.log.Logger; /** * * localContext * + * Implementation of the delegate for InitialContext for the local namespace. + * * * @version $Revision: 4780 $ $Date: 2009-03-17 16:36:08 +0100 (Tue, 17 Mar 2009) $ * */ public class localContextRoot implements Context { - private static final NamingContext __root = new NamingContext(); + private final static Logger __log=NamingUtil.__log; + protected final static NamingContext __root = new NamingRoot(); private final Hashtable _env; + - // make a root for the static namespace local: - static + static class NamingRoot extends NamingContext { - __root.setNameParser(new LocalNameParser()); + public NamingRoot() + { + super (null,null,null,new LocalNameParser()); + } } + + static class LocalNameParser implements NameParser { @@ -61,6 +88,19 @@ public class localContextRoot implements Context } } + + /* + * Root has to use the localContextRoot's env for all operations. + * So, if createSubcontext in the root, use the env of the localContextRoot. + * If lookup binding in the root, use the env of the localContextRoot. + * + */ + + + + + + public static NamingContext getRoot() { return __root; @@ -91,6 +131,21 @@ public class localContextRoot implements Context return ""; } + + /** + * + * + * @see javax.naming.Context#destroySubcontext(javax.naming.Name) + */ + public void destroySubcontext(Name name) throws NamingException + { + synchronized (__root) + { + __root.destroySubcontext(getSuffix(name)); + } + } + + /** * * @@ -100,23 +155,12 @@ public class localContextRoot implements Context { synchronized (__root) { - __root.destroySubcontext(getSuffix(name)); - } - } - - /** - * - * - * @see javax.naming.Context#unbind(java.lang.String) - */ - public void unbind(String name) throws NamingException - { - synchronized (__root) - { - __root.unbind(getSuffix(name)); + + destroySubcontext(__root.getNameParser("").parse(getSuffix(name))); } } + /** * * @@ -127,18 +171,7 @@ public class localContextRoot implements Context return _env; } - /** - * - * - * @see javax.naming.Context#destroySubcontext(javax.naming.Name) - */ - public void destroySubcontext(Name name) throws NamingException - { - synchronized (__root) - { - __root.destroySubcontext(getSuffix(name)); - } - } + /** * @@ -149,23 +182,92 @@ public class localContextRoot implements Context { synchronized (__root) { - __root.unbind(getSuffix(name)); + //__root.unbind(getSuffix(name)); + + if (name.size() == 0) + return; + + + if (__root.isLocked()) + throw new NamingException ("This context is immutable"); + + Name cname = __root.toCanonicalName(name); + + if (cname == null) + throw new NamingException ("Name is null"); + + if (cname.size() == 0) + throw new NamingException ("Name is empty"); + + + //if no subcontexts, just unbind it + if (cname.size() == 1) + { + __root.removeBinding (cname); + } + else + { + //walk down the subcontext hierarchy + if(__log.isDebugEnabled())__log.debug("Checking for existing binding for name="+cname+" for first element of name="+cname.get(0)); + + String firstComponent = cname.get(0); + Object ctx = null; + + + if (firstComponent.equals("")) + ctx = this; + else + { + Binding binding = __root.getBinding (name.get(0)); + if (binding == null) + throw new NameNotFoundException (name.get(0)+ " is not bound"); + + ctx = binding.getObject(); + + if (ctx instanceof Reference) + { + //deference the object + try + { + ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + } + + if (ctx instanceof Context) + { + ((Context)ctx).unbind (cname.getSuffix(1)); + } + else + throw new NotContextException ("Object bound at "+firstComponent +" is not a Context"); + } + + + } } /** * * - * @see javax.naming.Context#lookup(java.lang.String) + * @see javax.naming.Context#unbind(java.lang.String) */ - public Object lookup(String name) throws NamingException + public void unbind(String name) throws NamingException { - synchronized (__root) - { - return __root.lookup(getSuffix(name)); - } + unbind(__root.getNameParser("").parse(getSuffix(name))); } + + /** * * @@ -175,56 +277,7 @@ public class localContextRoot implements Context { synchronized (__root) { - return __root.lookupLink(getSuffix(name)); - } - } - - /** - * - * - * @see javax.naming.Context#removeFromEnvironment(java.lang.String) - */ - public Object removeFromEnvironment(String propName) throws NamingException - { - return _env.remove(propName); - } - - /** - * - * - * @see javax.naming.Context#bind(java.lang.String, java.lang.Object) - */ - public void bind(String name, Object obj) throws NamingException - { - synchronized (__root) - { - __root.bind(getSuffix(name), obj); - } - } - - /** - * - * - * @see javax.naming.Context#rebind(java.lang.String, java.lang.Object) - */ - public void rebind(String name, Object obj) throws NamingException - { - synchronized (__root) - { - __root.rebind(getSuffix(name), obj); - } - } - - /** - * - * - * @see javax.naming.Context#lookup(javax.naming.Name) - */ - public Object lookup(Name name) throws NamingException - { - synchronized (__root) - { - return __root.lookup(getSuffix(name)); + return lookupLink(__root.getNameParser("").parse(getSuffix(name))); } } @@ -237,10 +290,262 @@ public class localContextRoot implements Context { synchronized (__root) { - return __root.lookupLink(getSuffix(name)); + //return __root.lookupLink(getSuffix(name)); + + + Name cname = __root.toCanonicalName(name); + + if (cname == null) + { + //If no name create copy of this context with same bindings, but with copy of the environment so it can be modified + NamingContext ctx = new NamingContext (_env, null, null, __root.getNameParser("")); + ctx.setBindings(__root.getBindings()); + return ctx; + } + + if (cname.size() == 0) + throw new NamingException ("Name is empty"); + + if (cname.size() == 1) + { + Binding binding = __root.getBinding (cname); + if (binding == null) + throw new NameNotFoundException(); + + Object o = binding.getObject(); + + //handle links by looking up the link + if (o instanceof Reference) + { + //deference the object + try + { + return NamingManager.getObjectInstance(o, cname.getPrefix(1), __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + else + { + //object is either a LinkRef which we don't dereference + //or a plain object in which case spec says we return it + return o; + } + } + + + //it is a multipart name, recurse to the first subcontext + String firstComponent = cname.get(0); + Object ctx = null; + + if (firstComponent.equals("")) + ctx = this; + else + { + Binding binding = __root.getBinding (firstComponent); + if (binding == null) + throw new NameNotFoundException (); + + ctx = binding.getObject(); + + if (ctx instanceof Reference) + { + //deference the object + try + { + ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + } + + if (!(ctx instanceof Context)) + throw new NotContextException(); + + return ((Context)ctx).lookup (cname.getSuffix(1)); + + } } + + /** + * + * + * @see javax.naming.Context#removeFromEnvironment(java.lang.String) + */ + public Object removeFromEnvironment(String propName) throws NamingException + { + return _env.remove(propName); + } + + + /** + * + * + * @see javax.naming.Context#lookup(javax.naming.Name) + */ + public Object lookup(Name name) throws NamingException + { + synchronized (__root) + { + //return __root.lookup(getSuffix(name)); + + if(__log.isDebugEnabled())__log.debug("Looking up name=\""+name+"\""); + Name cname = __root.toCanonicalName(name); + + if ((cname == null) || (cname.size() == 0)) + { + __log.debug("Null or empty name, returning copy of this context"); + NamingContext ctx = new NamingContext (_env, null, null, __root.getNameParser("")); + ctx.setBindings(__root.getBindings()); + return ctx; + } + + + + if (cname.size() == 1) + { + Binding binding = __root.getBinding (cname); + if (binding == null) + { + NameNotFoundException nnfe = new NameNotFoundException(); + nnfe.setRemainingName(cname); + throw nnfe; + } + + + Object o = binding.getObject(); + + //handle links by looking up the link + if (o instanceof LinkRef) + { + //if link name starts with ./ it is relative to current context + String linkName = ((LinkRef)o).getLinkName(); + if (linkName.startsWith("./")) + return lookup (linkName.substring(2)); + else + { + //link name is absolute + InitialContext ictx = new InitialContext(); + return ictx.lookup (linkName); + } + } + else if (o instanceof Reference) + { + //deference the object + try + { + return NamingManager.getObjectInstance(o, cname, __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + else + return o; + } + + //it is a multipart name, get the first subcontext + + String firstComponent = cname.get(0); + Object ctx = null; + + if (firstComponent.equals("")) + ctx = this; + else + { + + Binding binding = __root.getBinding (firstComponent); + if (binding == null) + { + NameNotFoundException nnfe = new NameNotFoundException(); + nnfe.setRemainingName(cname); + throw nnfe; + } + + //as we have bound a reference to an object factory + //for the component specific contexts + //at "comp" we need to resolve the reference + ctx = binding.getObject(); + + if (ctx instanceof Reference) + { + //deference the object + try + { + ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + } + if (!(ctx instanceof Context)) + throw new NotContextException(); + + return ((Context)ctx).lookup (cname.getSuffix(1)); + + } + } + + + /** + * + * + * @see javax.naming.Context#lookup(java.lang.String) + */ + public Object lookup(String name) throws NamingException + { + synchronized (__root) + { + return lookup(__root.getNameParser("").parse(getSuffix(name))); + } + } + + + /** + * + * + * @see javax.naming.Context#bind(java.lang.String, java.lang.Object) + */ + public void bind(String name, Object obj) throws NamingException + { + synchronized (__root) + { + bind(__root.getNameParser("").parse(getSuffix(name)), obj); + + } + } + + /** * * @@ -250,7 +555,83 @@ public class localContextRoot implements Context { synchronized (__root) { - __root.bind(getSuffix(name), obj); + // __root.bind(getSuffix(name), obj); + + + if (__root.isLocked()) + throw new NamingException ("This context is immutable"); + + Name cname = __root.toCanonicalName(name); + + if (cname == null) + throw new NamingException ("Name is null"); + + if (cname.size() == 0) + throw new NamingException ("Name is empty"); + + + //if no subcontexts, just bind it + if (cname.size() == 1) + { + //get the object to be bound + Object objToBind = NamingManager.getStateToBind(obj, name,this, _env); + // Check for Referenceable + if (objToBind instanceof Referenceable) + { + objToBind = ((Referenceable)objToBind).getReference(); + } + + //anything else we should be able to bind directly + __root.addBinding (cname, objToBind); + } + else + { + if(__log.isDebugEnabled())__log.debug("Checking for existing binding for name="+cname+" for first element of name="+cname.get(0)); + + //walk down the subcontext hierarchy + //need to ignore trailing empty "" name components + + String firstComponent = cname.get(0); + Object ctx = null; + + if (firstComponent.equals("")) + ctx = this; + else + { + + Binding binding = __root.getBinding (firstComponent); + if (binding == null) + throw new NameNotFoundException (firstComponent+ " is not bound"); + + ctx = binding.getObject(); + + if (ctx instanceof Reference) + { + //deference the object + try + { + ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), this, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + } + + + if (ctx instanceof Context) + { + ((Context)ctx).bind (cname.getSuffix(1), obj); + } + else + throw new NotContextException ("Object bound at "+firstComponent +" is not a Context"); + } } } @@ -263,7 +644,105 @@ public class localContextRoot implements Context { synchronized (__root) { - __root.rebind(getSuffix(name), obj); + //__root.rebind(getSuffix(name), obj); + + + if (__root.isLocked()) + throw new NamingException ("This context is immutable"); + + Name cname = __root.toCanonicalName(name); + + if (cname == null) + throw new NamingException ("Name is null"); + + if (cname.size() == 0) + throw new NamingException ("Name is empty"); + + + //if no subcontexts, just bind it + if (cname.size() == 1) + { + //check if it is a Referenceable + Object objToBind = NamingManager.getStateToBind(obj, name, __root, _env); + + if (objToBind instanceof Referenceable) + { + objToBind = ((Referenceable)objToBind).getReference(); + } + __root.removeBinding(cname); + __root.addBinding (cname, objToBind); + } + else + { + //walk down the subcontext hierarchy + if(__log.isDebugEnabled())__log.debug("Checking for existing binding for name="+cname+" for first element of name="+cname.get(0)); + + String firstComponent = cname.get(0); + Object ctx = null; + + + if (firstComponent.equals("")) + ctx = this; + else + { + Binding binding = __root.getBinding (name.get(0)); + if (binding == null) + throw new NameNotFoundException (name.get(0)+ " is not bound"); + + ctx = binding.getObject(); + + + if (ctx instanceof Reference) + { + //deference the object + try + { + ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + } + + if (ctx instanceof Context) + { + ((Context)ctx).rebind (cname.getSuffix(1), obj); + } + else + throw new NotContextException ("Object bound at "+firstComponent +" is not a Context"); + } + } + } + + /** + * + * + * @see javax.naming.Context#rebind(java.lang.String, java.lang.Object) + */ + public void rebind(String name, Object obj) throws NamingException + { + synchronized (__root) + { + rebind(__root.getNameParser("").parse(getSuffix(name)), obj); + } + } + /** + * + * + * @see javax.naming.Context#rename(javax.naming.Name, javax.naming.Name) + */ + public void rename(Name oldName, Name newName) throws NamingException + { + synchronized (__root) + { + throw new OperationNotSupportedException(); } } @@ -276,7 +755,7 @@ public class localContextRoot implements Context { synchronized (__root) { - __root.rename(getSuffix(oldName), getSuffix(newName)); + throw new OperationNotSupportedException(); } } @@ -289,7 +768,15 @@ public class localContextRoot implements Context { synchronized (__root) { - return __root.createSubcontext(getSuffix(name)); + //if the subcontext comes directly off the root, use the env of the InitialContext + //as the root itself has no environment. Otherwise, it inherits the env of the parent + //Context further down the tree. + //NamingContext ctx = (NamingContext)__root.createSubcontext(name); + //if (ctx.getParent() == __root) + // ctx.setEnv(_env); + //return ctx; + + return createSubcontext(__root.getNameParser("").parse(name)); } } @@ -301,24 +788,92 @@ public class localContextRoot implements Context public Context createSubcontext(Name name) throws NamingException { synchronized (__root) - { - return __root.createSubcontext(getSuffix(name)); - } - } - - /** - * - * - * @see javax.naming.Context#rename(javax.naming.Name, javax.naming.Name) - */ - public void rename(Name oldName, Name newName) throws NamingException - { - synchronized (__root) - { - __root.rename(getSuffix(oldName), getSuffix(newName)); + { + //if the subcontext comes directly off the root, use the env of the InitialContext + //as the root itself has no environment. Otherwise, it inherits the env of the parent + //Context further down the tree. + //NamingContext ctx = (NamingContext)__root.createSubcontext(getSuffix(name)); + //if (ctx.getParent() == __root) + // ctx.setEnv(_env); + //return ctx; + + + + + if (__root.isLocked()) + { + NamingException ne = new NamingException ("This context is immutable"); + ne.setRemainingName(name); + throw ne; + } + + Name cname = __root.toCanonicalName (name); + + if (cname == null) + throw new NamingException ("Name is null"); + if (cname.size() == 0) + throw new NamingException ("Name is empty"); + + if (cname.size() == 1) + { + //not permitted to bind if something already bound at that name + Binding binding = __root.getBinding (cname); + if (binding != null) + throw new NameAlreadyBoundException (cname.toString()); + + //make a new naming context with the root as the parent + Context ctx = new NamingContext ((Hashtable)_env.clone(), cname.get(0), __root, __root.getNameParser("")); + __root.addBinding (cname, ctx); + return ctx; + } + + + //If the name has multiple subcontexts, walk the hierarchy by + //fetching the first one. All intermediate subcontexts in the + //name must already exist. + String firstComponent = cname.get(0); + Object ctx = null; + + if (firstComponent.equals("")) + ctx = this; + else + { + Binding binding = __root.getBinding (firstComponent); + if (binding == null) + throw new NameNotFoundException (firstComponent + " is not bound"); + + ctx = binding.getObject(); + + if (ctx instanceof Reference) + { + //deference the object + if(__log.isDebugEnabled())__log.debug("Object bound at "+firstComponent +" is a Reference"); + try + { + ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + } + + if (ctx instanceof Context) + { + return ((Context)ctx).createSubcontext (cname.getSuffix(1)); + } + else + throw new NotContextException (firstComponent +" is not a Context"); } } + /** * * @@ -348,22 +903,10 @@ public class localContextRoot implements Context { synchronized (__root) { - return __root.list(getSuffix(name)); + return list(__root.getNameParser("").parse(getSuffix(name))); } } - /** - * - * - * @see javax.naming.Context#listBindings(java.lang.String) - */ - public NamingEnumeration listBindings(String name) throws NamingException - { - synchronized (__root) - { - return __root.listBindings(getSuffix(name)); - } - } /** * @@ -374,7 +917,64 @@ public class localContextRoot implements Context { synchronized (__root) { - return __root.list(getSuffix(name)); + //return __root.list(getSuffix(name)); + + + Name cname = __root.toCanonicalName(name); + + if (cname == null) + { + List empty = Collections.emptyList(); + return new NameEnumeration(empty.iterator()); + } + + + if (cname.size() == 0) + { + return new NameEnumeration (__root.getBindings().values().iterator()); + } + + + + //multipart name + String firstComponent = cname.get(0); + Object ctx = null; + + if (firstComponent.equals("")) + ctx = this; + else + { + Binding binding = __root.getBinding (firstComponent); + if (binding == null) + throw new NameNotFoundException (); + + ctx = binding.getObject(); + + if (ctx instanceof Reference) + { + //deference the object + if(__log.isDebugEnabled())__log.debug("Dereferencing Reference for "+name.get(0)); + try + { + ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + } + + if (!(ctx instanceof Context)) + throw new NotContextException(); + + return ((Context)ctx).list (cname.getSuffix(1)); + } } @@ -387,10 +987,82 @@ public class localContextRoot implements Context { synchronized (__root) { - return __root.listBindings(getSuffix(name)); + //return __root.listBindings(getSuffix(name)); + + Name cname = __root.toCanonicalName (name); + + if (cname == null) + { + List empty = Collections.emptyList(); + return new BindingEnumeration(empty.iterator()); + } + + if (cname.size() == 0) + { + return new BindingEnumeration (__root.getBindings().values().iterator()); + } + + + + //multipart name + String firstComponent = cname.get(0); + Object ctx = null; + + //if a name has a leading "/" it is parsed as "" so ignore it by staying + //at this level in the tree + if (firstComponent.equals("")) + ctx = this; + else + { + //it is a non-empty name component + Binding binding = __root.getBinding (firstComponent); + if (binding == null) + throw new NameNotFoundException (); + + ctx = binding.getObject(); + + if (ctx instanceof Reference) + { + //deference the object + try + { + ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env); + } + catch (NamingException e) + { + throw e; + } + catch (Exception e) + { + __log.warn("",e); + throw new NamingException (e.getMessage()); + } + } + } + + if (!(ctx instanceof Context)) + throw new NotContextException(); + + return ((Context)ctx).listBindings (cname.getSuffix(1)); + } } + + /** + * + * + * @see javax.naming.Context#listBindings(java.lang.String) + */ + public NamingEnumeration listBindings(String name) throws NamingException + { + synchronized (__root) + { + return listBindings(__root.getNameParser("").parse(getSuffix(name))); + } + } + + /** * * diff --git a/jetty-jndi/src/test/java/org/eclipse/jetty/jndi/java/TestLocalJNDI.java b/jetty-jndi/src/test/java/org/eclipse/jetty/jndi/java/TestLocalJNDI.java index 0caa18fcefd..d41539de51d 100644 --- a/jetty-jndi/src/test/java/org/eclipse/jetty/jndi/java/TestLocalJNDI.java +++ b/jetty-jndi/src/test/java/org/eclipse/jetty/jndi/java/TestLocalJNDI.java @@ -12,11 +12,19 @@ // ======================================================================== package org.eclipse.jetty.jndi.java; +import java.util.Hashtable; + import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.Name; import javax.naming.NameNotFoundException; import javax.naming.NameParser; +import javax.naming.NamingException; +import javax.naming.RefAddr; +import javax.naming.Reference; +import javax.naming.Referenceable; +import javax.naming.StringRefAddr; +import javax.naming.spi.ObjectFactory; import org.eclipse.jetty.jndi.NamingUtil; import org.junit.After; @@ -31,13 +39,152 @@ import static org.junit.Assert.fail; */ public class TestLocalJNDI { + public static class FruitFactory implements ObjectFactory + { + public FruitFactory() + { + } + + public Object getObjectInstance(Object obj, Name name, Context ctx, Hashtable env) throws Exception + { + + if (!env.containsKey("flavour")) + throw new Exception ("No flavour!"); + + if (obj instanceof Reference) + { + Reference ref = (Reference)obj; + if (ref.getClassName().equals(Fruit.class.getName())) + { + RefAddr addr = ref.get("fruit"); + if (addr != null) + { + return new Fruit((String)addr.getContent()); + } + } + } + return null; + } + } + + + public static class Fruit implements Referenceable + { + String fruit; + + public Fruit(String f) + { + fruit = f; + } + + public Reference getReference() throws NamingException + { + return new Reference( + Fruit.class.getName(), + new StringRefAddr("fruit", fruit), + FruitFactory.class.getName(), + null); // Factory location + } + + public String toString() + { + return fruit; + } + } + + + + + + + + @After public void tearDown() throws Exception { InitialContext ic = new InitialContext(); ic.destroySubcontext("a"); } + + + @Test + public void testLocalReferenceable() throws Exception + { + Hashtable env1 = new Hashtable(); + env1.put("flavour", "orange"); + InitialContext ic1 = new InitialContext(env1); + + ic1.bind("valencia", new Fruit("orange")); + + Object o = ic1.lookup("valencia"); + Hashtable env2 = new Hashtable(); + InitialContext ic2 = new InitialContext(env2); + try + { + o = ic2.lookup("valencia"); + fail("Constructed object from reference without correct environment"); + } + catch (Exception e) + { + assertEquals("No flavour!", e.getMessage()); + } + } + + + @Test + public void testLocalEnvironment() throws Exception + { + Hashtable env1 = new Hashtable(); + env1.put("make", "holden"); + env1.put("model", "commodore"); + + Object car1 = new Object(); + + InitialContext ic = new InitialContext(env1); + ic.bind("car1", car1); + assertNotNull(ic.lookup("car1")); + assertEquals(car1, ic.lookup("car1")); + + Context carz = ic.createSubcontext("carz"); + assertNotNull(carz); + Hashtable ht = carz.getEnvironment(); + assertNotNull(ht); + assertEquals("holden", ht.get("make")); + assertEquals("commodore", ht.get("model")); + + Hashtable env2 = new Hashtable(); + env2.put("flavour", "strawberry"); + InitialContext ic2 = new InitialContext(env2); + assertEquals(car1, ic2.lookup("car1")); + Context c = (Context)ic2.lookup("carz"); + assertNotNull(c); + ht = c.getEnvironment(); + assertEquals("holden", ht.get("make")); + assertEquals("commodore", ht.get("model")); + + Context icecreamz = ic2.createSubcontext("icecreamz"); + ht = icecreamz.getEnvironment(); + assertNotNull(ht); + assertEquals("strawberry", ht.get("flavour")); + + Context hatchbackz = ic2.createSubcontext("carz/hatchbackz"); + assertNotNull(hatchbackz); + ht = hatchbackz.getEnvironment(); + assertNotNull(ht); + assertEquals("holden", ht.get("make")); + assertEquals("commodore", ht.get("model")); + assertEquals(null, ht.get("flavour")); + + c = (Context)ic.lookup("carz/hatchbackz"); + assertNotNull(c); + assertEquals(hatchbackz, c); + + } + + + + @Test public void testLocal () throws Exception { From 82f48ada9a947183922b28619356f29366e8a3d4 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 13 Sep 2011 11:48:16 -0700 Subject: [PATCH 020/134] 342161 - ScannerTest fails intermittently on Mac OS X + changing test directory to use test specific directory to avoid conflicts with /tmp directory reuse amoung other tests. --- .../java/org/eclipse/jetty/util/ScannerTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java index 8a85c295627..a7992b533ec 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ScannerTest.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import org.eclipse.jetty.toolchain.test.FS; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.util.Scanner.Notification; import org.junit.AfterClass; @@ -25,10 +27,8 @@ public class ScannerTest @BeforeClass public static void setUpBeforeClass() throws Exception { - _directory = File.createTempFile("scan",""); - _directory.delete(); - _directory.mkdir(); - _directory.deleteOnExit(); + _directory = MavenTestingUtils.getTargetTestingDir(ScannerTest.class.getSimpleName()); + FS.ensureEmpty(_directory); _scanner = new Scanner(); _scanner.addScanDir(_directory); @@ -88,7 +88,7 @@ public class ScannerTest public void testAddedChangeRemove() throws Exception { // TODO needs to be further investigated - Assume.assumeTrue(!OS.IS_WINDOWS && !OS.IS_OSX); + Assume.assumeTrue(!OS.IS_WINDOWS); touch("a0"); @@ -96,7 +96,7 @@ public class ScannerTest _scanner.scan(); _scanner.scan(); Event event = _queue.poll(); - Assert.assertTrue(event!=null); + Assert.assertNotNull("Event should not be null", event); Assert.assertEquals(_directory+"/a0",event._filename); Assert.assertEquals(Notification.ADDED,event._notification); @@ -197,7 +197,7 @@ public class ScannerTest public void testSizeChange() throws Exception { // TODO needs to be further investigated - Assume.assumeTrue(!OS.IS_WINDOWS && !OS.IS_OSX); + Assume.assumeTrue(!OS.IS_WINDOWS); touch("tsc0"); _scanner.scan(); From 670e8de26192fd13017a5e390ab29b7207a66eeb Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Tue, 13 Sep 2011 14:22:09 +0200 Subject: [PATCH 021/134] 352050: Fixed infinite redirect loop for /remote.html in testapp --- test-jetty-webapp/src/main/java/com/acme/TestFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-jetty-webapp/src/main/java/com/acme/TestFilter.java b/test-jetty-webapp/src/main/java/com/acme/TestFilter.java index 3712a2c7db4..18758dd276c 100644 --- a/test-jetty-webapp/src/main/java/com/acme/TestFilter.java +++ b/test-jetty-webapp/src/main/java/com/acme/TestFilter.java @@ -73,7 +73,7 @@ public class TestFilter implements Filter String to = request.getServerName(); String path=((HttpServletRequest)request).getServletPath(); - if (!_remote && !_allowed.contains(path) && ( + if (!"/remote.html".equals(path) && !_remote && !_allowed.contains(path) && ( !from.equals("localhost") && !from.startsWith("127.") && from.indexOf(":1")<0 || !to.equals("localhost")&&!to.startsWith("127.0.0.") && to.indexOf(":1")<0)) { From 54961fca1f9ba1de11862ea9cd29110ad7bde0c4 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 14 Sep 2011 14:17:09 +1000 Subject: [PATCH 022/134] refined test options and output --- .../org/eclipse/jetty/websocket/TestClient.java | 17 ++++++++++++----- .../org/eclipse/jetty/websocket/TestServer.java | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java index 80716955347..8a29da81323 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestClient.java @@ -52,6 +52,8 @@ public class TestClient implements WebSocket.OnFrame public void onOpen(Connection connection) { + if (_verbose) + System.err.printf("%s#onHandshake %s %s\n",this.getClass().getSimpleName(),connection,connection.getClass().getSimpleName()); } public void onClose(int closeCode, String message) @@ -141,7 +143,7 @@ public class TestClient implements WebSocket.OnFrame byte op=(byte)(off==0?opcode:WebSocketConnectionD13.OP_CONTINUATION); if (_verbose) - System.err.printf("%s#addFrame %s|%s %s\n",this.getClass().getSimpleName(),TypeUtil.toHexString(flags),TypeUtil.toHexString(op),TypeUtil.toHexString(data,off,len)); + System.err.printf("%s#sendFrame %s|%s %s\n",this.getClass().getSimpleName(),TypeUtil.toHexString(flags),TypeUtil.toHexString(op),TypeUtil.toHexString(data,off,len)); _connection.sendFrame(flags,op,data,off,len); @@ -168,6 +170,7 @@ public class TestClient implements WebSocket.OnFrame System.err.println(" -p|--port PORT (default 8080)"); System.err.println(" -b|--binary"); System.err.println(" -v|--verbose"); + System.err.println(" -q|--quiet"); System.err.println(" -c|--count n (default 10)"); System.err.println(" -s|--size n (default 64)"); System.err.println(" -f|--fragment n (default 4000) "); @@ -226,6 +229,8 @@ public class TestClient implements WebSocket.OnFrame try { __start=System.currentTimeMillis(); + protocol=protocol==null?"echo":protocol; + for (int i=0;i1?"s":"")+" ---"); - System.out.println(__framesSent+" frames transmitted, "+__framesReceived+" received, "+ - __messagesSent+" messages transmitted, "+__messagesReceived+" received, "+ - "time "+duration+"ms "+ (1000L*__messagesReceived.get()/duration)+" req/s"); + System.out.printf("%d/%d frames sent/recv, %d/%d mesg sent/recv, time %dms %dm/s %.2fbps%n", + __framesSent,__framesReceived.get(), + __messagesSent,__messagesReceived.get(), + duration,(1000L*__messagesReceived.get()/duration), + 1000.0D*__messagesReceived.get()*8*size/duration/1024/1024); System.out.printf("rtt min/ave/max = %.3f/%.3f/%.3f ms\n",__minDuration.get()/1000000.0,__messagesReceived.get()==0?0.0:(__totalTime.get()/__messagesReceived.get()/1000000.0),__maxDuration.get()/1000000.0); __clientFactory.stop(); diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java index ab9743392e2..ebdd1a0d8be 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/TestServer.java @@ -107,7 +107,7 @@ public class TestServer extends Server public void onOpen(Connection connection) { if (_verbose) - System.err.printf("%s#onOpen %s\n",this.getClass().getSimpleName(),connection); + System.err.printf("%s#onOpen %s %s\n",this.getClass().getSimpleName(),connection,connection.getProtocol()); } public void onHandshake(FrameConnection connection) From 901f818cb6068018f76df675eeed79cebac97266 Mon Sep 17 00:00:00 2001 From: hmalphettes Date: Wed, 14 Sep 2011 16:34:15 +0800 Subject: [PATCH 023/134] Ability to start equinox in a different thread instead of blocking the servletbrdige webapp from starting until equinox has completed to start. this is useful for cloudfoundry that at the moment complains if the webapp does not start very quickly --- jetty-osgi/jetty-osgi-servletbridge/pom.xml | 14 +++++- .../FrameworkLauncherExtended.java | 43 ++++++++++++++++++- .../src/main/webapp/WEB-INF/web.xml | 12 ++++-- 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/jetty-osgi/jetty-osgi-servletbridge/pom.xml b/jetty-osgi/jetty-osgi-servletbridge/pom.xml index 156a4a68ac4..703550a8ec6 100644 --- a/jetty-osgi/jetty-osgi-servletbridge/pom.xml +++ b/jetty-osgi/jetty-osgi-servletbridge/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 7.5.1-SNAPSHOT + 7.5.2-SNAPSHOT ../pom.xml 4.0.0 @@ -12,6 +12,7 @@ Jetty :: OSGi :: Servletbridge Jetty OSGi Servletbridge webapp war + false org.eclipse.equinox @@ -38,4 +39,15 @@ http://intalio.org/public/maven2 + + + + org.apache.maven.plugins + maven-eclipse-plugin + + false + + + + diff --git a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java index 52a926d384b..a0f2021e92f 100644 --- a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java +++ b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java @@ -49,6 +49,44 @@ public class FrameworkLauncherExtended extends FrameworkLauncher private boolean deployedInPlace = false; private URL resourceBaseAsURL = null; + + protected static Boolean ASYNCH_START_IN_PROGRESS; + protected static Throwable ASYNCH_START_FAILURE = null; + + /** + * If the start is asynch we do it in a different thread and return immediately. + */ + @Override + public synchronized void start() { + if (ASYNCH_START_IN_PROGRESS == null && "true".equals(super.config.getInitParameter("asyncStart"))) { + final ClassLoader webappCl = Thread.currentThread().getContextClassLoader(); + Thread th = new Thread() { + public void run() { + Thread.currentThread().setContextClassLoader(webappCl); + System.out.println("Jetty-Nested: Starting equinox asynchroneously."); + FrameworkLauncherExtended.this.start(); + System.out.println("Jetty-Nested: Finished starting equinox asynchroneously."); + } + }; + ASYNCH_START_IN_PROGRESS = true; + try { + th.start(); + } catch (Throwable t) { + ASYNCH_START_FAILURE = t; + if (t instanceof RuntimeException) { + throw (RuntimeException)t; + } else { + throw new RuntimeException("Equinox failed to start", t); + } + } finally { + ASYNCH_START_IN_PROGRESS = false; + } + } else { + System.out.println("Jetty-Nested: Starting equinox synchroneously."); + super.start(); + System.out.println("Jetty-Nested: Finished starting equinox synchroneously."); + } + } /** * try to find the resource base for this webapp by looking for the launcher initialization file. @@ -248,7 +286,10 @@ public class FrameworkLauncherExtended extends FrameworkLauncher String logback = System.getProperty("logback.configurationFile"); if (logback == null) { - File etcLogback = new File(jettyHome,"etc/logback.xml"); + File etcLogback = new File(jettyHome,"etc/logback-nested.xml"); + if (!etcLogback.exists()) { + etcLogback = new File(jettyHome,"etc/logback.xml"); + } if (etcLogback.exists()) { System.setProperty("logback.configurationFile",etcLogback.getAbsolutePath()); diff --git a/jetty-osgi/jetty-osgi-servletbridge/src/main/webapp/WEB-INF/web.xml b/jetty-osgi/jetty-osgi-servletbridge/src/main/webapp/WEB-INF/web.xml index c538c7c9bba..c61dee582d1 100644 --- a/jetty-osgi/jetty-osgi-servletbridge/src/main/webapp/WEB-INF/web.xml +++ b/jetty-osgi/jetty-osgi-servletbridge/src/main/webapp/WEB-INF/web.xml @@ -5,13 +5,19 @@ proxy Transparent Proxy Servlet and Equinox Framework Controller Transparent Proxy Servlet and Equinox Framework Controller - org.eclipse.equinox.servletbridge.BridgeServlet + org.eclipse.jetty.osgi.servletbridge.BridgeServletExtended + When this parameter is defined, that equinox installation is launched in place. + The parameter can also be passed as a system property. --> osgi.install.area /WEB-INF/eclipse + + + + asyncStart + true commandline From fd911df7403c8ca9d98ba02960d94828f04e8cbe Mon Sep 17 00:00:00 2001 From: hmalphettes Date: Wed, 14 Sep 2011 16:34:56 +0800 Subject: [PATCH 024/134] Ability to start equinox in a different thread instead of blocking the servletbrdige webapp from starting until equinox has completed to start. this is useful for cloudfoundry that at the moment complains if the webapp does not start very quickly --- .../servletbridge/BridgeServletExtended.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java diff --git a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java new file mode 100644 index 00000000000..4bf16ee2b4d --- /dev/null +++ b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java @@ -0,0 +1,48 @@ +// ======================================================================== +// Copyright (c) 2010-2011 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.osgi.servletbridge; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.equinox.servletbridge.BridgeServlet; + +/** + * Override the BridgeServlet to report on whether equinox is actually started or not + * in case it is started asynchroneously. + * + * @author hmalphettes + */ +public class BridgeServletExtended extends BridgeServlet { + + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + if (FrameworkLauncherExtended.ASYNCH_START_IN_PROGRESS != null + && req.getMethod().equals("GET")) { + if (FrameworkLauncherExtended.ASYNCH_START_IN_PROGRESS) { + resp.getWriter().append("Equinox is currently starting...\n"); + return; + } else if (FrameworkLauncherExtended.ASYNCH_START_FAILURE != null) { + resp.getWriter().append("Equinox failed to start:\n"); + FrameworkLauncherExtended.ASYNCH_START_FAILURE.printStackTrace(resp.getWriter()); + return; + } + } + super.service(req, resp); + } + +} From 5530594128ba7d73132ee86b2f35f0a49b4e7361 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Wed, 14 Sep 2011 10:43:20 +0200 Subject: [PATCH 025/134] 353509: Fixed merging issues --- .../org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java | 1 + .../jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java | 2 +- .../test/java/org/eclipse/jetty/client/HttpExchangeTest.java | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java index 2426cdfd79b..8cfe3d7d2e6 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java @@ -24,6 +24,7 @@ public class AsyncSslHttpExchangeTest extends SslHttpExchangeTest @BeforeClass public static void setUpOnce() throws Exception { + _scheme="https"; _server = serverAndClientCreator.createServer(); _httpClient = serverAndClientCreator.createClient(3000L,3500L,2000); _port = _server.getConnectors()[0].getLocalPort(); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java index f3ccca1edab..303cdcbec53 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java @@ -25,7 +25,7 @@ public class ExternalKeyStoreAsyncSslHttpExchangeTest extends SslHttpExchangeTes @BeforeClass public static void setUpOnce() throws Exception { - _scheme="https://"; + _scheme="https"; _server = serverAndClientCreator.createServer(); _httpClient = serverAndClientCreator.createClient(3000L,3500L,2000); _port = _server.getConnectors()[0].getLocalPort(); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index 7490f0cfc5e..97d65f7cf16 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -366,6 +366,7 @@ public class HttpExchangeTest System.err.println(throwable.get()); assertTrue(throwable.get().toString().indexOf("close")>=0); assertEquals(HttpExchange.STATUS_EXCEPTED, status); + _httpClient.start(); } /* ------------------------------------------------------------ */ @@ -554,7 +555,7 @@ public class HttpExchangeTest assertEquals(HttpStatus.OK_200,httpExchange.getResponseStatus()); HttpFields headers = httpExchange.getResponseFields(); - assertTrue("Response contains Allow header", headers.containsKey("Allow")); + assertTrue("Response does not contain Allow header", headers.containsKey("Allow")); String allow = headers.getStringField("Allow"); String expectedMethods[] = From 18c5483cc4f2da4af899a2f5bb44a98587bb178a Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 14 Sep 2011 11:23:11 -0700 Subject: [PATCH 026/134] 353509 - jetty-client unit tests are running too long + Fixing last remaining test failure with some careful GenericServerHandler refactoring. --- .../org/eclipse/jetty/client/HttpAsserts.java | 29 +++++++ .../jetty/client/HttpExchangeTest.java | 9 +- .../AbstractSslServerAndClientCreator.java | 71 +--------------- .../AsyncSslServerAndClientCreator.java | 1 - .../helperClasses/GenericServerHandler.java | 84 +++++++++++++++++++ .../HttpServerAndClientCreator.java | 78 +---------------- 6 files changed, 120 insertions(+), 152 deletions(-) create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/HttpAsserts.java create mode 100644 jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAsserts.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAsserts.java new file mode 100644 index 00000000000..e0410057571 --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpAsserts.java @@ -0,0 +1,29 @@ +package org.eclipse.jetty.client; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.jetty.http.HttpFields; +import org.junit.Assert; + +public final class HttpAsserts +{ + public static void assertContainsHeaderKey(String expectedKey, HttpFields headers) + { + if (headers.containsKey(expectedKey)) + { + return; + } + List names = Collections.list(headers.getFieldNames()); + StringBuilder err = new StringBuilder(); + err.append("Missing expected header key [").append(expectedKey); + err.append("] (of ").append(names.size()).append(" header fields)"); + for (int i = 0; i < names.size(); i++) + { + String value = headers.getStringField(names.get(i)); + err.append("\n").append(i).append("] ").append(names.get(i)); + err.append(": ").append(value); + } + Assert.fail(err.toString()); + } +} diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index 97d65f7cf16..77b353a0420 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -544,7 +544,7 @@ public class HttpExchangeTest public void testOptionsWithExchange() throws Exception { ContentExchange httpExchange = new ContentExchange(true); - httpExchange.setURI(getBaseURI()); + httpExchange.setURL(getBaseURI().toASCIIString()); httpExchange.setRequestURI("*"); httpExchange.setMethod(HttpMethods.OPTIONS); // httpExchange.setRequestHeader("Connection","close"); @@ -555,8 +555,10 @@ public class HttpExchangeTest assertEquals(HttpStatus.OK_200,httpExchange.getResponseStatus()); HttpFields headers = httpExchange.getResponseFields(); - assertTrue("Response does not contain Allow header", headers.containsKey("Allow")); + HttpAsserts.assertContainsHeaderKey("Content-Length", headers); + assertEquals("Content-Length header value", 0, headers.getLongField("Content-Length")); + HttpAsserts.assertContainsHeaderKey("Allow",headers); String allow = headers.getStringField("Allow"); String expectedMethods[] = { "GET", "HEAD", "POST", "PUT", "DELETE", "MOVE", "OPTIONS", "TRACE" }; @@ -564,9 +566,6 @@ public class HttpExchangeTest { assertThat(allow,containsString(expectedMethod)); } - - assertTrue("Response contains Content-Length header", headers.containsKey("Content-Length")); - assertEquals("Content-Length header value", 0, headers.getLongField("Content-Length")); } /* ------------------------------------------------------------ */ diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java index 3d230ff2a29..72e626e0087 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java @@ -14,22 +14,11 @@ package org.eclipse.jetty.client.helperClasses; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.eclipse.jetty.http.HttpHeaders; import org.eclipse.jetty.http.ssl.SslContextFactory; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.ssl.SslSocketConnector; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; -import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -58,65 +47,7 @@ public abstract class AbstractSslServerAndClientCreator implements ServerAndClie connector.setAllowRenegotiate(true); server.setConnectors(new Connector[]{ connector }); - server.setHandler(new AbstractHandler() - { - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, - ServletException - { - int i = 0; - try - { - baseRequest.setHandled(true); - response.setStatus(200); - - if (request.getServerName().equals("jetty.eclipse.org")) - { - response.getOutputStream().println("Proxy request: " + request.getRequestURL()); - response.getOutputStream().println(request.getHeader(HttpHeaders.PROXY_AUTHORIZATION)); - } - else if (request.getMethod().equalsIgnoreCase("GET")) - { - response.getOutputStream().println(""); - for (; i < 100; i++) - { - response.getOutputStream().println(" " + i + ""); - } - else if (request.getMethod().equalsIgnoreCase("SLEEP")) - { - Thread.sleep(10000); - } - else - { - response.setContentType(request.getContentType()); - int size = request.getContentLength(); - ByteArrayOutputStream bout = new ByteArrayOutputStream(size > 0?size:32768); - IO.copy(request.getInputStream(),bout); - response.getOutputStream().write(bout.toByteArray()); - } - } - catch (InterruptedException e) - { - LOG.debug(e); - } - catch (IOException e) - { - LOG.warn(e); - throw e; - } - catch (Throwable e) - { - LOG.warn(e); - throw new ServletException(e); - } - finally - { - } - } - }); + server.setHandler(new GenericServerHandler()); server.start(); return server; } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java index 564713fc65b..6d08d216f90 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AsyncSslServerAndClientCreator.java @@ -16,7 +16,6 @@ public class AsyncSslServerAndClientCreator extends AbstractSslServerAndClientCr httpClient.setMaxConnectionsPerAddress(2); String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); - httpClient.setKeyStoreInputStream(new FileInputStream(keystore)); httpClient.setKeyStorePassword("storepwd"); httpClient.setKeyManagerPassword("keypwd"); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java new file mode 100644 index 00000000000..71cd3cd1e1d --- /dev/null +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java @@ -0,0 +1,84 @@ +package org.eclipse.jetty.client.helperClasses; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.http.HttpHeaders; +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.handler.AbstractHandler; +import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; + +/** + * Generic Server Handler used for various client tests. + */ +public class GenericServerHandler extends AbstractHandler +{ + private static final Logger LOG = Log.getLogger(GenericServerHandler.class); + + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException + { + int i = 0; + try + { + baseRequest.setHandled(true); + response.setStatus(200); + + if (request.getServerName().equals("jetty.eclipse.org")) + { + response.getOutputStream().println("Proxy request: " + request.getRequestURL()); + response.getOutputStream().println(request.getHeader(HttpHeaders.PROXY_AUTHORIZATION)); + } + else if (request.getMethod().equalsIgnoreCase("GET")) + { + response.getOutputStream().println(""); + for (; i < 100; i++) + { + response.getOutputStream().println(" " + i + ""); + } + else if (request.getMethod().equalsIgnoreCase("OPTIONS")) + { + if ("*".equals(target)) + { + response.setContentLength(0); + response.setHeader("Allow","GET,HEAD,POST,PUT,DELETE,MOVE,OPTIONS,TRACE"); + } + } + else if (request.getMethod().equalsIgnoreCase("SLEEP")) + { + Thread.sleep(10000); + } + else + { + response.setContentType(request.getContentType()); + int size = request.getContentLength(); + ByteArrayOutputStream bout = new ByteArrayOutputStream(size > 0?size:32768); + IO.copy(request.getInputStream(),bout); + response.getOutputStream().write(bout.toByteArray()); + } + } + catch (InterruptedException e) + { + LOG.warn(e); + } + catch (IOException e) + { + LOG.warn(e); + throw e; + } + catch (Throwable e) + { + LOG.warn(e); + throw new ServletException(e); + } + } +} diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java index 21019ff5b45..d9a2f1d3eef 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/HttpServerAndClientCreator.java @@ -1,27 +1,12 @@ package org.eclipse.jetty.client.helperClasses; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.http.HttpHeaders; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.nio.SelectChannelConnector; -import org.eclipse.jetty.util.IO; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; public class HttpServerAndClientCreator implements ServerAndClientCreator { - private static final Logger LOG = Log.getLogger(HttpServerAndClientCreator.class); - public HttpClient createClient(long idleTimeout, long timeout, int connectTimeout) throws Exception { HttpClient httpClient = new HttpClient(); @@ -43,67 +28,8 @@ public class HttpServerAndClientCreator implements ServerAndClientCreator _connector.setMaxIdleTime(3000000); _connector.setPort(0); - _server.setConnectors(new Connector[] - { _connector }); - _server.setHandler(new AbstractHandler() - { - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, - ServletException - { - int i = 0; - try - { - baseRequest.setHandled(true); - response.setStatus(200); - - if (request.getServerName().equals("jetty.eclipse.org")) - { - response.getOutputStream().println("Proxy request: " + request.getRequestURL()); - response.getOutputStream().println(request.getHeader(HttpHeaders.PROXY_AUTHORIZATION)); - } - else if (request.getMethod().equalsIgnoreCase("GET")) - { - response.getOutputStream().println(""); - for (; i < 100; i++) - { - response.getOutputStream().println(" " + i + ""); - } - else if (request.getMethod().equalsIgnoreCase("SLEEP")) - { - Thread.sleep(10000); - } - else - { - response.setContentType(request.getContentType()); - int size = request.getContentLength(); - ByteArrayOutputStream bout = new ByteArrayOutputStream(size > 0?size:32768); - IO.copy(request.getInputStream(),bout); - response.getOutputStream().write(bout.toByteArray()); - } - } - catch (InterruptedException e) - { - LOG.warn(e); - } - catch (IOException e) - { - LOG.warn(e); - throw e; - } - catch (Throwable e) - { - LOG.warn(e); - throw new ServletException(e); - } - finally - { - } - } - }); + _server.setConnectors(new Connector[]{ _connector }); + _server.setHandler(new GenericServerHandler()); _server.start(); return _server; } From f6c480cef16cf8cdcee2a93fec11e401f1b0fef1 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 15 Sep 2011 07:54:05 -0500 Subject: [PATCH 027/134] [Bug 357672] resolve issue with serializing pojos with mongodb session manager, thanks to john simone for the discovery and fix --- .../org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java | 1 - 1 file changed, 1 deletion(-) 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 cceb8551032..4790834199e 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 @@ -428,7 +428,6 @@ public class MongoSessionManager extends NoSqlSessionManager return o; } - bout.reset(); out.reset(); out.writeUnshared(value); out.flush(); From a3b2a71aea2e6a487b3f0e5d4a9a10bb006d5f0e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 15 Sep 2011 11:28:56 -0700 Subject: [PATCH 028/134] Setting back to debug level --- .../src/main/java/org/eclipse/jetty/client/HttpExchange.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java index f5d15028b43..a7f1197b340 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java @@ -572,7 +572,7 @@ public class HttpExchange if (uri.isOpaque()) throw new IllegalArgumentException("Opaque URI: "+uri); - LOG.info("URI = {}", uri.toASCIIString()); + LOG.debug("URI = {}", uri.toASCIIString()); String scheme = uri.getScheme(); int port = uri.getPort(); From a6988108c3c15ede7e54db4da8c31965cedc1640 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 16 Sep 2011 15:29:28 +1000 Subject: [PATCH 029/134] minor cleanups and extra debug --- .../jetty/io/nio/SelectChannelEndPoint.java | 10 ++++++++ .../io/nio/SslSelectChannelEndPoint.java | 10 ++++++++ .../jetty/server/AsyncHttpConnection.java | 24 +++++++++++++++++-- .../server/ssl/SslTruncationAttackTest.java | 2 +- .../websocket/DeflateFrameExtension.java | 2 +- .../jetty/websocket/WebSocketParserD13.java | 2 +- 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index fd5413ff3e0..161cf194735 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -90,6 +90,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo scheduleIdle(); } + /* ------------------------------------------------------------ */ public SelectionKey getSelectionKey() { @@ -260,6 +261,15 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo _connection.idleExpired(); } + /* ------------------------------------------------------------ */ + /** + * @return True if the endpoint has produced/consumed bytes itself (non application data). + */ + public boolean isProgressing() + { + return false; + } + /* ------------------------------------------------------------ */ /* */ diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 02f91fb8e5f..c80bbceb9e3 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -145,6 +145,16 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } } + /* ------------------------------------------------------------ */ + /** + * @return True if the endpoint has produced/consumed bytes itself (non application data). + */ + public boolean isProgressing() + { + SSLEngineResult result = _result; + return result!=null && (result.bytesConsumed()>0 || result.bytesProduced()>0); + } + /* ------------------------------------------------------------ */ /** * @return True if SSL re-negotiation is allowed (default false) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index 70175378cdf..52310ebf65d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -7,12 +7,17 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; public class AsyncHttpConnection extends HttpConnection { + private final static int NO_PROGRESS_INFO = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_INFO",100); + private final static int NO_PROGRESS_CLOSE = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_CLOSE",1000); + private static final Logger LOG = Log.getLogger(AsyncHttpConnection.class); + private int _total_no_progress; public AsyncHttpConnection(Connector connector, EndPoint endpoint, Server server) { @@ -22,13 +27,14 @@ public class AsyncHttpConnection extends HttpConnection public Connection handle() throws IOException { Connection connection = this; + boolean some_progress=false; + boolean progress=true; // Loop while more in buffer try { setCurrentConnection(this); - boolean progress=true; boolean more_in_buffer =false; while (_endp.isOpen() && (more_in_buffer || progress)) @@ -98,7 +104,6 @@ public class AsyncHttpConnection extends HttpConnection reset(false); more_in_buffer = _parser.isMoreInBuffer() || _endp.isBufferingInput(); } - // else Are we suspended? else if (_request.isAsyncStarted()) { @@ -108,6 +113,8 @@ public class AsyncHttpConnection extends HttpConnection } else more_in_buffer = _parser.isMoreInBuffer() || _endp.isBufferingInput(); + + some_progress|=progress|((SelectChannelEndPoint)_endp).isProgressing(); } } } @@ -121,6 +128,19 @@ public class AsyncHttpConnection extends HttpConnection ((AsyncEndPoint)_endp).scheduleWrite(); else _generator.returnBuffers(); + + if (!some_progress) + { + _total_no_progress++; + + if (NO_PROGRESS_INFO>0 && _total_no_progress%NO_PROGRESS_INFO==0 && (NO_PROGRESS_CLOSE<=0 || _total_no_progress< NO_PROGRESS_CLOSE)) + LOG.info("EndPoint making no progress: "+_total_no_progress+" "+_endp); + if (NO_PROGRESS_CLOSE>0 && _total_no_progress>NO_PROGRESS_CLOSE) + { + LOG.warn("Closing EndPoint making no progress: "+_total_no_progress+" "+_endp); + _endp.close(); + } + } } return connection; } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslTruncationAttackTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslTruncationAttackTest.java index 0dc113cd210..7b1e6dd2319 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslTruncationAttackTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslTruncationAttackTest.java @@ -234,8 +234,8 @@ public class SslTruncationAttackTest // Sleep for a while to detect eventual spin looping TimeUnit.SECONDS.sleep(1); + Assert.assertTrue("endpoint closed", endPointClosed.get()); Assert.assertEquals("handle() invocations", 1, handleCount.get()); - Assert.assertTrue("endpoint not closed", endPointClosed.get()); } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java index b3d6f44b4d2..54e4f6dc141 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/DeflateFrameExtension.java @@ -87,7 +87,7 @@ public class DeflateFrameExtension extends AbstractExtension catch(DataFormatException e) { LOG.warn(e); - getConnection().close(WebSocketConnectionD13.CLOSE_PROTOCOL,e.toString()); + getConnection().close(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,e.toString()); } } diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java index 43db357578c..5b21494df50 100644 --- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java +++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketParserD13.java @@ -312,7 +312,7 @@ public class WebSocketParserD13 implements WebSocketParser _buffer.skip(_bytesNeeded); _state=State.START; events++; - _handler.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"bad mask"); + _handler.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"Not masked"); } else { From 67a73c38f8c37b265b1f2ce092b692b288a474f5 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 16 Sep 2011 09:48:19 -0700 Subject: [PATCH 030/134] 357959 - Include javadoc in distribution + Reworked how ${jetty.home}/lib folder, now created by 3 copy-dependencies declarations. --- jetty-distribution/pom.xml | 267 +++++++------------------------------ 1 file changed, 50 insertions(+), 217 deletions(-) diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 6f8abcd6cb5..c0f19c82b8b 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -317,187 +317,6 @@ ${assembly-directory}/ VERSION.txt - - org.eclipse.jetty - jetty-util - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-io - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-http - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-server - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-security - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-servlet - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-servlets - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-xml - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-webapp - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - - org.eclipse.jetty - jetty-deploy - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-jmx - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-rewrite - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-ajp - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-annotations - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-client - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-jndi - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-policy - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-monitor - ${project.version} - jar - true - ** - ${assembly-directory}/lib/monitor - - - org.eclipse.jetty - jetty-plus - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-continuation - ${project.version} - jar - true - ** - ${assembly-directory}/lib - org.eclipse.jetty test-jetty-webapp @@ -518,45 +337,49 @@ ${assembly-directory} start.jar - - org.eclipse.jetty - jetty-websocket - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-overlay-deployer - ${project.version} - jar - true - ** - ${assembly-directory}/lib - - - org.eclipse.jetty - jetty-jsp-2.1 - ${project.version} - jar - true - ** - ${assembly-directory}/lib/jsp - - - org.glassfish.web - jsp-impl - ${central-jsp-version} - jar - true - ** - ${assembly-directory}/lib/jsp - + + copy-lib-deps + generate-resources + + copy-dependencies + + + org.eclipse.jetty + jetty-start,jetty-monitor,jetty-jsp-2.1 + jar + ${assembly-directory}/lib + + + + copy-lib-jsp-deps + generate-resources + + copy-dependencies + + + org.eclipse.jetty,org.glassfish.web + jetty-jsp-2.1,jsp-impl + jar + ${assembly-directory}/lib/jsp + + + + copy-lib-monitor-deps + generate-resources + + copy-dependencies + + + org.eclipse.jetty + jetty-monitor + jar + true + ${assembly-directory}/lib/monitor + + @@ -658,6 +481,16 @@ jetty-policy ${project.version} + + org.eclipse.jetty + jetty-servlets + ${project.version} + + + org.eclipse.jetty + jetty-monitor + ${project.version} + org.eclipse.jetty jetty-websocket From 51cf6ee1c70f5d897564fee37e71bb1e0b9beba3 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 16 Sep 2011 10:03:21 -0700 Subject: [PATCH 031/134] 357959 - Include javadoc in distribution + Reworked ${jetty.home}/etc creation by using unpack-dependencies on the 'config' classifier instead. --- jetty-distribution/pom.xml | 154 ++++--------------------------------- 1 file changed, 13 insertions(+), 141 deletions(-) diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index c0f19c82b8b..9a1430096b5 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -158,147 +158,6 @@ maven-dependency-plugin - - unpack - generate-resources - - unpack - - - - - org.eclipse.jetty - jetty-rewrite - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-ajp - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - test-jetty-webapp - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-jmx - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-util - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-webapp - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-deploy - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-plus - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-server - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-security - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-policy - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-monitor - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - org.eclipse.jetty - jetty-overlay-deployer - ${project.version} - config - jar - true - ** - ${assembly-directory} - - - - copy generate-resources @@ -380,6 +239,19 @@ ${assembly-directory}/lib/monitor + + unpack-config-deps + generate-resources + + unpack-dependencies + + + org.eclipse.jetty + config + false + ${assembly-directory} + + From d39ceb21a754e7de6d9d95b1861bf858656f7a85 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 16 Sep 2011 10:13:21 -0700 Subject: [PATCH 032/134] 357959 - Include javadoc in distribution + Enabling javadoc:jar on jetty-all (aggregate) + Using jetty-all-${version}-javadoc.jar as source for distribution ${jetty.home}/javadoc/ content. --- jetty-aggregate/jetty-all/pom.xml | 13 +++++++++++++ jetty-distribution/pom.xml | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index c65e5c899af..0e9d64808aa 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -73,6 +73,19 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + + + javadoc-jar + compile + + jar + + + + diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 9a1430096b5..50eefde0bcd 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -252,6 +252,21 @@ ${assembly-directory} + + unpack-javadoc + generate-resources + + unpack-dependencies + + + + org.eclipse.jetty.aggregate + jetty-all + javadoc + true + ${assembly-directory}/javadoc + + @@ -383,5 +398,12 @@ jsp-impl ${central-jsp-version} + + org.eclipse.jetty.aggregate + jetty-all + javadoc + jar + ${project.version} + From 298a623fe98a1cd800cc0dcadc64071c8ecef0f1 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 16 Sep 2011 11:05:07 -0700 Subject: [PATCH 033/134] 357959 - Include javadoc in distribution + Adjusting /javadoc/ proxy configuration in test-jetty-webapp to now be /javadoc-proxy/, along with providing a link to the distribution's /javadoc/ path as well. --- test-jetty-webapp/src/main/webapp/WEB-INF/web.xml | 4 ++-- test-jetty-webapp/src/main/webapp/index.html | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test-jetty-webapp/src/main/webapp/WEB-INF/web.xml b/test-jetty-webapp/src/main/webapp/WEB-INF/web.xml index eee0a8801b3..b71cb0fdc8b 100644 --- a/test-jetty-webapp/src/main/webapp/WEB-INF/web.xml +++ b/test-jetty-webapp/src/main/webapp/WEB-INF/web.xml @@ -235,7 +235,7 @@ TransparentProxy org.eclipse.jetty.servlets.ProxyServlet$Transparent - Prefix/javadoc + Prefix/javadoc-proxy ProxyTohttp://download.eclipse.org/jetty/stable-7/apidocs @@ -247,7 +247,7 @@ TransparentProxy - /javadoc/* + /javadoc-proxy/* diff --git a/test-jetty-webapp/src/main/webapp/index.html b/test-jetty-webapp/src/main/webapp/index.html index 28f1b26eeb7..74ef907a75a 100644 --- a/test-jetty-webapp/src/main/webapp/index.html +++ b/test-jetty-webapp/src/main/webapp/index.html @@ -3,6 +3,11 @@ Powered By Jetty + @@ -11,8 +16,8 @@ This is the Test webapp for the Jetty 7 HTTP Server and Servlet Container. For more information about Jetty, please visit our website -or wiki. -Commercial support for Jetty is available via webtide. +or wiki or see the bundled javadoc.
+Commercial support for Jetty is available via Webtide and Intalio.

This is a test context that serves: @@ -29,7 +34,7 @@ This is a test context that serves:

  • Dispatcher Servlet
  • Request Rewrite Servlet
  • JSP examples
  • -
  • Transparent Proxy (to javadoc @ eclipse.org)
  • +
  • Transparent Proxy (to javadoc @ eclipse.org)
  • Comet Chat: Long Polling, WebSocket
  • Authentication
  • From 949975e46a19f9bf8326752e154b41061bf1fdb0 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 19 Sep 2011 08:09:20 +1000 Subject: [PATCH 034/134] 358035 servlet streams access max idle time from endp --- .../eclipse/jetty/server/HttpConnection.java | 15 ++++++++--- .../org/eclipse/jetty/server/HttpInput.java | 12 ++++----- .../org/eclipse/jetty/server/HttpOutput.java | 23 ++++++++++------- .../eclipse/jetty/server/HttpWriterTest.java | 25 +++++++++++++++++-- 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index c77f76af97a..8ee1938d1c6 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -327,7 +327,7 @@ public abstract class HttpConnection extends AbstractConnection } if (_in == null) - _in = new HttpInput(((HttpParser)_parser),_connector.getMaxIdleTime()); + _in = new HttpInput(HttpConnection.this); return _in; } @@ -671,6 +671,16 @@ public abstract class HttpConnection extends AbstractConnection return _expect102Processing; } + /* ------------------------------------------------------------ */ + public int getMaxIdleTime() + { + if (_endp.getMaxIdleTime()>0) + return _endp.getMaxIdleTime(); + if (_connector.isLowResources()) + return _connector.getLowResourceMaxIdleTime(); + return _connector.getMaxIdleTime(); + } + /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ @@ -960,8 +970,7 @@ public abstract class HttpConnection extends AbstractConnection { Output() { - super((AbstractGenerator)HttpConnection.this._generator, - _connector.isLowResources()?_connector.getLowResourceMaxIdleTime():_connector.getMaxIdleTime()); + super(HttpConnection.this); } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java index f0bbc9aec8b..670fa95c81a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java @@ -22,14 +22,14 @@ import org.eclipse.jetty.io.Buffer; public class HttpInput extends ServletInputStream { + protected final HttpConnection _connection; protected final HttpParser _parser; - protected final long _maxIdleTime; /* ------------------------------------------------------------ */ - public HttpInput(HttpParser parser, long maxIdleTime) + public HttpInput(HttpConnection connection) { - _parser=parser; - _maxIdleTime=maxIdleTime; + _connection=connection; + _parser=(HttpParser)connection.getParser(); } /* ------------------------------------------------------------ */ @@ -40,7 +40,7 @@ public class HttpInput extends ServletInputStream public int read() throws IOException { int c=-1; - Buffer content=_parser.blockForContent(_maxIdleTime); + Buffer content=_parser.blockForContent(_connection.getMaxIdleTime()); if (content!=null) c= 0xff & content.get(); return c; @@ -54,7 +54,7 @@ public class HttpInput extends ServletInputStream public int read(byte[] b, int off, int len) throws IOException { int l=-1; - Buffer content=_parser.blockForContent(_maxIdleTime); + Buffer content=_parser.blockForContent(_connection.getMaxIdleTime()); if (content!=null) l= content.get(b, off, len); return l; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java index 5fd7d91c522..6d595877851 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java @@ -36,8 +36,8 @@ import org.eclipse.jetty.util.ByteArrayOutputStream2; */ public class HttpOutput extends ServletOutputStream { + protected final HttpConnection _connection; protected final AbstractGenerator _generator; - protected final long _maxIdleTime; private boolean _closed; // These are held here for reuse by Writer @@ -45,15 +45,20 @@ public class HttpOutput extends ServletOutputStream Writer _converter; char[] _chars; ByteArrayOutputStream2 _bytes; - /* ------------------------------------------------------------ */ - public HttpOutput(AbstractGenerator generator, long maxIdleTime) + public HttpOutput(HttpConnection connection) { - _generator=generator; - _maxIdleTime=maxIdleTime; + _connection=connection; + _generator=(AbstractGenerator)connection.getGenerator(); } + /* ------------------------------------------------------------ */ + public int getMaxIdleTime() + { + return _connection.getMaxIdleTime(); + } + /* ------------------------------------------------------------ */ public boolean isWritten() { @@ -86,7 +91,7 @@ public class HttpOutput extends ServletOutputStream @Override public void flush() throws IOException { - _generator.flush(_maxIdleTime); + _generator.flush(getMaxIdleTime()); } /* ------------------------------------------------------------ */ @@ -121,7 +126,7 @@ public class HttpOutput extends ServletOutputStream // Block until we can add _content. while (_generator.isBufferFull()) { - _generator.blockForOutput(_maxIdleTime); + _generator.blockForOutput(getMaxIdleTime()); if (_closed) throw new IOException("Closed"); if (!_generator.isOpen()) @@ -151,7 +156,7 @@ public class HttpOutput extends ServletOutputStream // Block until we can add _content. while (_generator.isBufferFull()) { - _generator.blockForOutput(_maxIdleTime); + _generator.blockForOutput(getMaxIdleTime()); if (_closed) throw new IOException("Closed"); if (!_generator.isOpen()) @@ -174,7 +179,7 @@ public class HttpOutput extends ServletOutputStream // Block until our buffer is free while (buffer.length() > 0 && _generator.isOpen()) { - _generator.blockForOutput(_maxIdleTime); + _generator.blockForOutput(getMaxIdleTime()); } } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java index fa86c3dcba0..73828e81bf1 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java @@ -12,6 +12,7 @@ import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffers; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayEndPoint; +import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.SimpleBuffers; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.TypeUtil; @@ -75,7 +76,17 @@ public class HttpWriterTest }; - HttpOutput httpOut = new HttpOutput(generator,60000); + HttpConnection connection = new HttpConnection(null,endp,new Server(),null,generator,null) + { + @Override + public Connection handle() throws IOException + { + return null; + } + }; + endp.setMaxIdleTime(60000); + + HttpOutput httpOut = new HttpOutput(connection); _writer = new HttpWriter(httpOut); } @@ -158,7 +169,17 @@ public class HttpWriterTest hb.setResponse(200,"OK"); - HttpOutput output = new HttpOutput(hb,10000); + HttpConnection connection = new HttpConnection(null,endp,new Server(),null,hb,null) + { + @Override + public Connection handle() throws IOException + { + return null; + } + }; + endp.setMaxIdleTime(10000); + hb.setSendServerVersion(false); + HttpOutput output = new HttpOutput(connection); HttpWriter writer = new HttpWriter(output); writer.setCharacterEncoding(StringUtil.__UTF8); From 8e765f12c64b3ee55a716598185deaf824dd38b0 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 19 Sep 2011 10:32:43 +1000 Subject: [PATCH 035/134] JETTY-1431 --- .../main/java/org/eclipse/jetty/server/handler/GzipHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GzipHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GzipHandler.java index 7aead3c0c3a..29a9a833932 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GzipHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GzipHandler.java @@ -159,7 +159,7 @@ public class GzipHandler extends HandlerWrapper * * @return the buffer size */ - public int setBufferSize() + public int getBufferSize() { return _bufferSize; } From c984d2587106555d72cd6f94413d6f5fcf67169b Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 19 Sep 2011 17:57:48 +1000 Subject: [PATCH 036/134] 358027 NullPointerException in ResourceHandler with jetty-stylesheet.css --- .../eclipse/jetty/server/handler/ResourceHandler.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 87be3d7b3fd..5d618165ed7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -45,7 +45,7 @@ import org.eclipse.jetty.util.resource.Resource; * * This handle will serve static content and handle If-Modified-Since headers. * No caching is done. - * Requests that cannot be handled are let pass (Eg no 404's) + * Requests for resources that do not exist are let pass (Eg no 404's). * * * @org.apache.xbean.XBean @@ -205,7 +205,7 @@ public class ResourceHandler extends AbstractHandler { try { - _defaultStylesheet = Resource.newResource(this.getClass().getResource("/jetty-default.css")); + _defaultStylesheet = Resource.newResource(this.getClass().getResource("/jetty-dir.css")); } catch(IOException e) { @@ -326,7 +326,7 @@ public class ResourceHandler extends AbstractHandler /* ------------------------------------------------------------ */ /* - * @see org.eclipse.jetty.server.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int) + * @see org.eclipse.jetty.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int) */ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { @@ -344,7 +344,7 @@ public class ResourceHandler extends AbstractHandler Resource resource = getResource(request); if (resource==null || !resource.exists()) { - if (target.endsWith("/jetty-stylesheet.css")) + if (target.endsWith("/jetty-dir.css")) { response.setContentType("text/css"); resource = getStylesheet(); @@ -359,7 +359,7 @@ public class ResourceHandler extends AbstractHandler return; } - // We are going to server something + // We are going to serve something baseRequest.setHandled(true); if (resource.isDirectory()) From 479d9606ec83acd4033a2b6b101781d227906ecd Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 19 Sep 2011 19:05:49 +1000 Subject: [PATCH 037/134] 353267 Request._parameters initialization bug --- .../org/eclipse/jetty/server/Request.java | 147 ++++++++++-------- .../org/eclipse/jetty/server/RequestTest.java | 42 +++++ 2 files changed, 120 insertions(+), 69 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 3a239ff6011..38f3b460d23 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -186,79 +186,36 @@ public class Request implements HttpServletRequest /* ------------------------------------------------------------ */ /** - * Extract Paramters from query string and/or form _content. + * Extract Parameters from query string and/or form _content. */ public void extractParameters() { if (_baseParameters == null) _baseParameters = new MultiMap(16); - + if (_paramsExtracted) { if (_parameters==null) _parameters=_baseParameters; return; } - + _paramsExtracted = true; - // Handle query string - if (_uri!=null && _uri.hasQuery()) + try { - if (_queryEncoding==null) - _uri.decodeQueryTo(_baseParameters); - else + // Handle query string + if (_uri!=null && _uri.hasQuery()) { - try - { - _uri.decodeQueryTo(_baseParameters,_queryEncoding); - } - catch (UnsupportedEncodingException e) - { - if (LOG.isDebugEnabled()) - LOG.warn(e); - else - LOG.warn(e.toString()); - } - } - } - - // handle any _content. - String encoding = getCharacterEncoding(); - String content_type = getContentType(); - if (content_type != null && content_type.length() > 0) - { - content_type = HttpFields.valueParameters(content_type, null); - - if (MimeTypes.FORM_ENCODED.equalsIgnoreCase(content_type) && _inputState==__NONE && - (HttpMethods.POST.equals(getMethod()) || HttpMethods.PUT.equals(getMethod()))) - { - int content_length = getContentLength(); - if (content_length != 0) + if (_queryEncoding==null) + _uri.decodeQueryTo(_baseParameters); + else { try { - int maxFormContentSize=-1; - - if (_context!=null) - maxFormContentSize=_context.getContextHandler().getMaxFormContentSize(); - else - { - Integer size = (Integer)_connection.getConnector().getServer().getAttribute("org.eclipse.jetty.server.Request.maxFormContentSize"); - if (size!=null) - maxFormContentSize =size.intValue(); - } - - if (content_length>maxFormContentSize && maxFormContentSize > 0) - { - throw new IllegalStateException("Form too large"+content_length+">"+maxFormContentSize); - } - InputStream in = getInputStream(); - - // Add form params to query params - UrlEncoded.decodeTo(in, _baseParameters, encoding,content_length<0?maxFormContentSize:-1); + _uri.decodeQueryTo(_baseParameters,_queryEncoding); } - catch (IOException e) + catch (UnsupportedEncodingException e) { if (LOG.isDebugEnabled()) LOG.warn(e); @@ -267,23 +224,75 @@ public class Request implements HttpServletRequest } } } - } - - if (_parameters==null) - _parameters=_baseParameters; - else if (_parameters!=_baseParameters) - { - // Merge parameters (needed if parameters extracted after a forward). - Iterator iter = _baseParameters.entrySet().iterator(); - while (iter.hasNext()) + + // handle any _content. + String encoding = getCharacterEncoding(); + String content_type = getContentType(); + if (content_type != null && content_type.length() > 0) { - Map.Entry entry = (Map.Entry)iter.next(); - String name=(String)entry.getKey(); - Object values=entry.getValue(); - for (int i=0;imaxFormContentSize && maxFormContentSize > 0) + { + throw new IllegalStateException("Form too large"+content_length+">"+maxFormContentSize); + } + InputStream in = getInputStream(); + + // Add form params to query params + UrlEncoded.decodeTo(in, _baseParameters, encoding,content_length<0?maxFormContentSize:-1); + } + catch (IOException e) + { + if (LOG.isDebugEnabled()) + LOG.warn(e); + else + LOG.warn(e.toString()); + } + } + } } - } + + if (_parameters==null) + _parameters=_baseParameters; + else if (_parameters!=_baseParameters) + { + // Merge parameters (needed if parameters extracted after a forward). + Iterator iter = _baseParameters.entrySet().iterator(); + while (iter.hasNext()) + { + Map.Entry entry = (Map.Entry)iter.next(); + String name=(String)entry.getKey(); + Object values=entry.getValue(); + for (int i=0;i Date: Mon, 19 Sep 2011 19:09:55 +1000 Subject: [PATCH 038/134] 353267 Request._parameters initialization bug Add some extra tests. --- .../src/test/java/org/eclipse/jetty/server/RequestTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java index 50bcd110c6e..bc938bc0b67 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.Reader; import java.util.ArrayList; import java.util.Arrays; +import java.util.Enumeration; import java.util.Map; import javax.servlet.ServletException; @@ -93,6 +94,10 @@ public class RequestTest map = request.getParameterMap(); assertFalse(map == null); assertTrue(map.isEmpty()); + + Enumeration names = request.getParameterNames(); + assertFalse(names.hasMoreElements()); + } return true; From 0949443fab7d9104277a72b6b79bf3cfb5b3acbe Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Sep 2011 12:59:22 +1000 Subject: [PATCH 039/134] 358164 Dispatch from servlet to handler --- .../org/eclipse/jetty/server/Dispatcher.java | 5 ++++ .../jetty/server/handler/ContextHandler.java | 2 +- .../jetty/server/handler/ResourceHandler.java | 27 ++++++++++++++++--- .../eclipse/jetty/servlet/ServletHandler.java | 5 +++- 4 files changed, 33 insertions(+), 6 deletions(-) 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 355fc46adaa..5422cb2662c 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 @@ -222,6 +222,7 @@ public class Dispatcher implements RequestDispatcher if (!(response instanceof HttpServletResponse)) response = new ServletResponseHttpWrapper(response); + final boolean old_handled=baseRequest.isHandled(); final String old_uri=baseRequest.getRequestURI(); final String old_context_path=baseRequest.getContextPath(); final String old_servlet_path=baseRequest.getServletPath(); @@ -233,6 +234,7 @@ public class Dispatcher implements RequestDispatcher try { + baseRequest.setHandled(false); baseRequest.setDispatcherType(dispatch); if (_named!=null) @@ -279,6 +281,8 @@ public class Dispatcher implements RequestDispatcher baseRequest.setRequestURI(_uri); baseRequest.setContextPath(_contextHandler.getContextPath()); + baseRequest.setServletPath(null); + baseRequest.setPathInfo(_uri); baseRequest.setAttributes(attr); _contextHandler.handle(_path,baseRequest, (HttpServletRequest)request, (HttpServletResponse)response); @@ -303,6 +307,7 @@ public class Dispatcher implements RequestDispatcher } finally { + baseRequest.setHandled(old_handled); baseRequest.setRequestURI(old_uri); baseRequest.setContextPath(old_context_path); baseRequest.setServletPath(old_servlet_path); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 42feb615a0c..46554a844bc 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -801,7 +801,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. String old_path_info = null; ClassLoader old_classloader = null; Thread current_thread = null; - String pathInfo = null; + String pathInfo = target; DispatcherType dispatch = baseRequest.getDispatcherType(); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 5d618165ed7..1d3f196c127 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -29,6 +29,7 @@ import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.WriterOutputStream; +import org.eclipse.jetty.server.Dispatcher; import org.eclipse.jetty.server.HttpConnection; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; @@ -292,10 +293,28 @@ public class ResourceHandler extends AbstractHandler /* ------------------------------------------------------------ */ protected Resource getResource(HttpServletRequest request) throws MalformedURLException { - String path_info=request.getPathInfo(); - if (path_info==null) - return null; - return getResource(path_info); + String servletPath; + String pathInfo; + Boolean included =request.getAttribute(Dispatcher.INCLUDE_REQUEST_URI)!=null; + if (included!=null && included.booleanValue()) + { + servletPath=(String)request.getAttribute(Dispatcher.INCLUDE_SERVLET_PATH); + pathInfo=(String)request.getAttribute(Dispatcher.INCLUDE_PATH_INFO); + if (servletPath==null) + { + servletPath=request.getServletPath(); + pathInfo=request.getPathInfo(); + } + } + else + { + included = Boolean.FALSE; + servletPath = request.getServletPath(); + pathInfo = request.getPathInfo(); + } + + String pathInContext=URIUtil.addPaths(servletPath,pathInfo); + return getResource(pathInContext); } diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java index 45df833bf51..72de75cf444 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java @@ -474,7 +474,6 @@ public class ServletHandler extends ScopedHandler res = ((ServletResponseHttpWrapper)res).getResponse(); // Do the filter/handling thang - baseRequest.setHandled(true); if (chain!=null) chain.doFilter(req, res); else @@ -583,6 +582,10 @@ public class ServletHandler extends ScopedHandler else LOG.debug("Response already committed for handling ",e); } + finally + { + baseRequest.setHandled(true); + } } /* ------------------------------------------------------------ */ From 978f06242b7dd5d8da8a99abfe9cbfc9f168b063 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Sep 2011 14:50:53 +1000 Subject: [PATCH 040/134] 357240 extra debug --- .../java/org/eclipse/jetty/server/AsyncHttpConnection.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index 52310ebf65d..adc3dc18e0b 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -139,6 +139,10 @@ public class AsyncHttpConnection extends HttpConnection { LOG.warn("Closing EndPoint making no progress: "+_total_no_progress+" "+_endp); _endp.close(); + if (_endp instanceof SelectChannelEndPoint) + { + System.err.println(((SelectChannelEndPoint)_endp).getSelectManager().dump()); + } } } } From 94d43e42297489aff4a9a5ab88215574385e24a7 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Sep 2011 15:19:19 +1000 Subject: [PATCH 041/134] 356274 Start SSL socket factory in call to open() --- .../eclipse/jetty/embedded/LikeJettyXml.java | 27 +++++++++++++++++++ .../jetty/server/ssl/SslSocketConnector.java | 22 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java index ce7329c2245..0caec484893 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java @@ -33,6 +33,7 @@ import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.server.handler.StatisticsHandler; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; +import org.eclipse.jetty.server.ssl.SslSocketConnector; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.thread.QueuedThreadPool; @@ -89,7 +90,33 @@ public class LikeJettyXml }); ssl_connector.setStatsOn(true); server.addConnector(ssl_connector); + ssl_connector.open(); + + SslSocketConnector ssls_connector = new SslSocketConnector(); + ssls_connector.setPort(8444); + cf = ssls_connector.getSslContextFactory(); + cf.setKeyStore(jetty_home + "/etc/keystore"); + cf.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); + cf.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g"); + cf.setTrustStore(jetty_home + "/etc/keystore"); + cf.setTrustStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); + cf.setExcludeCipherSuites( + new String[] { + "SSL_RSA_WITH_DES_CBC_SHA", + "SSL_DHE_RSA_WITH_DES_CBC_SHA", + "SSL_DHE_DSS_WITH_DES_CBC_SHA", + "SSL_RSA_EXPORT_WITH_RC4_40_MD5", + "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", + "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", + "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" + }); + ssls_connector.setStatsOn(true); + server.addConnector(ssls_connector); + ssls_connector.open(); + + + Ajp13SocketConnector ajp = new Ajp13SocketConnector(); ajp.setPort(8009); server.addConnector(ajp); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java index 1783f9aba0e..85c50bb4a94 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java @@ -30,6 +30,7 @@ import javax.net.ssl.SSLSocket; import org.eclipse.jetty.http.HttpSchemes; import org.eclipse.jetty.http.ssl.SslContextFactory; import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.io.bio.SocketEndPoint; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.bio.SocketConnector; @@ -67,6 +68,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector this(new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH)); } + /* ------------------------------------------------------------ */ public SslSocketConnector(SslContextFactory sslContextFactory) { _sslContextFactory = sslContextFactory; @@ -329,6 +331,26 @@ public class SslSocketConnector extends SocketConnector implements SslConnector return integralPort == 0 || integralPort == request.getServerPort(); } + /* ------------------------------------------------------------ */ + @Override + public void open() throws IOException + { + if (!_sslContextFactory.checkConfig()) + { + throw new IllegalStateException("SSL context is not configured correctly."); + } + + try + { + _sslContextFactory.start(); + } + catch(Exception e) + { + throw new RuntimeIOException(e); + } + super.open(); + } + /* ------------------------------------------------------------ */ /** * {@inheritDoc} From dacb8962f00cf3668b14e0a65a055f3f16593e71 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Sep 2011 15:23:25 +1000 Subject: [PATCH 042/134] 356144 Allow SelectorManager thread priority to be set --- .../eclipse/jetty/server/nio/SelectChannelConnector.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java index c8cff99341c..9a4f8f03bcf 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java @@ -133,6 +133,12 @@ public class SelectChannelConnector extends AbstractNIOConnector super.persist(endpoint); } + /* ------------------------------------------------------------ */ + public SelectorManager getSelectorManager() + { + return _manager; + } + /* ------------------------------------------------------------ */ public Object getConnection() { From 57bd9f3bced17a05b837d1285dcef20eb671ee94 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Sep 2011 17:04:01 +1000 Subject: [PATCH 043/134] 336443 Check nonce count is increasing --- .../jetty/embedded/SecuredHelloHandler.java | 5 +- .../authentication/DigestAuthenticator.java | 164 +++++++++--------- 2 files changed, 83 insertions(+), 86 deletions(-) diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java index 7224824cb3e..5d2547e3f1b 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java @@ -23,13 +23,14 @@ import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.security.LoginService; import org.eclipse.jetty.security.authentication.BasicAuthenticator; +import org.eclipse.jetty.security.authentication.DigestAuthenticator; import org.eclipse.jetty.server.Server; public class SecuredHelloHandler { public static void main(String[] args) throws Exception { - Server server = new Server(0); + Server server = new Server(8080); LoginService loginService = new HashLoginService("MyRealm","src/test/resources/realm.properties"); server.addBean(loginService); @@ -51,7 +52,7 @@ public class SecuredHelloHandler knownRoles.add("admin"); security.setConstraintMappings(Collections.singletonList(mapping), knownRoles); - security.setAuthenticator(new BasicAuthenticator()); + security.setAuthenticator(new DigestAuthenticator()); security.setLoginService(loginService); security.setStrict(false); diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java index 7fa563a8502..ee9f5625aeb 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java @@ -15,6 +15,12 @@ package org.eclipse.jetty.security.authentication; import java.io.IOException; import java.security.MessageDigest; +import java.security.SecureRandom; +import java.util.Queue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicInteger; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; @@ -42,17 +48,29 @@ import org.eclipse.jetty.util.log.Logger; /** * @version $Rev: 4793 $ $Date: 2009-03-19 00:00:01 +0100 (Thu, 19 Mar 2009) $ * - * The nonce max age can be set with the {@link SecurityHandler#setInitParameter(String, String)} + * The nonce max age in ms can be set with the {@link SecurityHandler#setInitParameter(String, String)} * using the name "maxNonceAge" */ public class DigestAuthenticator extends LoginAuthenticator { private static final Logger LOG = Log.getLogger(DigestAuthenticator.class); + SecureRandom _random = new SecureRandom(); + private long _maxNonceAgeMs = 60*1000; + private ConcurrentMap _nonceCount = new ConcurrentHashMap(); + private Queue _nonceQueue = new ConcurrentLinkedQueue(); + private static class Nonce + { + final String _nonce; + final long _ts; + AtomicInteger _nc=new AtomicInteger(); + public Nonce(String nonce, long ts) + { + _nonce=nonce; + _ts=ts; + } + } - protected long _maxNonceAge = 0; - protected long _nonceSecret = this.hashCode() ^ System.currentTimeMillis(); - protected boolean _useStale = false; - + /* ------------------------------------------------------------ */ public DigestAuthenticator() { super(); @@ -69,19 +87,22 @@ public class DigestAuthenticator extends LoginAuthenticator String mna=configuration.getInitParameter("maxNonceAge"); if (mna!=null) - _maxNonceAge=Long.valueOf(mna); + _maxNonceAgeMs=Long.valueOf(mna); } + /* ------------------------------------------------------------ */ public String getAuthMethod() { return Constraint.__DIGEST_AUTH; } - + + /* ------------------------------------------------------------ */ public boolean secureResponse(ServletRequest req, ServletResponse res, boolean mandatory, User validatedUser) throws ServerAuthException { return true; } + /* ------------------------------------------------------------ */ public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException { if (!mandatory) @@ -144,7 +165,7 @@ public class DigestAuthenticator extends LoginAuthenticator } } - int n = checkNonce(digest.nonce, (Request)request); + int n = checkNonce(digest,(Request)request); if (n > 0) { @@ -171,7 +192,7 @@ public class DigestAuthenticator extends LoginAuthenticator + "\", nonce=\"" + newNonce((Request)request) + "\", algorithm=MD5, qop=\"auth\"" - + (_useStale ? (" stale=" + stale) : "")); + + " stale=" + stale); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); return Authentication.SEND_CONTINUE; @@ -186,87 +207,59 @@ public class DigestAuthenticator extends LoginAuthenticator } + /* ------------------------------------------------------------ */ public String newNonce(Request request) { - long ts=request.getTimeStamp(); - long sk = _nonceSecret; - - byte[] nounce = new byte[24]; - for (int i = 0; i < 8; i++) + Nonce nonce; + + do { - nounce[i] = (byte) (ts & 0xff); - ts = ts >> 8; - nounce[8 + i] = (byte) (sk & 0xff); - sk = sk >> 8; - } + byte[] nounce = new byte[24]; + _random.nextBytes(nounce); - byte[] hash = null; - try - { - MessageDigest md = MessageDigest.getInstance("MD5"); - md.reset(); - md.update(nounce, 0, 16); - hash = md.digest(); + nonce = new Nonce(new String(B64Code.encode(nounce)),request.getTimeStamp()); } - catch (Exception e) - { - LOG.warn(e); - } - - for (int i = 0; i < hash.length; i++) - { - nounce[8 + i] = hash[i]; - if (i == 23) break; - } - - return new String(B64Code.encode(nounce)); + while (_nonceCount.putIfAbsent(nonce._nonce,nonce)!=null); + _nonceQueue.add(nonce); + + return nonce._nonce; } /** - * @param nonce nonce to check + * @param nstring nonce to check * @param request * @return -1 for a bad nonce, 0 for a stale none, 1 for a good nonce */ /* ------------------------------------------------------------ */ - private int checkNonce(String nonce, Request request) + private int checkNonce(Digest digest, Request request) { + // firstly let's expire old nonces + long expired = request.getTimeStamp()-_maxNonceAgeMs; + + Nonce nonce=_nonceQueue.peek(); + while (nonce!=null && nonce._ts> 8; - ts = (ts << 8) + (0xff & (long) n[7 - i]); - } - - long age = request.getTimeStamp() - ts; - if (LOG.isDebugEnabled()) LOG.debug("age=" + age); - - byte[] hash = null; - try - { - MessageDigest md = MessageDigest.getInstance("MD5"); - md.reset(); - md.update(n2, 0, 16); - hash = md.digest(); - } - catch (Exception e) - { - LOG.warn(e); - } - - for (int i = 0; i < 16; i++) - if (n[i + 8] != hash[i]) return -1; - - if (_maxNonceAge > 0 && (age < 0 || age > _maxNonceAge)) return 0; // stale - + nonce = _nonceCount.get(digest.nonce); + if (nonce==null) + return 0; + + long count = Long.parseLong(digest.nc,16); + if (count>Integer.MAX_VALUE) + return 0; + int old=nonce._nc.get(); + while (!nonce._nc.compareAndSet(old,(int)count)) + old=nonce._nc.get(); + if (count<=old) + return -1; + return 1; } catch (Exception e) @@ -276,18 +269,21 @@ public class DigestAuthenticator extends LoginAuthenticator return -1; } + /* ------------------------------------------------------------ */ + /* ------------------------------------------------------------ */ + /* ------------------------------------------------------------ */ private static class Digest extends Credential { private static final long serialVersionUID = -2484639019549527724L; - String method = null; - String username = null; - String realm = null; - String nonce = null; - String nc = null; - String cnonce = null; - String qop = null; - String uri = null; - String response = null; + String method = ""; + String username = ""; + String realm = ""; + String nonce = ""; + String nc = ""; + String cnonce = ""; + String qop = ""; + String uri = ""; + String response = ""; /* ------------------------------------------------------------ */ Digest(String m) From b7b567d86d0f297b3e38a166ac738f1fd84df474 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Sep 2011 17:16:58 +1000 Subject: [PATCH 044/134] 353627 Basic Auth checks that Basic method has been send --- .../jetty/embedded/SecuredHelloHandler.java | 3 +- .../authentication/BasicAuthenticator.java | 32 ++++++++++++------- .../authentication/DigestAuthenticator.java | 2 +- .../jetty/security/ConstraintTest.java | 30 ++++++++--------- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java index 5d2547e3f1b..33c00e7a69b 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/SecuredHelloHandler.java @@ -23,7 +23,6 @@ import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.security.LoginService; import org.eclipse.jetty.security.authentication.BasicAuthenticator; -import org.eclipse.jetty.security.authentication.DigestAuthenticator; import org.eclipse.jetty.server.Server; public class SecuredHelloHandler @@ -52,7 +51,7 @@ public class SecuredHelloHandler knownRoles.add("admin"); security.setConstraintMappings(Collections.singletonList(mapping), knownRoles); - security.setAuthenticator(new DigestAuthenticator()); + security.setAuthenticator(new BasicAuthenticator()); security.setLoginService(loginService); security.setStrict(false); diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/BasicAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/BasicAuthenticator.java index e680644609f..372f9b63ea0 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/BasicAuthenticator.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/BasicAuthenticator.java @@ -65,20 +65,28 @@ public class BasicAuthenticator extends LoginAuthenticator return _deferred; if (credentials != null) - { - credentials = credentials.substring(credentials.indexOf(' ')+1); - credentials = B64Code.decode(credentials,StringUtil.__ISO_8859_1); - int i = credentials.indexOf(':'); - if (i>0) + { + int space=credentials.indexOf(' '); + if (space>0) { - String username = credentials.substring(0,i); - String password = credentials.substring(i+1); - - UserIdentity user = _loginService.login(username,password); - if (user!=null) + String method=credentials.substring(0,space); + if ("basic".equalsIgnoreCase(method)) { - renewSessionOnAuthentication(request,response); - return new UserAuthentication(getAuthMethod(),user); + credentials = credentials.substring(space+1); + credentials = B64Code.decode(credentials,StringUtil.__ISO_8859_1); + int i = credentials.indexOf(':'); + if (i>0) + { + String username = credentials.substring(0,i); + String password = credentials.substring(i+1); + + UserIdentity user = _loginService.login(username,password); + if (user!=null) + { + renewSessionOnAuthentication(request,response); + return new UserAuthentication(getAuthMethod(),user); + } + } } } } diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java index ee9f5625aeb..ac4ebe2ea30 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java @@ -275,7 +275,7 @@ public class DigestAuthenticator extends LoginAuthenticator private static class Digest extends Credential { private static final long serialVersionUID = -2484639019549527724L; - String method = ""; + final String method; String username = ""; String realm = ""; String nonce = ""; 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 9a40357de9e..19eb3099011 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 @@ -201,13 +201,13 @@ public class ConstraintTest assertTrue(response.indexOf("WWW-Authenticate: basic realm=\"TestRealm\"") > 0); response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user:wrong") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user:wrong") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 401 Unauthorized")); assertTrue(response.indexOf("WWW-Authenticate: basic realm=\"TestRealm\"") > 0); response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -218,20 +218,20 @@ public class ConstraintTest assertTrue(response.indexOf("WWW-Authenticate: basic realm=\"TestRealm\"") > 0); response = _connector.getResponses("GET /ctx/admin/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("admin:wrong") + "\r\n" + + "Authorization: Basic " + B64Code.encode("admin:wrong") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 401 Unauthorized")); assertTrue(response.indexOf("WWW-Authenticate: basic realm=\"TestRealm\"") > 0); response = _connector.getResponses("GET /ctx/admin/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 403 ")); assertTrue(response.indexOf("!role") > 0); response = _connector.getResponses("GET /ctx/admin/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("admin:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("admin:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -490,18 +490,18 @@ public class ConstraintTest assertTrue(response.indexOf("WWW-Authenticate: basic realm=\"TestRealm\"") > 0); response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user:wrong") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user:wrong") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 401 Unauthorized")); assertTrue(response.indexOf("WWW-Authenticate: basic realm=\"TestRealm\"") > 0); response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 403")); response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user2:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user2:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -512,20 +512,20 @@ public class ConstraintTest assertTrue(response.indexOf("WWW-Authenticate: basic realm=\"TestRealm\"") > 0); response = _connector.getResponses("GET /ctx/admin/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("admin:wrong") + "\r\n" + + "Authorization: Basic " + B64Code.encode("admin:wrong") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 401 Unauthorized")); assertTrue(response.indexOf("WWW-Authenticate: basic realm=\"TestRealm\"") > 0); response = _connector.getResponses("GET /ctx/admin/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 403 ")); assertTrue(response.indexOf("!role") > 0); response = _connector.getResponses("GET /ctx/admin/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("admin:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("admin:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -776,7 +776,7 @@ public class ConstraintTest assertTrue(response.startsWith("HTTP/1.1 200 OK")); response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user2:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user2:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 500 ")); @@ -789,7 +789,7 @@ public class ConstraintTest _server.start(); response = _connector.getResponses("GET /ctx/auth/info HTTP/1.0\r\n" + - "Authorization: " + B64Code.encode("user2:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("user2:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 200 OK")); } @@ -809,13 +809,13 @@ public class ConstraintTest assertTrue(response.indexOf("user=null") > 0); response = _connector.getResponses("GET /ctx/noauth/info HTTP/1.0\r\n"+ - "Authorization: " + B64Code.encode("admin:wrong") + "\r\n" + + "Authorization: Basic " + B64Code.encode("admin:wrong") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 200 OK")); assertTrue(response.indexOf("user=null") > 0); response = _connector.getResponses("GET /ctx/noauth/info HTTP/1.0\r\n"+ - "Authorization: " + B64Code.encode("admin:password") + "\r\n" + + "Authorization: Basic " + B64Code.encode("admin:password") + "\r\n" + "\r\n"); assertTrue(response.startsWith("HTTP/1.1 200 OK")); assertTrue(response.indexOf("user=admin") > 0); From 26c8cc851452b7a2f1abf21db55535b21aad6917 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 20 Sep 2011 18:00:24 +1000 Subject: [PATCH 045/134] 346419 testing HttpClient FDs --- .../org/eclipse/jetty/client/HttpClient.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index 85b16242c91..99b4a07dfa1 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 @@ -182,6 +182,15 @@ public class HttpClient extends HttpBuffers implements Attributes, Dumpable */ public ThreadPool getThreadPool() { + if (_threadPool==null) + { + QueuedThreadPool pool = new QueuedThreadPool(); + pool.setMaxThreads(16); + pool.setDaemon(true); + pool.setName("HttpClient"); + _threadPool = pool; + } + return _threadPool; } @@ -420,13 +429,7 @@ public class HttpClient extends HttpBuffers implements Attributes, Dumpable _idleTimeoutQ.setNow(); if (_threadPool == null) - { - QueuedThreadPool pool = new QueuedThreadPool(); - pool.setMaxThreads(16); - pool.setDaemon(true); - pool.setName("HttpClient"); - _threadPool = pool; - } + getThreadPool(); if (_threadPool instanceof LifeCycle) { From 1e30a58419ef1b1f156be6f6d0158e7bd1622149 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Fri, 26 Aug 2011 19:34:37 +0200 Subject: [PATCH 046/134] HashLoginService code format --- .../jetty/security/HashLoginService.java | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) 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 5e5a8445863..0d6a7e45b7b 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 @@ -36,22 +36,18 @@ import org.eclipse.jetty.util.resource.Resource; /** * Properties User Realm. * - * An implementation of UserRealm that stores users and roles in-memory in - * HashMaps. + * An implementation of UserRealm that stores users and roles in-memory in HashMaps. *

    - * Typically these maps are populated by calling the load() method or passing a - * properties resource to the constructor. The format of the properties file is: + * Typically these maps are populated by calling the load() method or passing a properties resource to the constructor. The format of the properties file is: * *

      *  username: password [,rolename ...]
      * 
    * - * Passwords may be clear text, obfuscated or checksummed. The class - * com.eclipse.Util.Password should be used to generate obfuscated passwords or - * password checksums. + * Passwords may be clear text, obfuscated or checksummed. The class com.eclipse.Util.Password should be used to generate obfuscated passwords or password + * checksums. * - * If DIGEST Authentication is used, the password must be in a recoverable - * format, either plain text or OBF:. + * If DIGEST Authentication is used, the password must be in a recoverable format, either plain text or OBF:. */ public class HashLoginService extends MappedLoginService { @@ -72,14 +68,14 @@ public class HashLoginService extends MappedLoginService { setName(name); } - + /* ------------------------------------------------------------ */ public HashLoginService(String name, String config) { setName(name); setConfig(config); } - + /* ------------------------------------------------------------ */ public String getConfig() { @@ -89,7 +85,7 @@ public class HashLoginService extends MappedLoginService /* ------------------------------------------------------------ */ public void getConfig(String config) { - _config=config; + _config = config; } /* ------------------------------------------------------------ */ @@ -100,11 +96,10 @@ public class HashLoginService extends MappedLoginService /* ------------------------------------------------------------ */ /** - * Load realm users from properties file. The property file maps usernames - * to password specs followed by an optional comma separated list of role - * names. + * Load realm users from properties file. The property file maps usernames to password specs followed by an optional comma separated list of role names. * - * @param config Filename or url of user properties file. + * @param config + * Filename or url of user properties file. */ public void setConfig(String config) { @@ -129,30 +124,31 @@ public class HashLoginService extends MappedLoginService { return null; } - + /* ------------------------------------------------------------ */ @Override public void loadUsers() throws IOException { - if (_config==null) + if (_config == null) return; _configResource = Resource.newResource(_config); if (LOG.isDebugEnabled()) LOG.debug("Load " + this + " from " + _config); + Properties properties = new Properties(); properties.load(_configResource.getInputStream()); Set known = new HashSet(); for (Map.Entry entry : properties.entrySet()) { - String username = ((String) entry.getKey()).trim(); - String credentials = ((String) entry.getValue()).trim(); + String username = ((String)entry.getKey()).trim(); + String credentials = ((String)entry.getValue()).trim(); String roles = null; int c = credentials.indexOf(','); if (c > 0) { roles = credentials.substring(c + 1).trim(); - credentials = credentials.substring(0, c).trim(); + credentials = credentials.substring(0,c).trim(); } if (username != null && username.length() > 0 && credentials != null && credentials.length() > 0) @@ -164,17 +160,16 @@ public class HashLoginService extends MappedLoginService putUser(username,Credential.getCredential(credentials),roleArray); } } - + Iterator users = _users.keySet().iterator(); - while(users.hasNext()) + while (users.hasNext()) { - String user=users.next(); + String user = users.next(); if (!known.contains(user)) users.remove(); } } - /* ------------------------------------------------------------ */ /** * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() @@ -182,7 +177,7 @@ public class HashLoginService extends MappedLoginService protected void doStart() throws Exception { super.doStart(); - + if (getRefreshInterval() > 0) { _scanner = new Scanner(); @@ -194,10 +189,11 @@ public class HashLoginService extends MappedLoginService { public boolean accept(File dir, String name) { - File f = new File(dir, name); + File f = new File(dir,name); try { - if (f.compareTo(_configResource.getFile()) == 0) return true; + if (f.compareTo(_configResource.getFile()) == 0) + return true; } catch (IOException e) { @@ -212,8 +208,10 @@ public class HashLoginService extends MappedLoginService { public void filesChanged(List filenames) throws Exception { - if (filenames == null) return; - if (filenames.isEmpty()) return; + if (filenames == null) + return; + if (filenames.isEmpty()) + return; if (filenames.size() == 1) { Resource r = Resource.newResource(filenames.get(0)); @@ -241,9 +239,9 @@ public class HashLoginService extends MappedLoginService protected void doStop() throws Exception { super.doStop(); - if (_scanner != null) _scanner.stop(); + if (_scanner != null) + _scanner.stop(); _scanner = null; } - } From 95ee2157bddc7fe60a43591a160d49383078d64e Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Fri, 26 Aug 2011 19:35:51 +0200 Subject: [PATCH 047/134] JETTY-1414 applied to PropertyUserStore --- .../org/eclipse/jetty/security/PropertyUserStore.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 5e463165103..7f49893030d 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 @@ -201,15 +201,17 @@ public class PropertyUserStore extends AbstractLifeCycle _scanner.addListener(new BulkListener() { - public void filesChanged(List filenames) throws Exception + public void filesChanged(List filenames) throws Exception { if (filenames == null) return; if (filenames.isEmpty()) return; - if (filenames.size() == 1 && filenames.get(0).equals(getConfigResource().getFile().getAbsolutePath())) + if (filenames.size() == 1) { - loadUsers(); + Resource r = Resource.newResource(filenames.get(0)); + if (r.getFile().equals(_configResource.getFile())) + loadUsers(); } } From 129a66f57918b972df7674c94180a687977f7b26 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Fri, 26 Aug 2011 19:58:15 +0200 Subject: [PATCH 048/134] 323311: HashLoginService uses PropertyUserStore now --- .../jetty/security/HashLoginService.java | 128 ++++-------------- 1 file changed, 27 insertions(+), 101 deletions(-) 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 0d6a7e45b7b..ab73707e1ce 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 @@ -13,21 +13,12 @@ package org.eclipse.jetty.security; -import java.io.File; -import java.io.FilenameFilter; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; import org.eclipse.jetty.http.security.Credential; +import org.eclipse.jetty.security.PropertyUserStore.UserListener; import org.eclipse.jetty.server.UserIdentity; import org.eclipse.jetty.util.Scanner; -import org.eclipse.jetty.util.Scanner.BulkListener; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.resource.Resource; @@ -49,10 +40,11 @@ import org.eclipse.jetty.util.resource.Resource; * * If DIGEST Authentication is used, the password must be in a recoverable format, either plain text or OBF:. */ -public class HashLoginService extends MappedLoginService +public class HashLoginService extends MappedLoginService implements UserListener { private static final Logger LOG = Log.getLogger(HashLoginService.class); + private PropertyUserStore _propertyUserStore; private String _config; private Resource _configResource; private Scanner _scanner; @@ -129,45 +121,7 @@ public class HashLoginService extends MappedLoginService @Override public void loadUsers() throws IOException { - if (_config == null) - return; - _configResource = Resource.newResource(_config); - - if (LOG.isDebugEnabled()) LOG.debug("Load " + this + " from " + _config); - - Properties properties = new Properties(); - properties.load(_configResource.getInputStream()); - Set known = new HashSet(); - - for (Map.Entry entry : properties.entrySet()) - { - String username = ((String)entry.getKey()).trim(); - String credentials = ((String)entry.getValue()).trim(); - String roles = null; - int c = credentials.indexOf(','); - if (c > 0) - { - roles = credentials.substring(c + 1).trim(); - credentials = credentials.substring(0,c).trim(); - } - - if (username != null && username.length() > 0 && credentials != null && credentials.length() > 0) - { - String[] roleArray = IdentityService.NO_ROLES; - if (roles != null && roles.length() > 0) - roleArray = roles.split(","); - known.add(username); - putUser(username,Credential.getCredential(credentials),roleArray); - } - } - - Iterator users = _users.keySet().iterator(); - while (users.hasNext()) - { - String user = users.next(); - if (!known.contains(user)) - users.remove(); - } + // TODO: Consider refactoring MappedLoginService to not have to override with unused methods } /* ------------------------------------------------------------ */ @@ -177,58 +131,15 @@ public class HashLoginService extends MappedLoginService protected void doStart() throws Exception { super.doStart(); - - if (getRefreshInterval() > 0) + if (_propertyUserStore == null) { - _scanner = new Scanner(); - _scanner.setScanInterval(getRefreshInterval()); - List dirList = new ArrayList(1); - dirList.add(_configResource.getFile()); - _scanner.setScanDirs(dirList); - _scanner.setFilenameFilter(new FilenameFilter() - { - public boolean accept(File dir, String name) - { - File f = new File(dir,name); - try - { - if (f.compareTo(_configResource.getFile()) == 0) - return true; - } - catch (IOException e) - { - return false; - } - - return false; - } - - }); - _scanner.addListener(new BulkListener() - { - public void filesChanged(List filenames) throws Exception - { - if (filenames == null) - return; - if (filenames.isEmpty()) - return; - if (filenames.size() == 1) - { - Resource r = Resource.newResource(filenames.get(0)); - if (r.getFile().equals(_configResource.getFile())) - loadUsers(); - } - } - - public String toString() - { - return "HashLoginService$Scanner"; - } - - }); - _scanner.setReportExistingFilesOnStartup(false); - _scanner.setRecursive(false); - _scanner.start(); + if(Log.isDebugEnabled()) + Log.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " refreshInterval: " + _refreshInterval); + _propertyUserStore = new PropertyUserStore(); + _propertyUserStore.setRefreshInterval(_refreshInterval); + _propertyUserStore.setConfig(_config); + _propertyUserStore.registerUserListener(this); + _propertyUserStore.start(); } } @@ -243,5 +154,20 @@ public class HashLoginService extends MappedLoginService _scanner.stop(); _scanner = null; } + + /* ------------------------------------------------------------ */ + public void update(String userName, Credential credential, String[] roleArray) + { + if (Log.isDebugEnabled()) + Log.debug("update: " + userName + " Roles: " + roleArray.length); + putUser(userName,credential,roleArray); + } + /* ------------------------------------------------------------ */ + public void remove(String userName) + { + if (Log.isDebugEnabled()) + Log.debug("remove: " + userName); + removeUser(userName); + } } From df0aab1f49b395fe4bb903fcef2c3d214a79dc9e Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Fri, 26 Aug 2011 20:00:02 +0200 Subject: [PATCH 049/134] PropertyUserStore: Code Format --- .../jaas/spi/PropertyFileLoginModule.java | 98 +++++++++---------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java index 67a207042ff..b10342e303d 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java @@ -31,108 +31,104 @@ import org.eclipse.jetty.util.log.Logger; /** * PropertyFileLoginModule - * - * + * + * */ public class PropertyFileLoginModule extends AbstractLoginModule { private static final Logger LOG = Log.getLogger(PropertyFileLoginModule.class); public static final String DEFAULT_FILENAME = "realm.properties"; - public static final Map> fileMap = new HashMap>(); - - private String propertyFileName; - - + public static final Map> fileMap = new HashMap>(); - /** + private String propertyFileName; + + /** * Read contents of the configured property file. * - * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map) + * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, + * java.util.Map) * @param subject * @param callbackHandler * @param sharedState * @param options */ - public void initialize(Subject subject, CallbackHandler callbackHandler, - Map sharedState, Map options) + public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { - super.initialize(subject, callbackHandler, sharedState, options); + super.initialize(subject,callbackHandler,sharedState,options); loadProperties((String)options.get("file")); } - - - - public void loadProperties (String filename) + + public void loadProperties(String filename) { File propsFile; - + if (filename == null) { - propsFile = new File(System.getProperty("user.dir"), DEFAULT_FILENAME); - //look for a file called realm.properties in the current directory - //if that fails, look for a file called realm.properties in $jetty.home/etc + propsFile = new File(System.getProperty("user.dir"),DEFAULT_FILENAME); + // look for a file called realm.properties in the current directory + // if that fails, look for a file called realm.properties in $jetty.home/etc if (!propsFile.exists()) - propsFile = new File(System.getProperty("jetty.home"), DEFAULT_FILENAME); + propsFile = new File(System.getProperty("jetty.home"),DEFAULT_FILENAME); } else { propsFile = new File(filename); } - - //give up, can't find a property file to load + + // give up, can't find a property file to load if (!propsFile.exists()) { LOG.warn("No property file found"); throw new IllegalStateException ("No property file specified in login module configuration file"); } - - - + try { this.propertyFileName = propsFile.getCanonicalPath(); if (fileMap.get(propertyFileName) != null) { - if (LOG.isDebugEnabled()) {LOG.debug("Properties file "+propertyFileName+" already in cache, skipping load");} + if (Log.isDebugEnabled()) + { + Log.debug("Properties file " + propertyFileName + " already in cache, skipping load"); + } return; } - + Map userInfoMap = new HashMap(); Properties props = new Properties(); props.load(new FileInputStream(propsFile)); - Iterator> iter = props.entrySet().iterator(); - while(iter.hasNext()) + Iterator> iter = props.entrySet().iterator(); + while (iter.hasNext()) { - - Map.Entry entry = iter.next(); - String username=entry.getKey().toString().trim(); - String credentials=entry.getValue().toString().trim(); - String roles=null; - int c=credentials.indexOf(','); - if (c>0) + + Map.Entry entry = iter.next(); + String username = entry.getKey().toString().trim(); + String credentials = entry.getValue().toString().trim(); + String roles = null; + int c = credentials.indexOf(','); + if (c > 0) { - roles=credentials.substring(c+1).trim(); - credentials=credentials.substring(0,c).trim(); + roles = credentials.substring(c + 1).trim(); + credentials = credentials.substring(0,c).trim(); } - if (username!=null && username.length()>0 && - credentials!=null && credentials.length()>0) + if (username != null && username.length() > 0 && credentials != null && credentials.length() > 0) { ArrayList roleList = new ArrayList(); - if(roles!=null && roles.length()>0) + if (roles != null && roles.length() > 0) { StringTokenizer tok = new StringTokenizer(roles,", "); - + while (tok.hasMoreTokens()) roleList.add(tok.nextToken()); } - - userInfoMap.put(username, (new UserInfo(username, Credential.getCredential(credentials.toString()), roleList))); + + userInfoMap.put(username,(new UserInfo(username,Credential.getCredential(credentials.toString()),roleList))); } } - - fileMap.put(propertyFileName, userInfoMap); + + fileMap.put(propertyFileName,userInfoMap); } catch (Exception e) { @@ -141,13 +137,13 @@ public class PropertyFileLoginModule extends AbstractLoginModule } } - /** - * Don't implement this as we want to pre-fetch all of the - * users. + /** + * Don't implement this as we want to pre-fetch all of the users. + * * @param username * @throws Exception */ - public UserInfo getUserInfo (String username) throws Exception + public UserInfo getUserInfo(String username) throws Exception { Map userInfoMap = (Map)fileMap.get(propertyFileName); if (userInfoMap == null) From c17552ee50090a02dc11328dd31d4a5cd662d9cf Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 13 Sep 2011 15:44:37 -0500 Subject: [PATCH 050/134] [323311] apply 5th patch of thomas, also removed extra method on IdentityService since it appears not needed, moved behavior to loadUsers() method instead. --- .../jaas/spi/PropertyFileLoginModule.java | 133 +++++++----------- .../security/DefaultIdentityService.java | 3 + .../jetty/security/HashLoginService.java | 15 +- .../jetty/security/IdentityService.java | 2 +- .../jetty/security/PropertyUserStore.java | 38 ++++- .../jetty/security/PropertyUserStoreTest.java | 7 + 6 files changed, 105 insertions(+), 93 deletions(-) diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java index b10342e303d..d3e69878cc1 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java @@ -13,19 +13,18 @@ package org.eclipse.jetty.plus.jaas.spi; -import java.io.File; -import java.io.FileInputStream; -import java.util.ArrayList; +import java.security.Principal; +import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.Properties; -import java.util.StringTokenizer; +import java.util.Set; import javax.security.auth.Subject; import javax.security.auth.callback.CallbackHandler; import org.eclipse.jetty.http.security.Credential; +import org.eclipse.jetty.security.PropertyUserStore; +import org.eclipse.jetty.server.UserIdentity; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -36,12 +35,14 @@ import org.eclipse.jetty.util.log.Logger; */ public class PropertyFileLoginModule extends AbstractLoginModule { + public static final String DEFAULT_FILENAME = "realm.properties"; + private static final Logger LOG = Log.getLogger(PropertyFileLoginModule.class); - public static final String DEFAULT_FILENAME = "realm.properties"; - public static final Map> fileMap = new HashMap>(); + private static Map _propertyUserStores = new HashMap(); - private String propertyFileName; + private int _refreshInterval = 0; + private String _filename = DEFAULT_FILENAME; /** * Read contents of the configured property file. @@ -56,99 +57,61 @@ public class PropertyFileLoginModule extends AbstractLoginModule public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { super.initialize(subject,callbackHandler,sharedState,options); - loadProperties((String)options.get("file")); + setupPropertyUserStore(options); } - public void loadProperties(String filename) + private void setupPropertyUserStore(Map options) { - File propsFile; + if (_propertyUserStores.get(_filename) == null) + { + parseConfig(options); - if (filename == null) - { - propsFile = new File(System.getProperty("user.dir"),DEFAULT_FILENAME); - // look for a file called realm.properties in the current directory - // if that fails, look for a file called realm.properties in $jetty.home/etc - if (!propsFile.exists()) - propsFile = new File(System.getProperty("jetty.home"),DEFAULT_FILENAME); - } - else - { - propsFile = new File(filename); - } + PropertyUserStore _propertyUserStore = new PropertyUserStore(); + _propertyUserStore.setConfig(_filename); + _propertyUserStore.setRefreshInterval(_refreshInterval); + LOG.debug("setupPropertyUserStore: Starting new PropertyUserStore. PropertiesFile: " + _filename + " refreshInterval: " + _refreshInterval); - // give up, can't find a property file to load - if (!propsFile.exists()) - { - LOG.warn("No property file found"); - throw new IllegalStateException ("No property file specified in login module configuration file"); - } - - try - { - this.propertyFileName = propsFile.getCanonicalPath(); - if (fileMap.get(propertyFileName) != null) + try { - if (Log.isDebugEnabled()) - { - Log.debug("Properties file " + propertyFileName + " already in cache, skipping load"); - } - return; + _propertyUserStore.start(); + } + catch (Exception e) + { + LOG.warn("Exception while starting propertyUserStore: ",e); } - Map userInfoMap = new HashMap(); - Properties props = new Properties(); - props.load(new FileInputStream(propsFile)); - Iterator> iter = props.entrySet().iterator(); - while (iter.hasNext()) - { - - Map.Entry entry = iter.next(); - String username = entry.getKey().toString().trim(); - String credentials = entry.getValue().toString().trim(); - String roles = null; - int c = credentials.indexOf(','); - if (c > 0) - { - roles = credentials.substring(c + 1).trim(); - credentials = credentials.substring(0,c).trim(); - } - - if (username != null && username.length() > 0 && credentials != null && credentials.length() > 0) - { - ArrayList roleList = new ArrayList(); - if (roles != null && roles.length() > 0) - { - StringTokenizer tok = new StringTokenizer(roles,", "); - - while (tok.hasMoreTokens()) - roleList.add(tok.nextToken()); - } - - userInfoMap.put(username,(new UserInfo(username,Credential.getCredential(credentials.toString()),roleList))); - } - } - - fileMap.put(propertyFileName,userInfoMap); - } - catch (Exception e) - { - LOG.warn("Error loading properties from file", e); - throw new RuntimeException(e); + _propertyUserStores.put(_filename,_propertyUserStore); } } + private void parseConfig(Map options) + { + _filename = (String)options.get("file") != null?(String)options.get("file"):DEFAULT_FILENAME; + String refreshIntervalString = (String)options.get("refreshInterval"); + _refreshInterval = refreshIntervalString == null?_refreshInterval:Integer.parseInt(refreshIntervalString); + } + /** * Don't implement this as we want to pre-fetch all of the users. * - * @param username + * @param userName * @throws Exception */ - public UserInfo getUserInfo(String username) throws Exception + public UserInfo getUserInfo(String userName) throws Exception { - Map userInfoMap = (Map)fileMap.get(propertyFileName); - if (userInfoMap == null) + PropertyUserStore propertyUserStore = _propertyUserStores.get(_filename); + if (propertyUserStore == null) + throw new IllegalStateException("PropertyUserStore should never be null here!"); + + UserIdentity userIdentity = propertyUserStore.getUserIdentity(userName); + if(userIdentity==null) return null; - return (UserInfo)userInfoMap.get(username); + + Set principals = userIdentity.getSubject().getPrincipals(); + String[] roles = principals.toArray(new String[principals.size()]); + Credential credential = (Credential)userIdentity.getSubject().getPrivateCredentials().iterator().next(); + LOG.debug("Found: " + userName + " in PropertyUserStore"); + return new UserInfo(userName, credential,Arrays.asList(roles)); } -} +} \ No newline at end of file diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/DefaultIdentityService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/DefaultIdentityService.java index 2b2b7462761..472da9c6654 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/DefaultIdentityService.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/DefaultIdentityService.java @@ -17,6 +17,9 @@ import java.security.Principal; import javax.security.auth.Subject; +import org.eclipse.jetty.http.security.Credential; +import org.eclipse.jetty.security.MappedLoginService.KnownUser; +import org.eclipse.jetty.security.MappedLoginService.RolePrincipal; import org.eclipse.jetty.server.UserIdentity; 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 ab73707e1ce..12b51f51502 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 @@ -131,10 +131,13 @@ public class HashLoginService extends MappedLoginService implements UserListener protected void doStart() throws Exception { super.doStart(); + if (_propertyUserStore == null) { - if(Log.isDebugEnabled()) - Log.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " refreshInterval: " + _refreshInterval); + if(LOG.isDebugEnabled()) + { + LOG.debug("doStart: Starting new PropertyUserStore. PropertiesFile: " + _config + " refreshInterval: " + _refreshInterval); + } _propertyUserStore = new PropertyUserStore(); _propertyUserStore.setRefreshInterval(_refreshInterval); _propertyUserStore.setConfig(_config); @@ -158,16 +161,16 @@ public class HashLoginService extends MappedLoginService implements UserListener /* ------------------------------------------------------------ */ public void update(String userName, Credential credential, String[] roleArray) { - if (Log.isDebugEnabled()) - Log.debug("update: " + userName + " Roles: " + roleArray.length); + if (LOG.isDebugEnabled()) + LOG.debug("update: " + userName + " Roles: " + roleArray.length); putUser(userName,credential,roleArray); } /* ------------------------------------------------------------ */ public void remove(String userName) { - if (Log.isDebugEnabled()) - Log.debug("remove: " + userName); + if (LOG.isDebugEnabled()) + LOG.debug("remove: " + userName); removeUser(userName); } } diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/IdentityService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/IdentityService.java index e05a000b2e0..216ae818d9b 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/IdentityService.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/IdentityService.java @@ -14,9 +14,9 @@ package org.eclipse.jetty.security; import java.security.Principal; - import javax.security.auth.Subject; +import org.eclipse.jetty.http.security.Credential; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.UserIdentity; 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 7f49893030d..b7e64ac123b 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 @@ -3,7 +3,9 @@ package org.eclipse.jetty.security; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; +import java.security.Principal; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -11,7 +13,12 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import javax.security.auth.Subject; + import org.eclipse.jetty.http.security.Credential; +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.Scanner; import org.eclipse.jetty.util.Scanner.BulkListener; import org.eclipse.jetty.util.component.AbstractLifeCycle; @@ -42,8 +49,10 @@ public class PropertyUserStore extends AbstractLifeCycle private Scanner _scanner; private int _refreshInterval = 0;// 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 _knownUsers = new ArrayList(); + private final Map _knownUserIdentities = new HashMap(); private List _listeners; /* ------------------------------------------------------------ */ @@ -57,6 +66,12 @@ public class PropertyUserStore extends AbstractLifeCycle { _config = config; } + + /* ------------------------------------------------------------ */ + public UserIdentity getUserIdentity(String userName) + { + return _knownUserIdentities.get(userName); + } /* ------------------------------------------------------------ */ /** @@ -119,9 +134,29 @@ public class PropertyUserStore extends AbstractLifeCycle { String[] roleArray = IdentityService.NO_ROLES; if (roles != null && roles.length() > 0) + { roleArray = roles.split(","); + } known.add(username); - notifyUpdate(username,Credential.getCredential(credentials),roleArray); + Credential credential = Credential.getCredential(credentials); + + Principal userPrincipal = new KnownUser(username,credential); + Subject subject = new Subject(); + subject.getPrincipals().add(userPrincipal); + subject.getPrivateCredentials().add(credential); + + if (roles != null) + { + for (String role : roleArray) + { + subject.getPrincipals().add(new RolePrincipal(role)); + } + } + + subject.setReadOnly(); + + _knownUserIdentities.put(username,_identityService.newUserIdentity(subject,userPrincipal,roleArray)); + notifyUpdate(username,credential,roleArray); } } @@ -138,6 +173,7 @@ public class PropertyUserStore extends AbstractLifeCycle String user = users.next(); if (!known.contains(user)) { + _knownUserIdentities.remove(user); notifyRemove(user); } } diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java index dde1df50bc1..68220b8dbca 100644 --- a/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java +++ b/jetty-security/src/test/java/org/eclipse/jetty/security/PropertyUserStoreTest.java @@ -78,6 +78,9 @@ public class PropertyUserStoreTest store.start(); + Assert.assertNotNull("Failed to retrieve UserIdentity directly from PropertyUserStore", store.getUserIdentity("tom")); + Assert.assertNotNull("Failed to retrieve UserIdentity directly from PropertyUserStore", store.getUserIdentity("dick")); + Assert.assertNotNull("Failed to retrieve UserIdentity directly from PropertyUserStore", store.getUserIdentity("harry")); Assert.assertEquals(3,userCount.get()); } @@ -117,7 +120,11 @@ public class PropertyUserStoreTest long start = System.currentTimeMillis(); while (userCount.get() < 4 && (System.currentTimeMillis() - start) < 10000) + { Thread.sleep(10); + } + + Assert.assertNotNull("Failed to retrieve UserIdentity from PropertyUserStore directly", store.getUserIdentity("skip")); Assert.assertEquals(4,userCount.get()); Assert.assertTrue(users.contains("skip")); From 2ef624e9fa4c125b60b785bf358b111a07f20eab Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 20 Sep 2011 10:11:08 -0500 Subject: [PATCH 051/134] add resource dir for tests --- jetty-servlet/src/test/resources/dispatchTest/dispatch.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 jetty-servlet/src/test/resources/dispatchTest/dispatch.txt diff --git a/jetty-servlet/src/test/resources/dispatchTest/dispatch.txt b/jetty-servlet/src/test/resources/dispatchTest/dispatch.txt new file mode 100644 index 00000000000..f3a34851d44 --- /dev/null +++ b/jetty-servlet/src/test/resources/dispatchTest/dispatch.txt @@ -0,0 +1 @@ +text \ No newline at end of file From 3091739b70b9cca0e612fbb8d3cac6ab7b70851b Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 20 Sep 2011 11:47:17 -0500 Subject: [PATCH 052/134] remove plugin versions we get from parent and remove groupId --- pom.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pom.xml b/pom.xml index fcb8e146e5c..4b45232f305 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,6 @@ jetty-parent 19-SNAPSHOT - org.eclipse.jetty jetty-project 7.5.2-SNAPSHOT Jetty :: Project @@ -245,7 +244,6 @@ org.codehaus.mojo findbugs-maven-plugin - 2.3.2 true true @@ -260,12 +258,10 @@ org.apache.maven.plugins maven-jxr-plugin - 2.2 org.apache.maven.plugins maven-javadoc-plugin - 2.8 true true @@ -275,7 +271,6 @@ org.apache.maven.plugins maven-pmd-plugin - 2.5 @@ -286,12 +281,10 @@ org.apache.maven.plugins maven-jxr-plugin - 2.2 org.apache.maven.plugins maven-javadoc-plugin - 2.8 512m true @@ -302,7 +295,6 @@ org.apache.maven.plugins maven-pmd-plugin - 2.5 1.5 @@ -313,7 +305,6 @@ org.codehaus.mojo findbugs-maven-plugin - 2.3.2 From bc86f5d154f0482eb2b1316c7b6a0e0061b33a92 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 20 Sep 2011 14:08:30 -0500 Subject: [PATCH 053/134] update parent version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4b45232f305..9bbf848c240 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-parent - 19-SNAPSHOT + 19 jetty-project 7.5.2-SNAPSHOT From f6d26c20078fbf9df043c4a02fe1bf4b728a2c6f Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 20 Sep 2011 14:09:26 -0500 Subject: [PATCH 054/134] [Bug 358263] add method for osgi users to register a driver as Class.forName does not work for them --- .../server/session/JDBCSessionIdManager.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java index 8e73f3af1d0..ad5b244d761 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionIdManager.java @@ -18,6 +18,7 @@ import java.io.InputStream; import java.sql.Blob; import java.sql.Connection; import java.sql.DatabaseMetaData; +import java.sql.Driver; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -56,6 +57,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager protected final HashSet _sessionIds = new HashSet(); protected Server _server; + protected Driver _driver; protected String _driverClassName; protected String _connectionUrl; protected DataSource _datasource; @@ -184,6 +186,19 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager _connectionUrl=connectionUrl; } + /** + * Configure jdbc connection information via a jdbc Driver + * + * @param driverClass + * @param connectionUrl + */ + public void setDriverInfo (Driver driverClass, String connectionUrl) + { + _driver=driverClass; + _connectionUrl=connectionUrl; + } + + public String getDriverClassName() { return _driverClassName; @@ -461,7 +476,11 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager InitialContext ic = new InitialContext(); _datasource = (DataSource)ic.lookup(_jndiName); } - else if (_driverClassName!=null && _connectionUrl!=null) + else if ( _driver != null && _connectionUrl != null ) + { + DriverManager.registerDriver(_driver); + } + else if (_driverClassName != null && _connectionUrl != null) { Class.forName(_driverClassName); } From f0fe55165b6ff36c9440d3ba4272f64ebd232b10 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Tue, 20 Sep 2011 10:19:23 +0200 Subject: [PATCH 055/134] SelectConnector.java code format --- .../java/org/eclipse/jetty/client/SelectConnector.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index 333c4166ba4..f070951407e 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -103,12 +103,12 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector } else { - channel.configureBlocking( false ); + channel.configureBlocking(false); channel.connect(address.toSocketAddress()); - _selectorManager.register( channel, destination ); - ConnectTimeout connectTimeout = new ConnectTimeout(channel, destination); + _selectorManager.register(channel,destination); + ConnectTimeout connectTimeout = new ConnectTimeout(channel,destination); _httpClient.schedule(connectTimeout,_httpClient.getConnectTimeout()); - _connectingChannels.put(channel, connectTimeout); + _connectingChannels.put(channel,connectTimeout); } } From 4b7f8d79dd9465b561599e1635bb86f08d99d14b Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Tue, 20 Sep 2011 10:20:24 +0200 Subject: [PATCH 056/134] 358147: SelectConnector catch UnresolvedAddressException to avoid socket leak --- .../org/eclipse/jetty/client/SelectConnector.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index f070951407e..caadb23c274 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -17,8 +17,10 @@ import java.io.IOException; import java.net.SocketTimeoutException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; +import java.nio.channels.UnresolvedAddressException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; + import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLSession; @@ -104,7 +106,15 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector else { channel.configureBlocking(false); - channel.connect(address.toSocketAddress()); + try + { + channel.connect(address.toSocketAddress()); + } + catch (UnresolvedAddressException ex) + { + channel.close(); + throw ex; + } _selectorManager.register(channel,destination); ConnectTimeout connectTimeout = new ConnectTimeout(channel,destination); _httpClient.schedule(connectTimeout,_httpClient.getConnectTimeout()); From 21ddd768f0edf75becbb65ca494ff3f4be1d9b3d Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 20 Sep 2011 14:26:17 -0500 Subject: [PATCH 057/134] [Bug 358147] Add catch for UnknownHostException to fix leaky file descriptor in client --- .../org/eclipse/jetty/client/SelectConnector.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index caadb23c274..c2274ef5eda 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -15,6 +15,7 @@ package org.eclipse.jetty.client; import java.io.IOException; import java.net.SocketTimeoutException; +import java.net.UnknownHostException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.nio.channels.UnresolvedAddressException; @@ -110,11 +111,17 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector { channel.connect(address.toSocketAddress()); } - catch (UnresolvedAddressException ex) + catch (UnresolvedAddressException uae) { channel.close(); - throw ex; + throw uae; } + catch ( UnknownHostException uhe ) + { + channel.close(); + throw uhe; + } + _selectorManager.register(channel,destination); ConnectTimeout connectTimeout = new ConnectTimeout(channel,destination); _httpClient.schedule(connectTimeout,_httpClient.getConnectTimeout()); From f8b8a2e77083c76b326c050e78c3937aa7b28b01 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 21 Sep 2011 11:30:40 +1000 Subject: [PATCH 058/134] JETTY-1277 Fixed sendRedirect encoding of relative locations --- .../org/eclipse/jetty/server/Response.java | 2 +- .../eclipse/jetty/server/ResponseTest.java | 62 ++++++++++++------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java index b5c9563b5b7..fb6196a2087 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java @@ -430,7 +430,7 @@ public class Response implements HttpServletResponse if (!canonical.equals(path)) { buf = _connection.getRequest().getRootURL(); - buf.append(canonical); + buf.append(URIUtil.encodePath(canonical)); if (uri.getQuery()!=null) { buf.append('?'); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java index 29ab7d91e03..ecc45ee835e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java @@ -381,31 +381,45 @@ public class ResponseTest public void testSendRedirect() throws Exception { - ByteArrayEndPoint out=new ByteArrayEndPoint(new byte[]{},4096); - HttpConnection connection=new TestHttpConnection(connector,out, connector.getServer()); - Response response = new Response(connection); - Request request = connection.getRequest(); - request.setServerName("myhost"); - request.setServerPort(8888); - request.setUri(new HttpURI("/path/info;param;jsessionid=12345?query=0&more=1#target")); - request.setContextPath("/path"); - request.setRequestedSessionId("12345"); - request.setRequestedSessionIdFromCookie(false); - AbstractSessionManager manager=new HashSessionManager(); - manager.setSessionIdManager(new HashSessionIdManager()); - request.setSessionManager(manager); - request.setSession(new TestSession(manager,"12345")); - manager.setCheckingRemoteSessionIdEncoding(false); + String[][] tests={ + {"/other/location?name=value","http://myhost:8888/other/location;jsessionid=12345?name=value"}, + {"/other/location","http://myhost:8888/other/location"}, + {"/other/l%20cation","http://myhost:8888/other/l%20cation"}, + {"location","http://myhost:8888/path/location"}, + {"./location","http://myhost:8888/path/location"}, + {"../location","http://myhost:8888/location"}, + {"/other/l%20cation","http://myhost:8888/other/l%20cation"}, + {"l%20cation","http://myhost:8888/path/l%20cation"}, + {"./l%20cation","http://myhost:8888/path/l%20cation"}, + {"../l%20cation","http://myhost:8888/l%20cation"}, + }; + + for (int i=1;i0); + AbstractSessionManager manager=new HashSessionManager(); + manager.setSessionIdManager(new HashSessionIdManager()); + request.setSessionManager(manager); + request.setSession(new TestSession(manager,"12345")); + manager.setCheckingRemoteSessionIdEncoding(false); - response.sendRedirect("/other/location"); - - String location = out.getOut().toString(); - int l=location.indexOf("Location: "); - int e=location.indexOf('\n',l); - location=location.substring(l+10,e).trim(); - - assertEquals("http://myhost:8888/other/location;jsessionid=12345",location); - + response.sendRedirect(tests[i][0]); + + String location = out.getOut().toString(); + int l=location.indexOf("Location: "); + int e=location.indexOf('\n',l); + location=location.substring(l+10,e).trim(); + assertEquals(tests[i][0],tests[i][1],location); + } } @Test From 790f6be8a6e09929feeb487716c92b1bda17bf3c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 21 Sep 2011 11:41:43 +1000 Subject: [PATCH 059/134] JETTY-1130 Access Sessions from HashSessionIdManager --- .../server/session/HashSessionIdManager.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java index 5e0aea6b457..7624afcf87a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionIdManager.java @@ -14,7 +14,9 @@ package org.eclipse.jetty.server.session; import java.lang.ref.WeakReference; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -46,6 +48,34 @@ public class HashSessionIdManager extends AbstractSessionIdManager super(random); } + /* ------------------------------------------------------------ */ + /** + * @return Collection of String session IDs + */ + public Collection getSessions() + { + return Collections.unmodifiableCollection(_sessions.keySet()); + } + + /* ------------------------------------------------------------ */ + /** + * @return Collection of Sessions for the passed session ID + */ + public Collection getSession(String id) + { + ArrayList sessions = new ArrayList(); + Set> refs =_sessions.get(id); + if (refs!=null) + { + for (WeakReference ref: refs) + { + HttpSession session = ref.get(); + if (session!=null) + sessions.add(session); + } + } + return sessions; + } /* ------------------------------------------------------------ */ /** Get the session ID with any worker ID. * From ff29a1cc51325ebf4f95feaa4bed847023a7e3fc Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 21 Sep 2011 13:46:48 +1000 Subject: [PATCH 060/134] JETTY-1322 idle sweeper checks for closed endp --- .../java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 161cf194735..d682584c096 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -251,7 +251,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo public void checkIdleTimestamp(long now) { long idleTimestamp=_idleTimestamp; - if (idleTimestamp!=0 && _maxIdleTime>0 && now>(idleTimestamp+_maxIdleTime)) + if (!getChannel().isOpen() || idleTimestamp!=0 && _maxIdleTime!=0 && now>(idleTimestamp+_maxIdleTime)) idleExpired(); } From e15e9ddc99b4961361d2b59c96a7ef90dcb7c1d9 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 21 Sep 2011 16:17:35 +1000 Subject: [PATCH 061/134] JETTY-1377 extra logging for busy selector --- .../eclipse/jetty/io/nio/SelectorManager.java | 184 ++++-------------- .../org/eclipse/jetty/server/StressTest.java | 6 +- 2 files changed, 45 insertions(+), 145 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index 2a01ba3d2a4..32a76910e9e 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -55,12 +55,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio"); - // TODO Tune these by approx system speed. - private static final int __JVMBUG_THRESHHOLD=Integer.getInteger("org.eclipse.jetty.io.nio.JVMBUG_THRESHHOLD",0).intValue(); private static final int __MONITOR_PERIOD=Integer.getInteger("org.eclipse.jetty.io.nio.MONITOR_PERIOD",1000).intValue(); - private static final int __MAX_SELECTS=Integer.getInteger("org.eclipse.jetty.io.nio.MAX_SELECTS",25000).intValue(); + private static final int __MAX_SELECTS=Integer.getInteger("org.eclipse.jetty.io.nio.MAX_SELECTS",3).intValue(); private static final int __BUSY_PAUSE=Integer.getInteger("org.eclipse.jetty.io.nio.BUSY_PAUSE",50).intValue(); - private static final int __BUSY_KEY=Integer.getInteger("org.eclipse.jetty.io.nio.BUSY_KEY",-1).intValue(); private static final int __IDLE_TICK=Integer.getInteger("org.eclipse.jetty.io.nio.IDLE_TICK",400).intValue(); private int _maxIdleTime; @@ -389,18 +386,10 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa private volatile Selector _selector; private volatile Thread _selecting; - private int _jvmBug; - private int _selects; - private long _monitorStart; + private int _busySelects; private long _monitorNext; private boolean _pausing; - private SelectionKey _busyKey; - private int _busyKeyCount; - private long _log; - private int _paused; - private int _jvmFix0; - private int _jvmFix1; - private int _jvmFix2; + private boolean _paused; private volatile long _idleTick; private ConcurrentMap _endPoints = new ConcurrentHashMap(); @@ -415,9 +404,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa // create a selector; _selector = Selector.open(); - _monitorStart=System.currentTimeMillis(); - _monitorNext=_monitorStart+__MONITOR_PERIOD; - _log=_monitorStart+60000; + _monitorNext=System.currentTimeMillis()+__MONITOR_PERIOD; } /* ------------------------------------------------------------ */ @@ -539,7 +526,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa // Do and instant select to see if any connections can be handled. int selected=selector.selectNow(); - _selects++; long now=System.currentTimeMillis(); @@ -573,12 +559,36 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa { long before=now; selected=selector.select(wait); - _selects++; now = System.currentTimeMillis(); _timeout.setNow(now); - if (__JVMBUG_THRESHHOLD>0) - checkJvmBugs(before, now, wait, selected); + // If we are monitoring for busy selector + // and this select did not wait more than 1ms + if (__MONITOR_PERIOD>0 && now-before <=1) + { + // count this as a busy select and if there have been too many this monitor cycle + if (++_busySelects>__MAX_SELECTS) + { + // Start injecting pauses + _pausing=true; + + // if this is the first pause + if (!_paused) + { + // Log and dump some status + _paused=true; + LOG.warn("Selector {} is too busy, pausing!",this); + final SelectSet set = this; + SelectorManager.this.dispatch( + new Runnable(){ + public void run() + { + System.err.println(set+":\n"+set.dump()); + } + }); + } + } + } } } @@ -705,6 +715,16 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa } } }); + + } + + // Reset busy select monitor counts + if (__MONITOR_PERIOD>0 && now>_monitorNext) + { + _busySelects=0; + _pausing=false; + _monitorNext=now+__MONITOR_PERIOD; + } } catch (ClosedSelectorException e) @@ -724,126 +744,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa } } - /* ------------------------------------------------------------ */ - private void checkJvmBugs(long before, long now, long wait, int selected) - throws IOException - { - Selector selector = _selector; - if (selector==null) - return; - - // Look for JVM bugs over a monitor period. - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6403933 - // http://bugs.sun.com/view_bug.do?bug_id=6693490 - if (now>_monitorNext) - { - _selects=(int)(_selects*__MONITOR_PERIOD/(now-_monitorStart)); - _pausing=_selects>__MAX_SELECTS; - if (_pausing) - _paused++; - - _selects=0; - _jvmBug=0; - _monitorStart=now; - _monitorNext=now+__MONITOR_PERIOD; - } - - if (now>_log) - { - if (_paused>0) - LOG.debug(this+" Busy selector - injecting delay "+_paused+" times"); - - if (_jvmFix2>0) - LOG.debug(this+" JVM BUG(s) - injecting delay"+_jvmFix2+" times"); - - if (_jvmFix1>0) - LOG.debug(this+" JVM BUG(s) - recreating selector "+_jvmFix1+" times, cancelled keys "+_jvmFix0+" times"); - - else if(LOG.isDebugEnabled() && _jvmFix0>0) - LOG.debug(this+" JVM BUG(s) - cancelled keys "+_jvmFix0+" times"); - _paused=0; - _jvmFix2=0; - _jvmFix1=0; - _jvmFix0=0; - _log=now+60000; - } - - // If we see signature of possible JVM bug, increment count. - if (selected==0 && wait>10 && (now-before)<(wait/2)) - { - // Increment bug count and try a work around - _jvmBug++; - if (_jvmBug>(__JVMBUG_THRESHHOLD)) - { - try - { - if (_jvmBug==__JVMBUG_THRESHHOLD+1) - _jvmFix2++; - - Thread.sleep(__BUSY_PAUSE); // pause to avoid busy loop - } - catch(InterruptedException e) - { - LOG.ignore(e); - } - } - else if (_jvmBug==__JVMBUG_THRESHHOLD) - { - renewSelector(); - } - else if (_jvmBug%32==31) // heuristic attempt to cancel key 31,63,95,... loops - { - // Cancel keys with 0 interested ops - int cancelled=0; - for (SelectionKey k: selector.keys()) - { - if (k.isValid()&&k.interestOps()==0) - { - k.cancel(); - cancelled++; - } - } - if (cancelled>0) - _jvmFix0++; - - return; - } - } - else if (__BUSY_KEY>0 && selected==1 && _selects>__MAX_SELECTS) - { - // Look for busy key - SelectionKey busy = selector.selectedKeys().iterator().next(); - if (busy==_busyKey) - { - if (++_busyKeyCount>__BUSY_KEY && !(busy.channel() instanceof ServerSocketChannel)) - { - final SelectChannelEndPoint endpoint = (SelectChannelEndPoint)busy.attachment(); - LOG.warn("Busy Key "+busy.channel()+" "+endpoint); - busy.cancel(); - if (endpoint!=null) - { - dispatch(new Runnable() - { - public void run() - { - try - { - endpoint.close(); - } - catch (IOException e) - { - LOG.ignore(e); - } - } - }); - } - } - } - else - _busyKeyCount=0; - _busyKey=busy; - } - } /* ------------------------------------------------------------ */ private void renewSelector() @@ -1044,7 +944,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa final CountDownLatch latch = new CountDownLatch(1); - addChange(new Runnable(){ + addChange(new ChangeTask(){ public void run() { dumpKeyState(dump); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java index ccf1dcf1ac5..0c46f2a3615 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java @@ -91,7 +91,7 @@ public class StressTest _server.setThreadPool(_threads); _connector = new SelectChannelConnector(); - _connector.setAcceptors(Math.max(1, Runtime.getRuntime().availableProcessors() / 2)); + _connector.setAcceptors(1); _connector.setAcceptQueueSize(5000); _connector.setMaxIdleTime(30000); _server.addConnector(_connector); @@ -123,7 +123,7 @@ public class StressTest // TODO needs to be further investigated assumeTrue(!OS.IS_OSX || Stress.isEnabled()); - doThreads(10,100,false); + doThreads(10,10,false); if (Stress.isEnabled()) { Thread.sleep(1000); @@ -139,7 +139,7 @@ public class StressTest // TODO needs to be further investigated assumeTrue(!OS.IS_OSX || Stress.isEnabled()); - doThreads(20,100,true); + doThreads(20,10,true); if (Stress.isEnabled()) { Thread.sleep(1000); From 6bebdceb3a3bec1b15032f19b1c35965f09c9468 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 21 Sep 2011 16:45:32 +1000 Subject: [PATCH 062/134] JETTY-1377 extra logging for busy selector --- .../main/java/org/eclipse/jetty/io/nio/SelectorManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index 32a76910e9e..dfb8141d61c 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -48,15 +48,13 @@ import org.eclipse.jetty.util.thread.Timeout.Task; * The Selector Manager manages and number of SelectSets to allow * NIO scheduling to scale to large numbers of connections. *

    - * This class works around a number of know JVM bugs. For details - * see http://wiki.eclipse.org/Jetty/Feature/JVM_NIO_Bug */ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable { public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio"); private static final int __MONITOR_PERIOD=Integer.getInteger("org.eclipse.jetty.io.nio.MONITOR_PERIOD",1000).intValue(); - private static final int __MAX_SELECTS=Integer.getInteger("org.eclipse.jetty.io.nio.MAX_SELECTS",3).intValue(); + private static final int __MAX_SELECTS=Integer.getInteger("org.eclipse.jetty.io.nio.MAX_SELECTS",25000).intValue(); private static final int __BUSY_PAUSE=Integer.getInteger("org.eclipse.jetty.io.nio.BUSY_PAUSE",50).intValue(); private static final int __IDLE_TICK=Integer.getInteger("org.eclipse.jetty.io.nio.IDLE_TICK",400).intValue(); From b3e6ebf416221f649b168bdf83b21aa91f97d34c Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Wed, 21 Sep 2011 11:47:38 +0200 Subject: [PATCH 063/134] Fix for #358121 (Utf8Appendable refactored to use Bjoern Hoehrmann's decoder). Signed-off-by: Simone Bordet --- .../eclipse/jetty/util/Utf8Appendable.java | 253 +++++++++--------- .../eclipse/jetty/util/Utf8StringBuffer.java | 54 ++-- .../eclipse/jetty/util/Utf8StringBuilder.java | 48 ++-- .../jetty/util/Utf8StringBufferTest.java | 124 +++++---- .../jetty/util/Utf8StringBuilderTest.java | 118 +++----- 5 files changed, 285 insertions(+), 312 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java index b869f431b91..c646979de54 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8Appendable.java @@ -1,180 +1,181 @@ +// ======================================================================== +// Copyright (c) 2006-2009 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.util; import java.io.IOException; -import java.util.IllegalFormatCodePointException; +/* ------------------------------------------------------------ */ +/** + * Utf8 Appendable abstract base class + * + * This abstract class wraps a standard {@link java.lang.Appendable} and provides methods to append UTF-8 encoded bytes, that are converted into characters. + * + * This class is stateful and up to 4 calls to {@link #append(byte)} may be needed before state a character is appended to the string buffer. + * + * The UTF-8 decoding is done by this class and no additional buffers or Readers are used. The UTF-8 code was inspired by + * http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ + * + * License information for Bjoern Hoehrmann's code: + * + * Copyright (c) 2008-2009 Bjoern Hoehrmann + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + **/ public abstract class Utf8Appendable { private final char REPLACEMENT = '\ufffd'; + private static final int UTF8_ACCEPT = 0; + private static final int UTF8_REJECT = 12; + protected final Appendable _appendable; - protected int _expectedContinuationBytes; - protected int _codePoint; - protected int _minCodePoint; + protected int _state = UTF8_ACCEPT; + + private static final byte[] BYTE_TABLE = + { + // The first part of the table maps bytes to character classes that + // to reduce the size of the transition table and create bitmasks. + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8 + }; + + private static final byte[] TRANS_TABLE = + { + // The second part is a transition table that maps a combination + // of a state of the automaton and a character class to a state. + 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12, + 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12, + 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12, + 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12, + 12,36,12,12,12,12,12,12,12,12,12,12 + }; + + private int _codep; public Utf8Appendable(Appendable appendable) { - _appendable=appendable; + _appendable = appendable; } public abstract int length(); - + + protected void reset() + { + _state = UTF8_ACCEPT; + } + public void append(byte b) { try { appendByte(b); } - catch(IOException e) - { - throw new RuntimeException(e); - } - } - - public void append(byte[] b,int offset, int length) - { - try - { - int end=offset+length; - for (int i=offset; imaxChars) + if (length() > maxChars) return false; appendByte(b[i]); } return true; } - catch(IOException e) + catch (IOException e) { throw new RuntimeException(e); } } - + protected void appendByte(byte b) throws IOException { - // Check for invalid bytes - if (b==(byte)0xc0 || b==(byte)0xc1 || (int)b>=0xf5) - { - _appendable.append(REPLACEMENT); - _expectedContinuationBytes=0; - _codePoint=0; - throw new NotUtf8Exception(); - } - - // Is it plain ASCII? - if (b>=0) - { - // Were we expecting a continuation byte? - if (_expectedContinuationBytes>0) - { - _appendable.append(REPLACEMENT); - _expectedContinuationBytes=0; - _codePoint=0; - throw new NotUtf8Exception(); - } - else - _appendable.append((char)(0x7f&b)); - } - // Else is this a start byte - else if (_expectedContinuationBytes==0) - { - if ((b & 0xe0) == 0xc0) - { - //110xxxxx - _expectedContinuationBytes=1; - _codePoint=b&0x1f; - _minCodePoint=0x80; - } - else if ((b & 0xf0) == 0xe0) - { - //1110xxxx - _expectedContinuationBytes=2; - _codePoint=b&0x0f; - _minCodePoint=0x800; - } - else if ((b & 0xf8) == 0xf0) - { - //11110xxx - _expectedContinuationBytes=3; - _codePoint=b&0x07; - _minCodePoint=0x10000; - } - else if ((b & 0xfc) == 0xf8) - { - //111110xx - _expectedContinuationBytes=4; - _codePoint=b&0x03; - _minCodePoint=0x200000; - } - else if ((b & 0xfe) == 0xfc) - { - //1111110x - _expectedContinuationBytes=5; - _codePoint=b&0x01; - _minCodePoint=0x400000; - } - else - { - _appendable.append(REPLACEMENT); - _expectedContinuationBytes=0; - _codePoint=0; - throw new NotUtf8Exception(); - } - } - // else is this a continuation character - else if ((b&0xc0)==0x80) - { - // 10xxxxxx - _codePoint=(_codePoint<<6)|(b&0x3f); - - // was that the last continuation? - if (--_expectedContinuationBytes==0) - { - // If this a valid unicode point? - if (_codePoint<_minCodePoint || (_codePoint>=0xD800 && _codePoint<=0xDFFF)) - { - _appendable.append(REPLACEMENT); - _expectedContinuationBytes=0; - _codePoint=0; - throw new NotUtf8Exception(); - } - _minCodePoint=0; - char[] chars = Character.toChars(_codePoint); - for (char c : chars) - _appendable.append(c); - } + if (b > 0 && isUtf8SequenceComplete()) + { + _appendable.append((char)(b & 0xFF)); } - // Else this is not a continuation character else { - // ! 10xxxxxx - _appendable.append(REPLACEMENT); - _expectedContinuationBytes=0; - _codePoint=0; - throw new NotUtf8Exception(); + int i = b & 0xFF; + int type = BYTE_TABLE[i]; + _codep = isUtf8SequenceComplete() ? (0xFF >> type) & i : (i & 0x3F) | (_codep << 6); + _state = TRANS_TABLE[_state + type]; + + if (isUtf8SequenceComplete()) + { + if (_codep < Character.MIN_HIGH_SURROGATE) + { + _appendable.append((char)_codep); + } + else + { + for (char c : Character.toChars(_codep)) + _appendable.append(c); + } + } + else if (_state == UTF8_REJECT) + { + _state = UTF8_ACCEPT; + _appendable.append(REPLACEMENT); + throw new NotUtf8Exception(); + } } } + protected boolean isUtf8SequenceComplete() + { + return _state == UTF8_ACCEPT; + } public static class NotUtf8Exception extends IllegalArgumentException { public NotUtf8Exception() { - super("!UTF-8"); + super("Not valid UTF8!"); } } -} \ No newline at end of file +} diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuffer.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuffer.java index bd730deabf3..b86058e584f 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuffer.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuffer.java @@ -4,71 +4,73 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.util; -import java.io.IOException; - /* ------------------------------------------------------------ */ -/** UTF-8 StringBuffer. +/** + * UTF-8 StringBuffer. * - * This class wraps a standard {@link java.lang.StringBuffer} and provides methods to append + * This class wraps a standard {@link java.lang.StringBuffer} and provides methods to append * UTF-8 encoded bytes, that are converted into characters. - * - * This class is stateful and up to 6 calls to {@link #append(byte)} may be needed before + * + * This class is stateful and up to 4 calls to {@link #append(byte)} may be needed before * state a character is appended to the string buffer. - * + * * The UTF-8 decoding is done by this class and no additional buffers or Readers are used. - * The UTF-8 code was inspired by http://javolution.org - * - * This class is not synchronised and should probably be called Utf8StringBuilder + * The UTF-8 code was inspired by http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ */ -public class Utf8StringBuffer extends Utf8Appendable +public class Utf8StringBuffer extends Utf8Appendable { final StringBuffer _buffer; - + public Utf8StringBuffer() { super(new StringBuffer()); - _buffer=(StringBuffer)_appendable; + _buffer = (StringBuffer)_appendable; } - + public Utf8StringBuffer(int capacity) { super(new StringBuffer(capacity)); - _buffer=(StringBuffer)_appendable; + _buffer = (StringBuffer)_appendable; } + @Override public int length() { return _buffer.length(); } - + + @Override public void reset() { + super.reset(); _buffer.setLength(0); - _expectedContinuationBytes=0; - _codePoint=0; } - + public StringBuffer getStringBuffer() { - if (_expectedContinuationBytes!=0) - throw new NotUtf8Exception(); + checkState(); return _buffer; } - + @Override public String toString() { - if (_expectedContinuationBytes!=0) - throw new NotUtf8Exception(); + checkState(); return _buffer.toString(); } + + private void checkState() + { + if (!isUtf8SequenceComplete()) + throw new IllegalArgumentException("Tried to read incomplete UTF8 decoded String"); + } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuilder.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuilder.java index 541590f6424..09866884eae 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuilder.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Utf8StringBuilder.java @@ -4,70 +4,74 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.util; -import java.io.IOException; /* ------------------------------------------------------------ */ /** UTF-8 StringBuilder. * - * This class wraps a standard {@link java.lang.StringBuffer} and provides methods to append + * This class wraps a standard {@link java.lang.StringBuilder} and provides methods to append * UTF-8 encoded bytes, that are converted into characters. - * - * This class is stateful and up to 6 calls to {@link #append(byte)} may be needed before + * + * This class is stateful and up to 4 calls to {@link #append(byte)} may be needed before * state a character is appended to the string buffer. - * + * * The UTF-8 decoding is done by this class and no additional buffers or Readers are used. - * The UTF-8 code was inspired by http://javolution.org - * + * The UTF-8 code was inspired by http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ + * */ -public class Utf8StringBuilder extends Utf8Appendable +public class Utf8StringBuilder extends Utf8Appendable { final StringBuilder _buffer; - + public Utf8StringBuilder() { super(new StringBuilder()); _buffer=(StringBuilder)_appendable; } - + public Utf8StringBuilder(int capacity) { super(new StringBuilder(capacity)); _buffer=(StringBuilder)_appendable; } - + + @Override public int length() { return _buffer.length(); } - + + @Override public void reset() { + super.reset(); _buffer.setLength(0); - _expectedContinuationBytes=0; - _codePoint=0; } - + public StringBuilder getStringBuilder() { - if (_expectedContinuationBytes!=0) - throw new NotUtf8Exception(); + checkState(); return _buffer; } - + @Override public String toString() { - if (_expectedContinuationBytes!=0) - throw new NotUtf8Exception(); + checkState(); return _buffer.toString(); } + + private void checkState() + { + if (!isUtf8SequenceComplete()) + throw new IllegalArgumentException("Tried to read incomplete UTF8 decoded String"); + } } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java index 9c44625e8fe..eacd85b33b9 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBufferTest.java @@ -4,92 +4,98 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import java.io.UnsupportedEncodingException; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class Utf8StringBufferTest { - public void testUtfStringBuffer() - throws Exception + @Test + public void testUtfStringBuffer() throws Exception { - String source="abcd012345\n\r\u0000\u00a4\u10fb\ufffdjetty"; + String source = "abcd012345\n\r\u0000\u00a4\u10fb\ufffdjetty"; byte[] bytes = source.getBytes(StringUtil.__UTF8); Utf8StringBuffer buffer = new Utf8StringBuffer(); - for (int i=0;i=0); - } - assertEquals("abc\ufffd",buffer.toString()); - } - - @Test - public void testUTF32codes() - throws Exception - { - String source="\uD842\uDF9F"; - byte[] bytes=source.getBytes("UTF-8"); - String jvmcheck = new String(bytes,0,bytes.length,"UTF-8"); assertEquals(source,jvmcheck); - + Utf8StringBuffer buffer = new Utf8StringBuffer(); buffer.append(bytes,0,bytes.length); - String result=buffer.toString(); + String result = buffer.toString(); assertEquals(source,result); } + @Test + public void testGermanUmlauts() throws Exception + { + byte[] bytes = new byte[6]; + bytes[0] = (byte)0xC3; + bytes[1] = (byte)0xBC; + bytes[2] = (byte)0xC3; + bytes[3] = (byte)0xB6; + bytes[4] = (byte)0xC3; + bytes[5] = (byte)0xA4; + + Utf8StringBuffer buffer = new Utf8StringBuffer(); + for (int i = 0; i < bytes.length; i++) + buffer.append(bytes[i]); + + assertEquals("\u00FC\u00F6\u00E4",buffer.toString()); + } + + @Test(expected = Utf8Appendable.NotUtf8Exception.class) + public void testInvalidUTF8() throws UnsupportedEncodingException + { + Utf8StringBuffer buffer = new Utf8StringBuffer(); + buffer.append((byte)0xC2); + buffer.append((byte)0xC2); + } } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java index bfa0cccd870..b83aa1099db 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/Utf8StringBuilderTest.java @@ -4,142 +4,102 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class Utf8StringBuilderTest { @Test - public void testInvalid() - throws Exception + public void testInvalid() throws Exception { - String[] invalids = { - "c0af", - "EDA080", - "f08080af", - "f8808080af", - "e080af", - "F4908080", - "fbbfbfbfbf" - }; - + String[] invalids = + { "c0af", "EDA080", "f08080af", "f8808080af", "e080af", "F4908080", "fbbfbfbfbf", "10FFFF" }; + for (String i : invalids) { byte[] bytes = TypeUtil.fromHexString(i); - - /* Test what JVM does - try - { - String s = new String(bytes,0,bytes.length,"UTF-8"); - System.err.println(i+": "+s); - } - catch(Exception e) - { - System.err.println(i+": "+e); - } - */ - try { Utf8StringBuilder buffer = new Utf8StringBuilder(); buffer.append(bytes,0,bytes.length); - + assertEquals(i,"not expected",buffer.toString()); } - catch(IllegalArgumentException e) + catch (Utf8Appendable.NotUtf8Exception e) { assertTrue(i,true); } } } - + @Test - public void testUtfStringBuilder() - throws Exception + public void testUtfStringBuilder() throws Exception { - String source="abcd012345\n\r\u0000\u00a4\u10fb\ufffdjetty"; + String source = "abcd012345\n\r\u0000\u00a4\u10fb\ufffdjetty"; byte[] bytes = source.getBytes(StringUtil.__UTF8); Utf8StringBuilder buffer = new Utf8StringBuilder(); - for (int i=0;i=0); - } + buffer.toString(); } - + @Test - public void testLong() - throws Exception + public void testLong() throws Exception { - String source="abcXX"; + String source = "abcXX"; byte[] bytes = source.getBytes(StringUtil.__UTF8); - bytes[3]=(byte)0xc0; - bytes[4]=(byte)0x00; + bytes[3] = (byte)0xc0; + bytes[4] = (byte)0x00; Utf8StringBuilder buffer = new Utf8StringBuilder(); try { - for (int i = 0; i < bytes.length; i++) - buffer.append(bytes[i]); + for (byte aByte : bytes) + buffer.append(aByte); assertTrue(false); } - catch(Utf8Appendable.NotUtf8Exception e) + catch (IllegalArgumentException e) { assertTrue(true); } - assertEquals("abc\ufffd", buffer.toString()); + assertEquals("abc\ufffd",buffer.toString()); } - - @Test - public void testUTF32codes() - throws Exception + @Test + public void testUTF32codes() throws Exception { - String source="\uD842\uDF9F"; - byte[] bytes=source.getBytes("UTF-8"); - - // System.err.println(TypeUtil.toHexString(bytes)); + String source = "\uD842\uDF9F"; + byte[] bytes = source.getBytes("UTF-8"); + String jvmcheck = new String(bytes,0,bytes.length,"UTF-8"); assertEquals(source,jvmcheck); - + Utf8StringBuilder buffer = new Utf8StringBuilder(); buffer.append(bytes,0,bytes.length); - String result=buffer.toString(); + String result = buffer.toString(); assertEquals(source,result); } - - } From 0bd7519a2e2b95b955be39bc6da0d67f0f6379b5 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 21 Sep 2011 15:54:53 +0200 Subject: [PATCH 064/134] Fix for #358121 (Utf8Appendable refactored to use Bjoern Hoehrmann's decoder). --- VERSION.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/VERSION.txt b/VERSION.txt index e0abfa17b93..d694d6fc44d 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,4 +1,5 @@ jetty-7.5.2-SNAPSHOT + + 358121 Implement new UTF8 Algorithm to UTF8Appendable.java jetty-7.5.1.v20110908 - 08 September 2011 + 350634 Added Resource.newResource(File) From 633f3b15886664e116478145a3e0139fc8f89847 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 22 Sep 2011 09:22:27 +1000 Subject: [PATCH 065/134] JETTY-1423 force connection to be closed returned --- .../org/eclipse/jetty/client/SocketConnector.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java index 226cd644ffd..309abe87881 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java @@ -97,6 +97,17 @@ class SocketConnector extends AbstractLifeCycle implements HttpClient.Connector destination.onException(e); } } + finally + { + try + { + destination.returnConnection(connection,true); + } + catch (IOException e) + { + LOG.debug(e); + } + } } }); From e2bdcbe38c1e550f722ea2c0586edc7ba688dec7 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Thu, 22 Sep 2011 11:00:02 +0200 Subject: [PATCH 066/134] Ajp13Generator: code format Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/ajp/Ajp13Generator.java | 276 +++++++++--------- 1 file changed, 130 insertions(+), 146 deletions(-) diff --git a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java index 488af7401a3..154008797e7 100644 --- a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java +++ b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java @@ -44,38 +44,38 @@ public class Ajp13Generator extends AbstractGenerator static { byte[] xA001 = - { (byte) 0xA0, (byte) 0x01 }; + { (byte)0xA0, (byte)0x01 }; byte[] xA002 = - { (byte) 0xA0, (byte) 0x02 }; + { (byte)0xA0, (byte)0x02 }; byte[] xA003 = - { (byte) 0xA0, (byte) 0x03 }; + { (byte)0xA0, (byte)0x03 }; byte[] xA004 = - { (byte) 0xA0, (byte) 0x04 }; + { (byte)0xA0, (byte)0x04 }; byte[] xA005 = - { (byte) 0xA0, (byte) 0x05 }; + { (byte)0xA0, (byte)0x05 }; byte[] xA006 = - { (byte) 0xA0, (byte) 0x06 }; + { (byte)0xA0, (byte)0x06 }; byte[] xA007 = - { (byte) 0xA0, (byte) 0x07 }; + { (byte)0xA0, (byte)0x07 }; byte[] xA008 = - { (byte) 0xA0, (byte) 0x08 }; + { (byte)0xA0, (byte)0x08 }; byte[] xA009 = - { (byte) 0xA0, (byte) 0x09 }; + { (byte)0xA0, (byte)0x09 }; byte[] xA00A = - { (byte) 0xA0, (byte) 0x0A }; + { (byte)0xA0, (byte)0x0A }; byte[] xA00B = - { (byte) 0xA0, (byte) 0x0B }; - __headerHash.put("Content-Type", xA001); - __headerHash.put("Content-Language", xA002); - __headerHash.put("Content-Length", xA003); - __headerHash.put("Date", xA004); - __headerHash.put("Last-Modified", xA005); - __headerHash.put("Location", xA006); - __headerHash.put("Set-Cookie", xA007); - __headerHash.put("Set-Cookie2", xA008); - __headerHash.put("Servlet-Engine", xA009); - __headerHash.put("Status", xA00A); - __headerHash.put("WWW-Authenticate", xA00B); + { (byte)0xA0, (byte)0x0B }; + __headerHash.put("Content-Type",xA001); + __headerHash.put("Content-Language",xA002); + __headerHash.put("Content-Length",xA003); + __headerHash.put("Date",xA004); + __headerHash.put("Last-Modified",xA005); + __headerHash.put("Location",xA006); + __headerHash.put("Set-Cookie",xA007); + __headerHash.put("Set-Cookie2",xA008); + __headerHash.put("Servlet-Engine",xA009); + __headerHash.put("Status",xA00A); + __headerHash.put("WWW-Authenticate",xA00B); } @@ -83,7 +83,7 @@ public class Ajp13Generator extends AbstractGenerator // 0, 1 ajp int 1 packet length // 9 CPONG response Code private static final byte[] AJP13_CPONG_RESPONSE = - { 'A', 'B', 0, 1, 9}; + { 'A', 'B', 0, 1, 9 }; private static final byte[] AJP13_END_RESPONSE = { 'A', 'B', 0, 2, 5, 1 }; @@ -114,7 +114,7 @@ public class Ajp13Generator extends AbstractGenerator /* ------------------------------------------------------------ */ public Ajp13Generator(Buffers buffers, EndPoint io) { - super(buffers, io); + super(buffers,io); } /* ------------------------------------------------------------ */ @@ -130,6 +130,7 @@ public class Ajp13Generator extends AbstractGenerator { return true; } + /* ------------------------------------------------------------ */ @Override public void reset(boolean returnBuffers) @@ -140,9 +141,7 @@ public class Ajp13Generator extends AbstractGenerator _needMore = false; _expectMore = false; _bufferPrepared = false; - _last=false; - - + _last = false; _state = STATE_HEADER; @@ -159,11 +158,9 @@ public class Ajp13Generator extends AbstractGenerator _noContent = false; _persistent = true; - - - _header = null; // Buffer for HTTP header (and maybe small _content) - _buffer = null; // Buffer for copy of passed _content - _content = null; // Buffer passed to addContent + _header = null; // Buffer for HTTP header (and maybe small _content) + _buffer = null; // Buffer for copy of passed _content + _content = null; // Buffer passed to addContent } @@ -175,13 +172,13 @@ public class Ajp13Generator extends AbstractGenerator { initContent(); } - catch(IOException e) + catch (IOException e) { throw new RuntimeException(e); } - return super.getContentBufferSize()-7; + return super.getContentBufferSize() - 7; } - + /* ------------------------------------------------------------ */ @Override public void increaseContentBufferSize(int contentBufferSize) @@ -196,11 +193,9 @@ public class Ajp13Generator extends AbstractGenerator * @param content * @param last * @throws IllegalArgumentException - * if content is - * {@link Buffer#isImmutable immutable}. + * if content is {@link Buffer#isImmutable immutable}. * @throws IllegalStateException - * If the request is not expecting any more content, or if the - * buffers are full and cannot be flushed. + * If the request is not expecting any more content, or if the buffers are full and cannot be flushed. * @throws IOException * if there is a problem flushing the buffers. */ @@ -217,13 +212,13 @@ public class Ajp13Generator extends AbstractGenerator if (_last || _state == STATE_END) { - LOG.debug("Ignoring extra content {}", content); + LOG.debug("Ignoring extra content {}",content); content.clear(); return; } _last = last; - if(!_endp.isOpen()) + if (!_endp.isOpen()) { _state = STATE_END; return; @@ -289,8 +284,7 @@ public class Ajp13Generator extends AbstractGenerator if (_last || _state == STATE_END) throw new IllegalStateException("Closed"); - - if(!_endp.isOpen()) + if (!_endp.isOpen()) { _state = STATE_END; return false; @@ -322,8 +316,7 @@ public class Ajp13Generator extends AbstractGenerator /* ------------------------------------------------------------ */ /** - * Prepare buffer for unchecked writes. Prepare the generator buffer to - * receive unchecked writes + * Prepare buffer for unchecked writes. Prepare the generator buffer to receive unchecked writes * * @return the available space in the buffer. * @throws IOException @@ -337,8 +330,7 @@ public class Ajp13Generator extends AbstractGenerator if (_last || _state == STATE_END) throw new IllegalStateException("Closed"); - - if(!_endp.isOpen()) + if (!_endp.isOpen()) { _state = STATE_END; return -1; @@ -377,8 +369,8 @@ public class Ajp13Generator extends AbstractGenerator _last = _last | allContentAdded; boolean has_server = false; - if (_persistent==null) - _persistent=(_version > HttpVersions.HTTP_1_0_ORDINAL); + if (_persistent == null) + _persistent = (_version > HttpVersions.HTTP_1_0_ORDINAL); // get a header buffer if (_header == null) @@ -390,13 +382,13 @@ public class Ajp13Generator extends AbstractGenerator try { // start the header - _buffer.put((byte) 'A'); - _buffer.put((byte) 'B'); + _buffer.put((byte)'A'); + _buffer.put((byte)'B'); addInt(0); - _buffer.put((byte) 0x4); + _buffer.put((byte)0x4); addInt(_status); if (_reason == null) - _reason=HttpGenerator.getReasonBuffer(_status); + _reason = HttpGenerator.getReasonBuffer(_status); if (_reason == null) _reason = new ByteArrayBuffer(Integer.toString(_status)); addBuffer(_reason); @@ -407,7 +399,6 @@ public class Ajp13Generator extends AbstractGenerator _content = null; } - // allocate 2 bytes for number of headers int field_index = _buffer.putIndex(); addInt(0); @@ -417,15 +408,15 @@ public class Ajp13Generator extends AbstractGenerator if (fields != null) { // Add headers - int s=fields.size(); - for (int f=0;f 0) ? 4 : 0) | ((_buffer != null && _buffer.length() > 0) ? 2 : 0); - + int to_flush = ((_header != null && _header.length() > 0)?4:0) | ((_buffer != null && _buffer.length() > 0)?2:0); switch (to_flush) { - case 7: - throw new IllegalStateException(); // should - // never - // happen! - case 6: - len = _endp.flush(_header, _buffer, null); + case 7: + throw new IllegalStateException(); // should + // never + // happen! + case 6: + len = _endp.flush(_header,_buffer,null); - break; - case 5: - throw new IllegalStateException(); // should - // never - // happen! - case 4: - len = _endp.flush(_header); - break; - case 3: - throw new IllegalStateException(); // should - // never - // happen! - case 2: - len = _endp.flush(_buffer); + break; + case 5: + throw new IllegalStateException(); // should + // never + // happen! + case 4: + len = _endp.flush(_header); + break; + case 3: + throw new IllegalStateException(); // should + // never + // happen! + case 2: + len = _endp.flush(_buffer); - break; - case 1: - throw new IllegalStateException(); // should - // never - // happen! - case 0: - { - // Nothing more we can write now. - if (_header != null) - _header.clear(); - - _bufferPrepared = false; - - if (_buffer != null) + break; + case 1: + throw new IllegalStateException(); // should + // never + // happen! + case 0: { - _buffer.clear(); + // Nothing more we can write now. + if (_header != null) + _header.clear(); - // reserve some space for the - // header - _buffer.setPutIndex(7); - _buffer.setGetIndex(7); + _bufferPrepared = false; - // Special case handling for - // small left over buffer from - // an addContent that caused a - // buffer flush. - if (_content != null && _content.length() < _buffer.space() && _state != STATE_FLUSHING) + if (_buffer != null) { + _buffer.clear(); + + // reserve some space for the + // header + _buffer.setPutIndex(7); + _buffer.setGetIndex(7); + + // Special case handling for + // small left over buffer from + // an addContent that caused a + // buffer flush. + if (_content != null && _content.length() < _buffer.space() && _state != STATE_FLUSHING) + { + + _buffer.put(_content); + _content.clear(); + _content = null; + break Flushing; + } + + } + + // Are we completely finished for now? + if (!_expectMore && !_needEOC && (_content == null || _content.length() == 0)) + { + if (_state == STATE_FLUSHING) + _state = STATE_END; + + // if (_state == STATE_END) + // { + // _endp.close(); + // } + // - _buffer.put(_content); - _content.clear(); - _content = null; break Flushing; } + // Try to prepare more to write. + prepareBuffers(); } - - - - // Are we completely finished for now? - if (!_expectMore && !_needEOC && (_content == null || _content.length() == 0)) - { - if (_state == STATE_FLUSHING) - _state = STATE_END; - -// if (_state == STATE_END) -// { -// _endp.close(); -// } -// - - break Flushing; - } - - // Try to prepare more to write. - prepareBuffers(); - } } // If we failed to flush anything twice in a row @@ -631,7 +618,7 @@ public class Ajp13Generator extends AbstractGenerator catch (IOException e) { LOG.ignore(e); - throw (e instanceof EofException) ? e : new EofException(e); + throw (e instanceof EofException)?e:new EofException(e); } } @@ -680,14 +667,14 @@ public class Ajp13Generator extends AbstractGenerator { _bufferPrepared = true; - _buffer.put((byte) 0); + _buffer.put((byte)0); int put = _buffer.putIndex(); _buffer.setGetIndex(0); _buffer.setPutIndex(0); - _buffer.put((byte) 'A'); - _buffer.put((byte) 'B'); + _buffer.put((byte)'A'); + _buffer.put((byte)'B'); addInt(payloadSize + 4); - _buffer.put((byte) 3); + _buffer.put((byte)3); addInt(payloadSize); _buffer.setPutIndex(put); } @@ -759,15 +746,15 @@ public class Ajp13Generator extends AbstractGenerator /* ------------------------------------------------------------ */ private void addInt(int i) { - _buffer.put((byte) ((i >> 8) & 0xFF)); - _buffer.put((byte) (i & 0xFF)); + _buffer.put((byte)((i >> 8) & 0xFF)); + _buffer.put((byte)(i & 0xFF)); } /* ------------------------------------------------------------ */ private void addInt(int startIndex, int i) { - _buffer.poke(startIndex, (byte) ((i >> 8) & 0xFF)); - _buffer.poke((startIndex + 1), (byte) (i & 0xFF)); + _buffer.poke(startIndex,(byte)((i >> 8) & 0xFF)); + _buffer.poke((startIndex + 1),(byte)(i & 0xFF)); } /* ------------------------------------------------------------ */ @@ -786,7 +773,7 @@ public class Ajp13Generator extends AbstractGenerator addInt(b.length); _buffer.put(b); - _buffer.put((byte) 0); + _buffer.put((byte)0); } /* ------------------------------------------------------------ */ @@ -800,7 +787,7 @@ public class Ajp13Generator extends AbstractGenerator addInt(b.length()); _buffer.put(b); - _buffer.put((byte) 0); + _buffer.put((byte)0); } /* ------------------------------------------------------------ */ @@ -818,7 +805,6 @@ public class Ajp13Generator extends AbstractGenerator _expectMore = false; } - /* ------------------------------------------------------------ */ public void sendCPong() throws IOException { @@ -831,13 +817,11 @@ public class Ajp13Generator extends AbstractGenerator { _endp.flush(buff); } - while(buff.length() >0); + while (buff.length() > 0); _buffers.returnBuffer(buff); reset(true); } - - } From af7252b7197d895b720d1885a69c06d7e6da020c Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Thu, 22 Sep 2011 11:42:05 +0200 Subject: [PATCH 067/134] 353839: Ajp13Generator fix for file upload Signed-off-by: Simone Bordet --- .../src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java index 154008797e7..dd05df0df91 100644 --- a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java +++ b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java @@ -793,9 +793,8 @@ public class Ajp13Generator extends AbstractGenerator /* ------------------------------------------------------------ */ public void getBodyChunk() throws IOException { - _needMore = true; - _expectMore = true; - flushBuffer(); + ByteArrayBuffer bf = new ByteArrayBuffer(AJP13_MORE_CONTENT); + _endp.flush(bf); } /* ------------------------------------------------------------ */ From a699ffd8690ebd12c415bc81566a0c65c5f5a395 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 22 Sep 2011 12:14:15 +0200 Subject: [PATCH 068/134] Updated VERSION.txt for #353839. --- VERSION.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/VERSION.txt b/VERSION.txt index d694d6fc44d..5279b2c8f99 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,5 +1,6 @@ jetty-7.5.2-SNAPSHOT + 358121 Implement new UTF8 Algorithm to UTF8Appendable.java + + 353839 ajp component error when upload file jetty-7.5.1.v20110908 - 08 September 2011 + 350634 Added Resource.newResource(File) From 75645cef0e8fbfd7f4f0a123a7e32368c7a17430 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 23 Sep 2011 08:02:42 +1000 Subject: [PATCH 069/134] 358674 Added include/exclude protocols to SslContextFactory --- .../eclipse/jetty/embedded/LikeJettyXml.java | 24 +- .../org/eclipse/jetty/client/HttpClient.java | 2 +- .../eclipse/jetty/client/SelectConnector.java | 10 +- .../eclipse/jetty/client/SocketConnector.java | 15 +- .../helperClasses/GenericServerHandler.java | 2 +- .../jetty/http/ssl/SslContextFactory.java | 469 ++++++++++++------ .../server/ssl/SslSelectChannelConnector.java | 44 +- .../jetty/server/ssl/SslSocketConnector.java | 29 +- .../jetty/server/HttpServerTestBase.java | 2 +- .../jetty/server/ssl/SSLEngineTest.java | 3 +- .../ssl/SslSelectChannelServerTest.java | 4 +- .../jetty/server/ssl/SslSocketServerTest.java | 8 +- .../server/ssl/SslSocketTimeoutTest.java | 11 +- .../test/support/rawhttp/HttpsSocketImpl.java | 7 +- 14 files changed, 365 insertions(+), 265 deletions(-) diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java index 0caec484893..f8aa4949802 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java @@ -88,33 +88,13 @@ public class LikeJettyXml "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" }); + cf.setProtocol("TLSv1.1"); + cf.addExcludeProtocols(new String[]{"TLSv1","SSLv3"}); ssl_connector.setStatsOn(true); server.addConnector(ssl_connector); ssl_connector.open(); - SslSocketConnector ssls_connector = new SslSocketConnector(); - ssls_connector.setPort(8444); - cf = ssls_connector.getSslContextFactory(); - cf.setKeyStore(jetty_home + "/etc/keystore"); - cf.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); - cf.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g"); - cf.setTrustStore(jetty_home + "/etc/keystore"); - cf.setTrustStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); - cf.setExcludeCipherSuites( - new String[] { - "SSL_RSA_WITH_DES_CBC_SHA", - "SSL_DHE_RSA_WITH_DES_CBC_SHA", - "SSL_DHE_DSS_WITH_DES_CBC_SHA", - "SSL_RSA_EXPORT_WITH_RC4_40_MD5", - "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", - "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", - "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" - }); - ssls_connector.setStatsOn(true); - server.addConnector(ssls_connector); - ssls_connector.open(); - Ajp13SocketConnector ajp = new Ajp13SocketConnector(); 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 99b4a07dfa1..31b27424dc9 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 @@ -178,7 +178,7 @@ public class HttpClient extends HttpBuffers implements Attributes, Dumpable /* ------------------------------------------------------------ */ /** - * @return the threadPool + * @return the threadpool */ public ThreadPool getThreadPool() { diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index c2274ef5eda..7a561727abe 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -51,7 +51,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector private final HttpClient _httpClient; private final Manager _selectorManager=new Manager(); private final Map _connectingChannels = new ConcurrentHashMap(); - private SSLContext _sslContext; private Buffers _sslBuffers; /** @@ -211,19 +210,16 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector private synchronized SSLEngine newSslEngine(SocketChannel channel) throws IOException { SslContextFactory sslContextFactory = _httpClient.getSslContextFactory(); - if (_sslContext == null) - _sslContext = sslContextFactory.getSslContext(); - SSLEngine sslEngine; - if (channel != null && sslContextFactory.isSessionCachingEnabled()) + if (channel != null) { String peerHost = channel.socket().getInetAddress().getHostAddress(); int peerPort = channel.socket().getPort(); - sslEngine = _sslContext.createSSLEngine(peerHost, peerPort); + sslEngine = sslContextFactory.newSslEngine(peerHost, peerPort); } else { - sslEngine = _sslContext.createSSLEngine(); + sslEngine = sslContextFactory.newSslEngine(); } sslEngine.setUseClientMode(true); sslEngine.beginHandshake(); diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java index 309abe87881..031c0cb5bb3 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SocketConnector.java @@ -45,18 +45,9 @@ class SocketConnector extends AbstractLifeCycle implements HttpClient.Connector public void startConnection(final HttpDestination destination) throws IOException { - Socket socket=null; - - if ( destination.isSecure() ) - { - SSLContext sslContext = _httpClient.getSSLContext(); - socket = sslContext.getSocketFactory().createSocket(); - } - else - { - LOG.debug("Using Regular Socket"); - socket = SocketFactory.getDefault().createSocket(); - } + Socket socket= destination.isSecure() + ?_httpClient.getSslContextFactory().newSslSocket() + :SocketFactory.getDefault().createSocket(); socket.setSoTimeout(0); socket.setTcpNoDelay(true); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java index 71cd3cd1e1d..82dbdb35c47 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/GenericServerHandler.java @@ -68,7 +68,7 @@ public class GenericServerHandler extends AbstractHandler } catch (InterruptedException e) { - LOG.warn(e); + LOG.debug(e); } catch (IOException e) { diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java index 52cecaaad1b..33ec5f964f2 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java @@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.InetAddress; import java.security.InvalidParameterException; import java.security.KeyStore; import java.security.SecureRandom; @@ -42,7 +43,11 @@ import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSessionContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509KeyManager; @@ -51,9 +56,12 @@ import javax.net.ssl.X509TrustManager; import org.eclipse.jetty.http.security.Password; import org.eclipse.jetty.util.IO; 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.resource.Resource; import org.eclipse.jetty.util.security.CertificateUtils; import org.eclipse.jetty.util.security.CertificateValidator; +import org.junit.experimental.categories.Categories.IncludeCategory; /* ------------------------------------------------------------ */ @@ -65,6 +73,8 @@ import org.eclipse.jetty.util.security.CertificateValidator; */ public class SslContextFactory extends AbstractLifeCycle { + private static final Logger LOG = Log.getLogger(SslContextFactory.class); + public static final String DEFAULT_KEYMANAGERFACTORY_ALGORITHM = (Security.getProperty("ssl.KeyManagerFactory.algorithm") == null ? "SunX509" : Security.getProperty("ssl.KeyManagerFactory.algorithm")); @@ -82,8 +92,13 @@ public class SslContextFactory extends AbstractLifeCycle /** String name of keystore password property. */ public static final String PASSWORD_PROPERTY = "org.eclipse.jetty.ssl.password"; + /** Excluded protocols. */ + private final Set _excludeProtocols = new HashSet(Collections.singleton("SSLv2Hello")); + /** Included protocols. */ + private Set _includeProtocols = null; + /** Excluded cipher suites. */ - private Set _excludeCipherSuites = null; + private final Set _excludeCipherSuites = new HashSet(); /** Included cipher suites. */ private Set _includeCipherSuites = null; @@ -196,6 +211,7 @@ public class SslContextFactory extends AbstractLifeCycle if (_keyStoreInputStream == null && _keyStorePath == null && _trustStoreInputStream == null && _trustStorePath == null ) { + LOG.info("No keystore or trust store configured. ACCEPTING UNTRUSTED CERTIFICATES!!!!!"); // Create a trust manager that does not validate certificate chains TrustManager trustAllCerts = new X509TrustManager() { @@ -218,11 +234,115 @@ public class SslContextFactory extends AbstractLifeCycle } else { - createSSLContext(); + // verify that keystore and truststore + // parameters are set up correctly + try + { + checkKeyStore(); + } + catch(IllegalStateException e) + { + LOG.ignore(e); + } + + KeyStore keyStore = loadKeyStore(); + KeyStore trustStore = loadTrustStore(); + + Collection crls = loadCRL(_crlPath); + + if (_validateCerts && keyStore != null) + { + if (_certAlias == null) + { + List aliases = Collections.list(keyStore.aliases()); + _certAlias = aliases.size() == 1 ? aliases.get(0) : null; + } + + Certificate cert = _certAlias == null?null:keyStore.getCertificate(_certAlias); + if (cert == null) + { + throw new Exception("No certificate found in the keystore" + (_certAlias==null ? "":" for alias " + _certAlias)); + } + + CertificateValidator validator = new CertificateValidator(trustStore, crls); + validator.setMaxCertPathLength(_maxCertPathLength); + validator.setEnableCRLDP(_enableCRLDP); + validator.setEnableOCSP(_enableOCSP); + validator.setOcspResponderURL(_ocspResponderURL); + validator.validate(keyStore, cert); + } + + KeyManager[] keyManagers = getKeyManagers(keyStore); + TrustManager[] trustManagers = getTrustManagers(trustStore,crls); + + SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm); + _context = (_sslProvider == null)?SSLContext.getInstance(_sslProtocol):SSLContext.getInstance(_sslProtocol,_sslProvider); + _context.init(keyManagers,trustManagers,secureRandom); + + SSLEngine engine=newSslEngine(); + LOG.info("Enabled Protocols {} of {}",Arrays.asList(engine.getEnabledProtocols()),Arrays.asList(engine.getSupportedProtocols())); + LOG.debug("Enabled Ciphers {} of {}",Arrays.asList(engine.getEnabledCipherSuites()),Arrays.asList(engine.getSupportedCipherSuites())); } } } + /* ------------------------------------------------------------ */ + /** + * @return The array of protocol names to exclude from + * {@link SSLEngine#setEnabledProtocols(String[])} + */ + public String[] getExcludeProtocols() + { + return _excludeProtocols.toArray(new String[_excludeProtocols.size()]); + } + + /* ------------------------------------------------------------ */ + /** + * @param Protocols + * The array of protocol names to exclude from + * {@link SSLEngine#setEnabledProtocols(String[])} + */ + public void setExcludeProtocols(String... protocols) + { + checkNotStarted(); + + _excludeProtocols.clear(); + _excludeProtocols.addAll(Arrays.asList(protocols)); + } + + /* ------------------------------------------------------------ */ + /** + * @param protocol Protocol names to add to {@link SSLEngine#setEnabledProtocols(String[])} + */ + public void addExcludeProtocols(String... protocol) + { + checkNotStarted(); + _excludeProtocols.addAll(Arrays.asList(protocol)); + } + + /* ------------------------------------------------------------ */ + /** + * @return The array of protocol names to include in + * {@link SSLEngine#setEnabledProtocols(String[])} + */ + public String[] getIncludeProtocols() + { + return _includeProtocols.toArray(new String[_includeProtocols.size()]); + } + + /* ------------------------------------------------------------ */ + /** + * @param Protocols + * The array of protocol names to include in + * {@link SSLEngine#setEnabledProtocols(String[])} + */ + public void setIncludeProtocols(String... protocols) + { + checkNotStarted(); + + _includeProtocols = new HashSet(Arrays.asList(protocols)); + } + /* ------------------------------------------------------------ */ /** * @return The array of cipher suite names to exclude from @@ -239,11 +359,21 @@ public class SslContextFactory extends AbstractLifeCycle * The array of cipher suite names to exclude from * {@link SSLEngine#setEnabledCipherSuites(String[])} */ - public void setExcludeCipherSuites(String[] cipherSuites) + public void setExcludeCipherSuites(String... cipherSuites) { - checkStarted(); - - _excludeCipherSuites = new HashSet(Arrays.asList(cipherSuites)); + checkNotStarted(); + _excludeCipherSuites.clear(); + _excludeCipherSuites.addAll(Arrays.asList(cipherSuites)); + } + + /* ------------------------------------------------------------ */ + /** + * @param cipher Cipher names to add to {@link SSLEngine#setEnabledCipherSuites(String[])} + */ + public void addExcludeCipherSuites(String... cipher) + { + checkNotStarted(); + _excludeCipherSuites.addAll(Arrays.asList(cipher)); } /* ------------------------------------------------------------ */ @@ -262,9 +392,9 @@ public class SslContextFactory extends AbstractLifeCycle * The array of cipher suite names to include in * {@link SSLEngine#setEnabledCipherSuites(String[])} */ - public void setIncludeCipherSuites(String[] cipherSuites) + public void setIncludeCipherSuites(String... cipherSuites) { - checkStarted(); + checkNotStarted(); _includeCipherSuites = new HashSet(Arrays.asList(cipherSuites)); } @@ -285,7 +415,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setKeyStore(String keyStorePath) { - checkStarted(); + checkNotStarted(); _keyStorePath = keyStorePath; } @@ -306,7 +436,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setKeyStoreProvider(String keyStoreProvider) { - checkStarted(); + checkNotStarted(); _keyStoreProvider = keyStoreProvider; } @@ -327,7 +457,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setKeyStoreType(String keyStoreType) { - checkStarted(); + checkNotStarted(); _keyStoreType = keyStoreType; } @@ -341,7 +471,7 @@ public class SslContextFactory extends AbstractLifeCycle @Deprecated public InputStream getKeyStoreInputStream() { - checkConfig(); + checkKeyStore(); return _keyStoreInputStream; } @@ -355,7 +485,7 @@ public class SslContextFactory extends AbstractLifeCycle @Deprecated public void setKeyStoreInputStream(InputStream keyStoreInputStream) { - checkStarted(); + checkNotStarted(); _keyStoreInputStream = keyStoreInputStream; } @@ -376,7 +506,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setCertAlias(String certAlias) { - checkStarted(); + checkNotStarted(); _certAlias = certAlias; } @@ -397,7 +527,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setTrustStore(String trustStorePath) { - checkStarted(); + checkNotStarted(); _trustStorePath = trustStorePath; } @@ -418,7 +548,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setTrustStoreProvider(String trustStoreProvider) { - checkStarted(); + checkNotStarted(); _trustStoreProvider = trustStoreProvider; } @@ -439,7 +569,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setTrustStoreType(String trustStoreType) { - checkStarted(); + checkNotStarted(); _trustStoreType = trustStoreType; } @@ -453,7 +583,7 @@ public class SslContextFactory extends AbstractLifeCycle @Deprecated public InputStream getTrustStoreInputStream() { - checkConfig(); + checkKeyStore(); return _trustStoreInputStream; } @@ -467,7 +597,7 @@ public class SslContextFactory extends AbstractLifeCycle @Deprecated public void setTrustStoreInputStream(InputStream trustStoreInputStream) { - checkStarted(); + checkNotStarted(); _trustStoreInputStream = trustStoreInputStream; } @@ -490,7 +620,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setNeedClientAuth(boolean needClientAuth) { - checkStarted(); + checkNotStarted(); _needClientAuth = needClientAuth; } @@ -513,7 +643,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setWantClientAuth(boolean wantClientAuth) { - checkStarted(); + checkNotStarted(); _wantClientAuth = wantClientAuth; } @@ -545,7 +675,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setValidateCerts(boolean validateCerts) { - checkStarted(); + checkNotStarted(); _validateCerts = validateCerts; } @@ -566,7 +696,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setValidatePeerCerts(boolean validatePeerCerts) { - checkStarted(); + checkNotStarted(); _validatePeerCerts = validatePeerCerts; } @@ -593,7 +723,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setAllowRenegotiate(boolean allowRenegotiate) { - checkStarted(); + checkNotStarted(); _allowRenegotiate = allowRenegotiate; } @@ -605,7 +735,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setKeyStorePassword(String password) { - checkStarted(); + checkNotStarted(); _keyStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null); } @@ -617,7 +747,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setKeyManagerPassword(String password) { - checkStarted(); + checkNotStarted(); _keyManagerPassword = Password.getPassword(KEYPASSWORD_PROPERTY,password,null); } @@ -629,7 +759,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setTrustStorePassword(String password) { - checkStarted(); + checkNotStarted(); _trustStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null); } @@ -652,7 +782,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setProvider(String provider) { - checkStarted(); + checkNotStarted(); _sslProvider = provider; } @@ -675,7 +805,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setProtocol(String protocol) { - checkStarted(); + checkNotStarted(); _sslProtocol = protocol; } @@ -700,7 +830,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setSecureRandomAlgorithm(String algorithm) { - checkStarted(); + checkNotStarted(); _secureRandomAlgorithm = algorithm; } @@ -721,7 +851,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setSslKeyManagerFactoryAlgorithm(String algorithm) { - checkStarted(); + checkNotStarted(); _keyManagerFactoryAlgorithm = algorithm; } @@ -742,7 +872,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setTrustManagerFactoryAlgorithm(String algorithm) { - checkStarted(); + checkNotStarted(); _trustManagerFactoryAlgorithm = algorithm; } @@ -763,7 +893,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setCrlPath(String crlPath) { - checkStarted(); + checkNotStarted(); _crlPath = crlPath; } @@ -786,7 +916,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setMaxCertPathLength(int maxCertPathLength) { - checkStarted(); + checkNotStarted(); _maxCertPathLength = maxCertPathLength; } @@ -797,6 +927,8 @@ public class SslContextFactory extends AbstractLifeCycle */ public SSLContext getSslContext() { + if (!isStarted()) + throw new IllegalStateException(getState()); return _context; } @@ -807,60 +939,11 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setSslContext(SSLContext sslContext) { - checkStarted(); + checkNotStarted(); _context = sslContext; } - /* ------------------------------------------------------------ */ - /** - * @throws Exception - */ - protected void createSSLContext() throws Exception - { - // verify that keystore and truststore - // parameters are set up correctly - checkConfig(); - - KeyStore keyStore = loadKeyStore(); - KeyStore trustStore = loadTrustStore(); - - Collection crls = loadCRL(_crlPath); - - if (_validateCerts && keyStore != null) - { - if (_certAlias == null) - { - List aliases = Collections.list(keyStore.aliases()); - _certAlias = aliases.size() == 1 ? aliases.get(0) : null; - } - - Certificate cert = _certAlias == null?null:keyStore.getCertificate(_certAlias); - if (cert == null) - { - throw new Exception("No certificate found in the keystore" + (_certAlias==null ? "":" for alias " + _certAlias)); - } - - CertificateValidator validator = new CertificateValidator(trustStore, crls); - validator.setMaxCertPathLength(_maxCertPathLength); - validator.setEnableCRLDP(_enableCRLDP); - validator.setEnableOCSP(_enableOCSP); - validator.setOcspResponderURL(_ocspResponderURL); - validator.validate(keyStore, cert); - } - - KeyManager[] keyManagers = getKeyManagers(keyStore); - TrustManager[] trustManagers = getTrustManagers(trustStore,crls); - - SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm); - _context = (_sslProvider == null)?SSLContext.getInstance(_sslProtocol):SSLContext.getInstance(_sslProtocol,_sslProvider); - _context.init(keyManagers,trustManagers,secureRandom); - - SSLSessionContext sslSessionContext = _context.getServerSessionContext(); - sslSessionContext.setSessionCacheSize(_sslSessionCacheSize); - sslSessionContext.setSessionTimeout(_sslSessionTimeout); - } - /* ------------------------------------------------------------ */ /** * Override this method to provide alternate way to load a keystore. @@ -1014,33 +1097,27 @@ public class SslContextFactory extends AbstractLifeCycle /* ------------------------------------------------------------ */ /** - * Check configuration. Ensures that if keystore has been + * Check KetyStore Configuration. Ensures that if keystore has been * configured but there's no truststore, that keystore is * used as truststore. - * @return true SslContextFactory configuration can be used in server connector. + * @throws IllegalStateException if SslContextFactory configuration can't be used. */ - public boolean checkConfig() + public void checkKeyStore() { - boolean check = true; if (_keyStore == null && _keyStoreInputStream == null && _keyStorePath == null) + throw new IllegalStateException("SSL doesn't have a valid keystore"); + + // if the keystore has been configured but there is no + // truststore configured, use the keystore as the truststore + if (_trustStore == null && _trustStoreInputStream == null && _trustStorePath == null) { - // configuration doesn't have a valid keystore - check = false; - } - else - { - // if the keystore has been configured but there is no - // truststore configured, use the keystore as the truststore - if (_trustStore == null && _trustStoreInputStream == null && _trustStorePath == null) - { - _trustStore = _keyStore; - _trustStorePath = _keyStorePath; - _trustStoreInputStream = _keyStoreInputStream; - _trustStoreType = _keyStoreType; - _trustStoreProvider = _keyStoreProvider; - _trustStorePassword = _keyStorePassword; - _trustManagerFactoryAlgorithm = _keyManagerFactoryAlgorithm; - } + _trustStore = _keyStore; + _trustStorePath = _keyStorePath; + _trustStoreInputStream = _keyStoreInputStream; + _trustStoreType = _keyStoreType; + _trustStoreProvider = _keyStoreProvider; + _trustStorePassword = _keyStorePassword; + _trustManagerFactoryAlgorithm = _keyManagerFactoryAlgorithm; } // It's the same stream we cannot read it twice, so read it once in memory @@ -1057,11 +1134,9 @@ public class SslContextFactory extends AbstractLifeCycle } catch (Exception ex) { - throw new RuntimeException(ex); + throw new IllegalStateException(ex); } } - - return check; } /* ------------------------------------------------------------ */ @@ -1073,57 +1148,68 @@ public class SslContextFactory extends AbstractLifeCycle * @param supportedCipherSuites Array of supported cipher suites * @return Array of cipher suites to enable */ - public String[] selectCipherSuites(String[] enabledCipherSuites, String[] supportedCipherSuites) + public String[] selectProtocols(String[] enabledProtocols, String[] supportedProtocols) { - Set selectedCipherSuites = null; - if (enabledCipherSuites != null) + Set selected_protocols = new HashSet(); + + // Set the starting protocols - either from the included or enabled list + if (_includeProtocols!=null) { - selectedCipherSuites = new HashSet(Arrays.asList(enabledCipherSuites)); + // Use only the supported included protocols + for (String protocol : supportedProtocols) + if (_includeProtocols.contains(protocol)) + selected_protocols.add(protocol); } else + selected_protocols.addAll(Arrays.asList(enabledProtocols)); + + + // Remove any excluded protocols + if (_excludeProtocols != null) + selected_protocols.removeAll(_excludeProtocols); + + return selected_protocols.toArray(new String[selected_protocols.size()]); + } + + /* ------------------------------------------------------------ */ + /** + * Select cipher suites to be used by the connector + * based on configured inclusion and exclusion lists + * as well as enabled and supported cipher suite lists. + * @param enabledCipherSuites Array of enabled cipher suites + * @param supportedCipherSuites Array of supported cipher suites + * @return Array of cipher suites to enable + */ + public String[] selectCipherSuites(String[] enabledCipherSuites, String[] supportedCipherSuites) + { + Set selected_ciphers = new HashSet(); + + // Set the starting ciphers - either from the included or enabled list + if (_includeCipherSuites!=null) { - selectedCipherSuites = new HashSet(); + // Use only the supported included ciphers + for (String cipherSuite : supportedCipherSuites) + if (_includeCipherSuites.contains(cipherSuite)) + selected_ciphers.add(cipherSuite); } - - if ((supportedCipherSuites != null && supportedCipherSuites.length > 0) && - (_includeCipherSuites != null && _includeCipherSuites.size() > 0)) - { - Set supportedCSList = new HashSet(Arrays.asList(supportedCipherSuites)); - - for (String cipherName : _includeCipherSuites) - { - if ((!selectedCipherSuites.contains(cipherName)) && - supportedCSList.contains(cipherName)) - { - selectedCipherSuites.add(cipherName); - } - } - } - - if (_excludeCipherSuites != null && _excludeCipherSuites.size() > 0) - { - for (String cipherName : _excludeCipherSuites) - { - if (selectedCipherSuites.contains(cipherName)) - { - selectedCipherSuites.remove(cipherName); - } - } - } - - return selectedCipherSuites.toArray(new String[selectedCipherSuites.size()]); + else + selected_ciphers.addAll(Arrays.asList(enabledCipherSuites)); + + + // Remove any excluded ciphers + if (_excludeCipherSuites != null) + selected_ciphers.removeAll(_excludeCipherSuites); + return selected_ciphers.toArray(new String[selected_ciphers.size()]); } /* ------------------------------------------------------------ */ /** * Check if the lifecycle has been started and throw runtime exception */ - protected void checkStarted() + protected void checkNotStarted() { if (isStarted()) - { - throw new IllegalStateException("Cannot modify configuration after SslContextFactory was started"); - } + throw new IllegalStateException("Cannot modify configuration when "+getState()); } /* ------------------------------------------------------------ */ @@ -1141,7 +1227,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setEnableCRLDP(boolean enableCRLDP) { - checkStarted(); + checkNotStarted(); _enableCRLDP = enableCRLDP; } @@ -1161,7 +1247,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setEnableOCSP(boolean enableOCSP) { - checkStarted(); + checkNotStarted(); _enableOCSP = enableOCSP; } @@ -1181,7 +1267,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setOcspResponderURL(String ocspResponderURL) { - checkStarted(); + checkNotStarted(); _ocspResponderURL = ocspResponderURL; } @@ -1192,7 +1278,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setKeyStore(KeyStore keyStore) { - checkStarted(); + checkNotStarted(); _keyStore = keyStore; } @@ -1203,7 +1289,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setTrustStore(KeyStore trustStore) { - checkStarted(); + checkNotStarted(); _trustStore = trustStore; } @@ -1214,7 +1300,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setKeyStoreResource(Resource resource) { - checkStarted(); + checkNotStarted(); try { @@ -1233,7 +1319,7 @@ public class SslContextFactory extends AbstractLifeCycle */ public void setTrustStore(Resource resource) { - checkStarted(); + checkNotStarted(); try { @@ -1299,4 +1385,83 @@ public class SslContextFactory extends AbstractLifeCycle { _sslSessionTimeout = sslSessionTimeout; } + + + /* ------------------------------------------------------------ */ + public SSLServerSocket newSslServerSocket(String host,int port,int backlog) throws IOException + { + SSLServerSocketFactory factory = _context.getServerSocketFactory(); + + SSLServerSocket socket = + (SSLServerSocket) (host==null ? + factory.createServerSocket(port,backlog): + factory.createServerSocket(port,backlog,InetAddress.getByName(host))); + + if (getWantClientAuth()) + socket.setWantClientAuth(getWantClientAuth()); + if (getNeedClientAuth()) + socket.setNeedClientAuth(getNeedClientAuth()); + + socket.setEnabledCipherSuites(selectCipherSuites( + socket.getEnabledCipherSuites(), + socket.getSupportedCipherSuites())); + socket.setEnabledProtocols(selectProtocols(socket.getEnabledProtocols(),socket.getSupportedProtocols())); + + return socket; + } + + /* ------------------------------------------------------------ */ + public SSLSocket newSslSocket() throws IOException + { + SSLSocketFactory factory = _context.getSocketFactory(); + + SSLSocket socket = (SSLSocket)factory.createSocket(); + + if (getWantClientAuth()) + socket.setWantClientAuth(getWantClientAuth()); + if (getNeedClientAuth()) + socket.setNeedClientAuth(getNeedClientAuth()); + + socket.setEnabledCipherSuites(selectCipherSuites( + socket.getEnabledCipherSuites(), + socket.getSupportedCipherSuites())); + socket.setEnabledProtocols(selectProtocols(socket.getEnabledProtocols(),socket.getSupportedProtocols())); + + return socket; + } + + /* ------------------------------------------------------------ */ + public SSLEngine newSslEngine(String host,int port) + { + SSLEngine sslEngine=isSessionCachingEnabled() + ?_context.createSSLEngine(host, port) + :_context.createSSLEngine(); + + customize(sslEngine); + return sslEngine; + } + + /* ------------------------------------------------------------ */ + public SSLEngine newSslEngine() + { + SSLEngine sslEngine=_context.createSSLEngine(); + customize(sslEngine); + return sslEngine; + } + + /* ------------------------------------------------------------ */ + public void customize(SSLEngine sslEngine) + { + if (getWantClientAuth()) + sslEngine.setWantClientAuth(getWantClientAuth()); + if (getNeedClientAuth()) + sslEngine.setNeedClientAuth(getNeedClientAuth()); + + sslEngine.setEnabledCipherSuites(selectCipherSuites( + sslEngine.getEnabledCipherSuites(), + sslEngine.getSupportedCipherSuites())); + + sslEngine.setEnabledProtocols(selectProtocols(sslEngine.getEnabledProtocols(),sslEngine.getSupportedProtocols())); + } + } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java index d60f82dea6b..8bfe80a4f8a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java @@ -16,6 +16,8 @@ package org.eclipse.jetty.server.ssl; import java.io.IOException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; +import java.util.Arrays; + import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLSession; @@ -36,7 +38,6 @@ import org.eclipse.jetty.io.nio.SslSelectChannelEndPoint; import org.eclipse.jetty.server.HttpConnection; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.nio.SelectChannelConnector; -import org.eclipse.jetty.util.log.Log; /* ------------------------------------------------------------ */ /** @@ -97,7 +98,9 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements SslSelectChannelEndPoint sslHttpChannelEndpoint=(SslSelectChannelEndPoint)endpoint; SSLEngine sslEngine=sslHttpChannelEndpoint.getSSLEngine(); SSLSession sslSession=sslEngine.getSession(); - + + System.err.println(sslSession.getProtocol()); + SslCertificates.customize(sslSession,endpoint,request); } @@ -565,33 +568,19 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements protected SSLEngine createSSLEngine(SocketChannel channel) throws IOException { SSLEngine engine; - if (channel != null && _sslContextFactory.isSessionCachingEnabled()) + if (channel != null) { String peerHost = channel.socket().getInetAddress().getHostAddress(); int peerPort = channel.socket().getPort(); - engine = _sslContextFactory.getSslContext().createSSLEngine(peerHost, peerPort); + engine = _sslContextFactory.newSslEngine(peerHost, peerPort); } else { - engine = _sslContextFactory.getSslContext().createSSLEngine(); + engine = _sslContextFactory.newSslEngine(); } - customizeEngine(engine); - return engine; - } - - /* ------------------------------------------------------------ */ - private void customizeEngine(SSLEngine engine) - { + engine.setUseClientMode(false); - - if (_sslContextFactory.getWantClientAuth()) - engine.setWantClientAuth(_sslContextFactory.getWantClientAuth()); - if (_sslContextFactory.getNeedClientAuth()) - engine.setNeedClientAuth(_sslContextFactory.getNeedClientAuth()); - - engine.setEnabledCipherSuites( - _sslContextFactory.selectCipherSuites(engine.getEnabledCipherSuites(), - engine.getSupportedCipherSuites())); + return engine; } /* ------------------------------------------------------------ */ @@ -601,22 +590,13 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements @Override protected void doStart() throws Exception { - if (!_sslContextFactory.checkConfig()) - { - throw new IllegalStateException("SSL context is not configured correctly."); - } + _sslContextFactory.checkKeyStore(); _sslContextFactory.start(); - SSLEngine sslEngine = _sslContextFactory.getSslContext().createSSLEngine(); + SSLEngine sslEngine = _sslContextFactory.newSslEngine(); sslEngine.setUseClientMode(false); - sslEngine.setWantClientAuth(_sslContextFactory.getWantClientAuth()); - sslEngine.setNeedClientAuth(_sslContextFactory.getNeedClientAuth()); - - sslEngine.setEnabledCipherSuites(_sslContextFactory.selectCipherSuites( - sslEngine.getEnabledCipherSuites(), - sslEngine.getSupportedCipherSuites())); SSLSession sslSession = sslEngine.getSession(); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java index 85c50bb4a94..be7c5dcf12a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSocketConnector.java @@ -335,11 +335,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector @Override public void open() throws IOException { - if (!_sslContextFactory.checkConfig()) - { - throw new IllegalStateException("SSL context is not configured correctly."); - } - + _sslContextFactory.checkKeyStore(); try { _sslContextFactory.start(); @@ -358,11 +354,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector @Override protected void doStart() throws Exception { - if (!_sslContextFactory.checkConfig()) - { - throw new IllegalStateException("SSL context is not configured correctly."); - } - + _sslContextFactory.checkKeyStore(); _sslContextFactory.start(); super.doStart(); @@ -394,22 +386,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector @Override protected ServerSocket newServerSocket(String host, int port,int backlog) throws IOException { - SSLServerSocketFactory factory = _sslContextFactory.getSslContext().getServerSocketFactory(); - - SSLServerSocket socket = - (SSLServerSocket) (host==null ? - factory.createServerSocket(port,backlog): - factory.createServerSocket(port,backlog,InetAddress.getByName(host))); - - if (_sslContextFactory.getWantClientAuth()) - socket.setWantClientAuth(_sslContextFactory.getWantClientAuth()); - if (_sslContextFactory.getNeedClientAuth()) - socket.setNeedClientAuth(_sslContextFactory.getNeedClientAuth()); - - socket.setEnabledCipherSuites(_sslContextFactory.selectCipherSuites( - socket.getEnabledCipherSuites(), - socket.getSupportedCipherSuites())); - return socket; + return _sslContextFactory.newSslServerSocket(host,port,backlog); } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index 8b1c982db7f..2b510cd8504 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -425,7 +425,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture while(len>=0) { - Thread.sleep(500); + Thread.sleep(100); len=is.read(buf); if (len>0) total+=len; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java index 0373a3f3e4f..432d51ea689 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java @@ -133,7 +133,7 @@ public class SSLEngineTest @Test public void testBigResponse() throws Exception { - SSLContext ctx=SSLContext.getInstance("SSLv3"); + SSLContext ctx=SSLContext.getInstance("TLS"); ctx.init(null,s_dummyTrustManagers,new java.security.SecureRandom()); int port=connector.getLocalPort(); @@ -367,4 +367,5 @@ public class SSLEngineTest response.flushBuffer(); } } + } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSelectChannelServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSelectChannelServerTest.java index 1acfa7d9e29..a568fe7ce70 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSelectChannelServerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSelectChannelServerTest.java @@ -60,14 +60,14 @@ public class SslSelectChannelServerTest extends HttpServerTestBase keystore.load(new FileInputStream(connector.getKeystore()), "storepwd".toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keystore); - __sslContext = SSLContext.getInstance("SSL"); + __sslContext = SSLContext.getInstance("TLS"); __sslContext.init(null, trustManagerFactory.getTrustManagers(), null); try { HttpsURLConnection.setDefaultHostnameVerifier(__hostnameverifier); - SSLContext sc = SSLContext.getInstance("SSL"); + SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, __trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSocketServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSocketServerTest.java index c9da61e856d..f77757beb2d 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSocketServerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSocketServerTest.java @@ -15,8 +15,10 @@ package org.eclipse.jetty.server.ssl; import java.io.FileInputStream; import java.net.Socket; import java.security.KeyStore; +import java.util.Arrays; import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; import javax.net.ssl.TrustManagerFactory; import org.eclipse.jetty.http.ssl.SslContextFactory; @@ -37,7 +39,9 @@ public class SslSocketServerTest extends HttpServerTestBase @Override protected Socket newSocket(String host, int port) throws Exception { - return __sslContext.getSocketFactory().createSocket(host,port); + SSLSocket socket = (SSLSocket)__sslContext.getSocketFactory().createSocket(host,port); + socket.setEnabledProtocols(new String[] {"TLSv1"}); + return socket; } @@ -59,7 +63,7 @@ public class SslSocketServerTest extends HttpServerTestBase keystore.load(new FileInputStream(connector.getKeystore()), "storepwd".toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keystore); - __sslContext = SSLContext.getInstance("SSL"); + __sslContext = SSLContext.getInstance("TLSv1"); __sslContext.init(null, trustManagerFactory.getTrustManagers(), null); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSocketTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSocketTimeoutTest.java index edcaac7b785..d995f0e5c3a 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSocketTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSocketTimeoutTest.java @@ -18,6 +18,7 @@ import java.net.Socket; import java.security.KeyStore; import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; import javax.net.ssl.TrustManagerFactory; import org.eclipse.jetty.http.ssl.SslContextFactory; @@ -26,12 +27,14 @@ import org.junit.BeforeClass; public class SslSocketTimeoutTest extends ConnectorTimeoutTest { - static SSLContext _sslContext; + static SSLContext __sslContext; @Override protected Socket newSocket(String host, int port) throws Exception { - return _sslContext.getSocketFactory().createSocket(host,port); + SSLSocket socket = (SSLSocket)__sslContext.getSocketFactory().createSocket(host,port); + socket.setEnabledProtocols(new String[] {"TLSv1"}); + return socket; } @BeforeClass @@ -53,8 +56,8 @@ public class SslSocketTimeoutTest extends ConnectorTimeoutTest keystore.load(new FileInputStream(connector.getKeystore()), "storepwd".toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keystore); - _sslContext = SSLContext.getInstance("SSL"); - _sslContext.init(null, trustManagerFactory.getTrustManagers(), null); + __sslContext = SSLContext.getInstance("TLSv1"); + __sslContext.init(null, trustManagerFactory.getTrustManagers(), null); } diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpsSocketImpl.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpsSocketImpl.java index 3a071047195..332aa4fed39 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpsSocketImpl.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpsSocketImpl.java @@ -25,6 +25,7 @@ import java.net.SocketAddress; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; @@ -78,7 +79,7 @@ public class HttpsSocketImpl implements HttpSocket try { // TODO real trust manager - this.sslContext = SSLContext.getInstance("SSL"); + this.sslContext = SSLContext.getInstance("TLS"); sslContext.init(null,trustAllCerts,new java.security.SecureRandom()); } catch (Exception e) @@ -87,11 +88,13 @@ public class HttpsSocketImpl implements HttpSocket } sslfactory = sslContext.getSocketFactory(); + } public Socket connect(InetAddress host, int port) throws IOException { - Socket sslsock = sslfactory.createSocket(); + SSLSocket sslsock = (SSLSocket)sslfactory.createSocket(); + sslsock.setEnabledProtocols(new String[] {"TLSv1"}); SocketAddress address = new InetSocketAddress(host,port); sslsock.connect(address); return sslsock; From 0d09b6e310aba5ec0b14cfea6f357c2a84634ca1 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 23 Sep 2011 14:11:04 +1000 Subject: [PATCH 070/134] 358674 Still allows sslv3 for now --- .../java/org/eclipse/jetty/http/ssl/SslContextFactory.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java index 33ec5f964f2..efc2ab72788 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java @@ -93,7 +93,8 @@ public class SslContextFactory extends AbstractLifeCycle public static final String PASSWORD_PROPERTY = "org.eclipse.jetty.ssl.password"; /** Excluded protocols. */ - private final Set _excludeProtocols = new HashSet(Collections.singleton("SSLv2Hello")); + private final Set _excludeProtocols = new HashSet(); + // private final Set _excludeProtocols = new HashSet(Collections.singleton("SSLv2Hello")); /** Included protocols. */ private Set _includeProtocols = null; @@ -211,7 +212,7 @@ public class SslContextFactory extends AbstractLifeCycle if (_keyStoreInputStream == null && _keyStorePath == null && _trustStoreInputStream == null && _trustStorePath == null ) { - LOG.info("No keystore or trust store configured. ACCEPTING UNTRUSTED CERTIFICATES!!!!!"); + LOG.debug("No keystore or trust store configured. ACCEPTING UNTRUSTED CERTIFICATES!!!!!"); // Create a trust manager that does not validate certificate chains TrustManager trustAllCerts = new X509TrustManager() { From 8195103f011efb4575f5bb3cd121b5dd04c12768 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 23 Sep 2011 14:12:40 +1000 Subject: [PATCH 071/134] 358035 idle time only active if > 0 --- .../java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java | 2 +- .../main/java/org/eclipse/jetty/server/HttpConnection.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index d682584c096..5a8ed7842b6 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -251,7 +251,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo public void checkIdleTimestamp(long now) { long idleTimestamp=_idleTimestamp; - if (!getChannel().isOpen() || idleTimestamp!=0 && _maxIdleTime!=0 && now>(idleTimestamp+_maxIdleTime)) + if (!getChannel().isOpen() || idleTimestamp!=0 && _maxIdleTime>0 && now>(idleTimestamp+_maxIdleTime)) idleExpired(); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index 8ee1938d1c6..26d2fb6071b 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -674,10 +674,10 @@ public abstract class HttpConnection extends AbstractConnection /* ------------------------------------------------------------ */ public int getMaxIdleTime() { + if (_connector.isLowResources() && _endp.getMaxIdleTime()==_connector.getMaxIdleTime()) + return _connector.getLowResourceMaxIdleTime(); if (_endp.getMaxIdleTime()>0) return _endp.getMaxIdleTime(); - if (_connector.isLowResources()) - return _connector.getLowResourceMaxIdleTime(); return _connector.getMaxIdleTime(); } From 8d6f64c902c394dc18aa1f73f0ea4f9b2df45605 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 23 Sep 2011 14:51:25 +1000 Subject: [PATCH 072/134] 358687 Updated jsp does not scan for system tlds --- .../src/main/config/etc/jetty-deploy.xml | 2 +- .../jetty/webapp/TagLibConfiguration.java | 63 ++++++++++++++++++- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/jetty-deploy/src/main/config/etc/jetty-deploy.xml b/jetty-deploy/src/main/config/etc/jetty-deploy.xml index ebbec509329..aaa490349e1 100644 --- a/jetty-deploy/src/main/config/etc/jetty-deploy.xml +++ b/jetty-deploy/src/main/config/etc/jetty-deploy.xml @@ -22,7 +22,7 @@ org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern - .*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$ + .*/*jsp-api-[^/]*\.jar$|.*/*jsp-[^/]*\.jar$|.*/*taglib*\.jar$ diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/TagLibConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/TagLibConfiguration.java index f5f14b8e4d7..863c85c9113 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/TagLibConfiguration.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/TagLibConfiguration.java @@ -14,13 +14,16 @@ package org.eclipse.jetty.webapp; import java.io.IOException; +import java.net.URI; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.EventListener; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import javax.servlet.Servlet; @@ -58,6 +61,7 @@ public class TagLibConfiguration extends AbstractConfiguration public static final String TLD_RESOURCES = "org.eclipse.jetty.tlds"; + /** * TagLibListener * @@ -96,7 +100,37 @@ public class TagLibConfiguration extends AbstractConfiguration public void contextInitialized(ServletContextEvent sce) { - try { + try + { + //For jasper 2.1: + //Get the system classpath tlds and tell jasper about them, if jasper is on the classpath + try + { + Class clazz = getClass().getClassLoader().loadClass("org.apache.jasper.compiler.TldLocationsCache"); + Collection tld_resources = (Collection)_context.getAttribute(TLD_RESOURCES); + + Map> tldMap = new HashMap>(); + + if (tld_resources != null) + { + //get the jar file names of the files + for (Resource r:tld_resources) + { + Resource jarResource = extractJarResource(r); + //jasper is happy with an empty list of tlds + if (!tldMap.containsKey(jarResource.getURI())) + tldMap.put(jarResource.getURI(), null); + + } + //set the magic context attribute that tells jasper about the system tlds + sce.getServletContext().setAttribute("com.sun.appserv.tld.map", tldMap); + } + } + catch (ClassNotFoundException e) + { + LOG.ignore(e); + } + //find the tld files and parse them to get out their //listeners Set tlds = findTldResources(); @@ -117,12 +151,37 @@ public class TagLibConfiguration extends AbstractConfiguration } } - } catch (Exception e) { + } + catch (Exception e) { LOG.warn(e); } } + + + private Resource extractJarResource (Resource r) + { + if (r == null) + return null; + + try + { + String url = r.getURI().toURL().toString(); + int idx = url.lastIndexOf("!/"); + if (idx >= 0) + url = url.substring(0, idx); + if (url.startsWith("jar:")) + url = url.substring(4); + return Resource.newResource(url); + } + catch (IOException e) + { + LOG.warn(e); + return null; + } + } + /** * Find all the locations that can harbour tld files that may contain * a listener which the web container is supposed to instantiate and From 7e00a1d13cf98d5c041c97183877b3df96481c19 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 23 Sep 2011 14:56:07 +1000 Subject: [PATCH 073/134] 358687 Updated jsp does not scan for system tlds Fixed pattern. --- jetty-deploy/src/main/config/etc/jetty-deploy.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-deploy/src/main/config/etc/jetty-deploy.xml b/jetty-deploy/src/main/config/etc/jetty-deploy.xml index aaa490349e1..dd25f7ff34c 100644 --- a/jetty-deploy/src/main/config/etc/jetty-deploy.xml +++ b/jetty-deploy/src/main/config/etc/jetty-deploy.xml @@ -22,7 +22,7 @@ org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern - .*/*jsp-api-[^/]*\.jar$|.*/*jsp-[^/]*\.jar$|.*/*taglib*\.jar$ + .*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$ From df0371796e3890bc89a138125b68a0eed7bdd089 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 26 Sep 2011 15:03:12 +1000 Subject: [PATCH 074/134] fixed bad import --- .../main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java index efc2ab72788..90227c88073 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/ssl/SslContextFactory.java @@ -45,7 +45,6 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; -import javax.net.ssl.SSLSessionContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; @@ -61,7 +60,6 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.security.CertificateUtils; import org.eclipse.jetty.util.security.CertificateValidator; -import org.junit.experimental.categories.Categories.IncludeCategory; /* ------------------------------------------------------------ */ From 0555cc762f8a9df0259d6af5dad51c9a46f93cb5 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 26 Sep 2011 20:23:38 +1000 Subject: [PATCH 075/134] 358784 JSP broken on Java 1.5 --- jetty-jsp-2.1/pom.xml | 82 ++++++++++---- .../java/org/eclipse/jetty/jsp/JettyLog.java | 102 ------------------ 2 files changed, 62 insertions(+), 122 deletions(-) delete mode 100644 jetty-jsp-2.1/src/main/java/org/eclipse/jetty/jsp/JettyLog.java diff --git a/jetty-jsp-2.1/pom.xml b/jetty-jsp-2.1/pom.xml index ca42f774f54..aa77baff7c7 100644 --- a/jetty-jsp-2.1/pom.xml +++ b/jetty-jsp-2.1/pom.xml @@ -13,6 +13,54 @@ + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + generate-sources + + unpack + + + + + org.glassfish.web + jsp-impl + 2.1.3-b10 + jar + sources + true + target/generated-sources + **/JDTJavaCompiler.java + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + add-source + generate-sources + + add-source + + + + target/generated-sources + + + + + + org.apache.felix maven-bundle-plugin @@ -26,14 +74,12 @@ - - com.sun.org.apache.commons.logging;version="[2.1,3)";glassfish="split", + + org.apache.jasper;version="[2.1,3)";glassfish="split", * - - org.eclipse.jetty*;version="${parsedVersion.osgiVersion}" - org.apache.jasper.glassfish - + + org.apache.jasper*;version="${parsedVersion.osgiVersion}" + org.apache.jasper.glassfish <_nouses>true @@ -61,20 +107,10 @@ - org.eclipse.jetty - jetty-util - ${project.version} - provided - - - org.mortbay.jetty - jsp-2.1-glassfish - ${javax-servlet-jsp-version} + org.glassfish.web + jsp-impl + 2.1.3-b10 - - org.mortbay.jetty - servlet-api - provided @@ -83,5 +119,11 @@ servlet-api provided + + org.eclipse.jdt.core.compiler + ecj + 3.7 + provided + diff --git a/jetty-jsp-2.1/src/main/java/org/eclipse/jetty/jsp/JettyLog.java b/jetty-jsp-2.1/src/main/java/org/eclipse/jetty/jsp/JettyLog.java deleted file mode 100644 index e8bd4afe952..00000000000 --- a/jetty-jsp-2.1/src/main/java/org/eclipse/jetty/jsp/JettyLog.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.eclipse.jetty.jsp; - -import com.sun.org.apache.commons.logging.LogFactory; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; - -/** - * @version $Revision$ $Date$ - */ -public class JettyLog implements com.sun.org.apache.commons.logging.Log -{ - private static volatile boolean __initialized; - - /** - * Called via reflection from WebXmlProcessor - */ - public static synchronized void init() - { - if (!__initialized) - { - __initialized = true; - LogFactory.setLogImplClassName(JettyLog.class.getName()); - } - } - - private final Logger _logger; - - public JettyLog(String name) - { - _logger = Log.getLogger(name); - } - - public void fatal(Object o) - { - error(o); - } - - public void fatal(Object o, Throwable throwable) - { - error(o, throwable); - } - - public boolean isErrorEnabled() - { - return true; - } - - public void error(Object o) - { - warn(o); - } - - public void error(Object o, Throwable throwable) - { - _logger.warn(String.valueOf(o), throwable); - } - - public boolean isWarnEnabled() - { - return true; - } - - public void warn(Object o) - { - _logger.warn(String.valueOf(o)); - } - - public boolean isInfoEnabled() - { - return true; - } - - public void info(Object o) - { - _logger.info(String.valueOf(o)); - } - - public boolean isDebugEnabled() - { - return _logger.isDebugEnabled(); - } - - public void debug(Object o) - { - _logger.debug(String.valueOf(o)); - } - - public void debug(Object o, Throwable throwable) - { - _logger.debug(String.valueOf(o), throwable); - } - - public boolean isTraceEnabled() - { - return isDebugEnabled(); - } - - public void trace(Object o) - { - debug(o); - } -} From 11ae5c7dd386b5b778386acebdcccdd849d34f6e Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 26 Sep 2011 20:59:37 +1000 Subject: [PATCH 076/134] JETTY-1434 Add a jsp that exercises jstl. --- test-jetty-webapp/src/main/webapp/jsp/index.html | 1 + test-jetty-webapp/src/main/webapp/jsp/jstl.jsp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test-jetty-webapp/src/main/webapp/jsp/jstl.jsp diff --git a/test-jetty-webapp/src/main/webapp/jsp/index.html b/test-jetty-webapp/src/main/webapp/jsp/index.html index 935f85bc7a4..5a7376ac2da 100644 --- a/test-jetty-webapp/src/main/webapp/jsp/index.html +++ b/test-jetty-webapp/src/main/webapp/jsp/index.html @@ -10,6 +10,7 @@

  • JSP 2.0 SimpleTag demo
  • JSP 2.0 Tag File demo
  • JSP 2.0 Tag Expression
    +
  • JSTL Expression
    Main Menu diff --git a/test-jetty-webapp/src/main/webapp/jsp/jstl.jsp b/test-jetty-webapp/src/main/webapp/jsp/jstl.jsp new file mode 100644 index 00000000000..9fa7b57e96c --- /dev/null +++ b/test-jetty-webapp/src/main/webapp/jsp/jstl.jsp @@ -0,0 +1,15 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + +

    JSTL Example

    +
    +

    A trivial jstl example +


    + + +
    +
    + + From 27753fa747430bc6834eed2d0bfe7c8252de2328 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 26 Sep 2011 23:00:57 +1000 Subject: [PATCH 077/134] removed debug --- .../eclipse/jetty/client/AsyncSslHttpExchangeTest.java | 8 ++++++++ .../jetty/server/ssl/SslSelectChannelConnector.java | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java index 8cfe3d7d2e6..e8c2accd48d 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java @@ -29,4 +29,12 @@ public class AsyncSslHttpExchangeTest extends SslHttpExchangeTest _httpClient = serverAndClientCreator.createClient(3000L,3500L,2000); _port = _server.getConnectors()[0].getLocalPort(); } + + @Override + public void testPerf() throws Exception + { + super.testPerf(); + } + + } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java index 8bfe80a4f8a..b1b3347321c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java @@ -98,9 +98,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements SslSelectChannelEndPoint sslHttpChannelEndpoint=(SslSelectChannelEndPoint)endpoint; SSLEngine sslEngine=sslHttpChannelEndpoint.getSSLEngine(); SSLSession sslSession=sslEngine.getSession(); - - System.err.println(sslSession.getProtocol()); - + SslCertificates.customize(sslSession,endpoint,request); } From 88ce9aceb25fd3bce460904a66c98095391f220b Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Fri, 23 Sep 2011 17:43:07 +0200 Subject: [PATCH 078/134] Added ProxyRule.java and ProxyRuleTest.java --- .../jetty/rewrite/handler/ProxyRule.java | 282 ++++++++++++++++++ .../jetty/rewrite/handler/ProxyRuleTest.java | 77 +++++ 2 files changed, 359 insertions(+) create mode 100644 jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java create mode 100644 jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java new file mode 100644 index 00000000000..b5516bcbf68 --- /dev/null +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java @@ -0,0 +1,282 @@ +package org.eclipse.jetty.rewrite.handler; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.util.Enumeration; +import java.util.HashSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.HttpExchange; +import org.eclipse.jetty.http.HttpHeaderValues; +import org.eclipse.jetty.http.HttpHeaders; +import org.eclipse.jetty.http.HttpSchemes; +import org.eclipse.jetty.http.HttpURI; +import org.eclipse.jetty.io.Buffer; +import org.eclipse.jetty.io.EofException; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.util.thread.QueuedThreadPool; + +public class ProxyRule extends Rule +{ + private static final Logger _log = Log.getLogger(ProxyRule.class); + + protected HttpClient _client; + protected String _hostHeader; + + protected HashSet _DontProxyHeaders = new HashSet(); + { + _DontProxyHeaders.add("proxy-connection"); + _DontProxyHeaders.add("connection"); + _DontProxyHeaders.add("keep-alive"); + _DontProxyHeaders.add("transfer-encoding"); + _DontProxyHeaders.add("te"); + _DontProxyHeaders.add("trailer"); + _DontProxyHeaders.add("proxy-authorization"); + _DontProxyHeaders.add("proxy-authenticate"); + _DontProxyHeaders.add("upgrade"); + } + + public ProxyRule() + { + _handling = true; + _terminating = true; + + } + + private void initializeClient() throws Exception + { + _client = new HttpClient(); + _client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + _client.setThreadPool(new QueuedThreadPool()); + _client.start(); + } + + /* ------------------------------------------------------------ */ + protected HttpURI proxyHttpURI(String scheme, String serverName, int serverPort, String uri) throws MalformedURLException + { + return new HttpURI(scheme + "://" + serverName + ":" + serverPort + uri); + } + + @Override + public String matchAndApply(String target, HttpServletRequest req, HttpServletResponse res) throws IOException + { + synchronized (this) + { + if (_client == null) + { + try + { + initializeClient(); + } + catch (Exception e) + { + throw new IOException("Unable to proxy: " + e.getMessage()); + } + } + } + + final HttpServletRequest request = (HttpServletRequest)req; + final HttpServletResponse response = (HttpServletResponse)res; + + final int debug = _log.isDebugEnabled()?request.hashCode():0; + + final InputStream in = request.getInputStream(); + final OutputStream out = response.getOutputStream(); + + String uri = request.getRequestURI(); + if (request.getQueryString() != null) + uri += "?" + request.getQueryString(); + + HttpURI url = proxyHttpURI(request.getScheme(),request.getServerName(),request.getServerPort(),uri); + + if (debug != 0) + _log.debug(debug + " proxy " + uri + "-->" + url); + + if (url == null) + { + response.sendError(HttpServletResponse.SC_FORBIDDEN); + return target; + } + + HttpExchange exchange = new HttpExchange() + { + protected void onRequestCommitted() throws IOException + { + } + + protected void onRequestComplete() throws IOException + { + } + + protected void onResponseComplete() throws IOException + { + if (debug != 0) + _log.debug(debug + " complete"); + } + + protected void onResponseContent(Buffer content) throws IOException + { + if (debug != 0) + _log.debug(debug + " content" + content.length()); + content.writeTo(out); + } + + protected void onResponseHeaderComplete() throws IOException + { + } + + protected void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException + { + if (debug != 0) + _log.debug(debug + " " + version + " " + status + " " + reason); + + if (reason != null && reason.length() > 0) + response.setStatus(status,reason.toString()); + else + response.setStatus(status); + } + + protected void onResponseHeader(Buffer name, Buffer value) throws IOException + { + String s = name.toString().toLowerCase(); + if (!_DontProxyHeaders.contains(s) || (HttpHeaders.CONNECTION_BUFFER.equals(name) && HttpHeaderValues.CLOSE_BUFFER.equals(value))) + { + if (debug != 0) + _log.debug(debug + " " + name + ": " + value); + + response.addHeader(name.toString(),value.toString()); + } + else if (debug != 0) + _log.debug(debug + " " + name + "! " + value); + } + + protected void onConnectionFailed(Throwable ex) + { + _log.warn(ex.toString()); + _log.debug(ex); + if (!response.isCommitted()) + { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + + protected void onException(Throwable ex) + { + if (ex instanceof EofException) + { + _log.ignore(ex); + return; + } + _log.warn(ex.toString()); + _log.debug(ex); + if (!response.isCommitted()) + { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + + protected void onExpire() + { + if (!response.isCommitted()) + { + response.setStatus(HttpServletResponse.SC_GATEWAY_TIMEOUT); + } + } + + }; + + exchange.setScheme(HttpSchemes.HTTPS.equals(request.getScheme())?HttpSchemes.HTTPS_BUFFER:HttpSchemes.HTTP_BUFFER); + exchange.setMethod(request.getMethod()); + exchange.setURL(url.toString()); + exchange.setVersion(request.getProtocol()); + + if (debug != 0) + _log.debug(debug + " " + request.getMethod() + " " + url + " " + request.getProtocol()); + + // check connection header + String connectionHdr = request.getHeader("Connection"); + if (connectionHdr != null) + { + connectionHdr = connectionHdr.toLowerCase(); + if (connectionHdr.indexOf("keep-alive") < 0 && connectionHdr.indexOf("close") < 0) + connectionHdr = null; + } + + // force host + if (_hostHeader != null) + exchange.setRequestHeader("Host",_hostHeader); + + // copy headers + boolean xForwardedFor = false; + boolean hasContent = false; + long contentLength = -1; + Enumeration enm = request.getHeaderNames(); + while (enm.hasMoreElements()) + { + // TODO could be better than this! + String hdr = (String)enm.nextElement(); + String lhdr = hdr.toLowerCase(); + + if (_DontProxyHeaders.contains(lhdr)) + continue; + if (connectionHdr != null && connectionHdr.indexOf(lhdr) >= 0) + continue; + if (_hostHeader != null && "host".equals(lhdr)) + continue; + + if ("content-type".equals(lhdr)) + hasContent = true; + else if ("content-length".equals(lhdr)) + { + contentLength = request.getContentLength(); + exchange.setRequestHeader(HttpHeaders.CONTENT_LENGTH,Long.toString(contentLength)); + if (contentLength > 0) + hasContent = true; + } + else if ("x-forwarded-for".equals(lhdr)) + xForwardedFor = true; + + Enumeration vals = request.getHeaders(hdr); + while (vals.hasMoreElements()) + { + String val = (String)vals.nextElement(); + if (val != null) + { + if (debug != 0) + _log.debug(debug + " " + hdr + ": " + val); + + exchange.setRequestHeader(hdr,val); + } + } + } + + // Proxy headers + exchange.setRequestHeader("Via","1.1 (jetty)"); + if (!xForwardedFor) + { + exchange.addRequestHeader("X-Forwarded-For",request.getRemoteAddr()); + exchange.addRequestHeader("X-Forwarded-Proto",request.getScheme()); + exchange.addRequestHeader("X-Forwarded-Host",request.getServerName()); + exchange.addRequestHeader("X-Forwarded-Server",request.getLocalName()); + } + + if (hasContent) + exchange.setRequestContentSource(in); + + /* + * we need to set the timeout on the continuation to take into account the timeout of the HttpClient and the HttpExchange + */ + long ctimeout = (_client.getTimeout() > exchange.getTimeout())?_client.getTimeout():exchange.getTimeout(); + + _client.send(exchange); + + return target; + } + +} diff --git a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java new file mode 100644 index 00000000000..9f021a5794f --- /dev/null +++ b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java @@ -0,0 +1,77 @@ +// ======================================================================== +// Copyright (c) 2006-2009 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.rewrite.handler; + +import java.io.IOException; +import java.net.URI; +import java.net.URLEncoder; + +import org.eclipse.jetty.client.Address; +import org.eclipse.jetty.client.ContentExchange; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.HttpExchange; +import org.eclipse.jetty.http.HttpHeaders; +import org.eclipse.jetty.http.HttpMethods; +import org.eclipse.jetty.toolchain.test.SimpleRequest; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class ProxyRuleTest extends AbstractRuleTestCase +{ + private ProxyRule _rule; + private RewriteHandler _handler; + + @Before + public void init() throws Exception + { + start(false); + _rule = new ProxyRule(); + + _handler = new RewriteHandler(); + _handler.setRewriteRequestURI(true); + + _handler.setRules(new Rule[] { _rule } ); + + _server.setHandler(_handler); + } + + @After + public void destroy() + { + _rule = null; + } + + @Test + public void testProxy() throws Exception + { +// HttpClient httpClient = new HttpClient(); +// httpClient.setProxy(new Address("localhost", proxyPort())); +// httpClient.start(); +// +// try +// { +// ContentExchange exchange = new ContentExchange(true); +// exchange.setMethod(HttpMethods.GET); +// String body = "BODY"; +// exchange.setURL("https://localhost:" + serverConnector.getLocalPort() + "/echo?body=" + URLEncoder.encode(body, "UTF-8")); +// +// httpClient.send(exchange); +// assertEquals(HttpExchange.STATUS_COMPLETED, exchange.waitForDone()); +// //_rule.matchAndApply(null, _request, _response); +// +// //assertEquals(location, _response.getHeader(HttpHeaders.LOCATION)); + } +} From 0d8bd99d6a9984358f9b8d62c84b4fb12364cb15 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Mon, 26 Sep 2011 14:41:15 +0200 Subject: [PATCH 079/134] Basic functionality for ProxyRule implemented --- .../java/org/eclipse/jetty/http/PathMap.java | 120 +++++++++--------- jetty-rewrite/pom.xml | 5 + .../jetty/rewrite/handler/ProxyRule.java | 80 ++++++++---- .../jetty/rewrite/handler/ProxyRuleTest.java | 91 +++++++++---- 4 files changed, 183 insertions(+), 113 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java b/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java index 7e24daa3ebf..19da9e00104 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java @@ -4,11 +4,11 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.http; @@ -34,7 +34,7 @@ import org.eclipse.jetty.util.URIUtil; * /foo/bar - an exact path specification. * /foo/* - a prefix path specification (must end '/*'). * *.ext - a suffix path specification. - * / - the default path specification. + * / - the default path specification. * * Matching is performed in the following order *
  • Exact match. @@ -43,24 +43,24 @@ import org.eclipse.jetty.util.URIUtil; *
  • default. * * Multiple path specifications can be mapped by providing a list of - * specifications. By default this class uses characters ":," as path - * separators, unless configured differently by calling the static - * method @see PathMap#setPathSpecSeparators(String) + * specifications. By default this class uses characters ":," as path + * separators, unless configured differently by calling the static + * method @see PathMap#setPathSpecSeparators(String) *

    * Special characters within paths such as '?� and ';' are not treated specially - * as it is assumed they would have been either encoded in the original URL or + * as it is assumed they would have been either encoded in the original URL or * stripped from the path. *

    * This class is not synchronized. If concurrent modifications are * possible then it should be synchronized at a higher level. * - * + * */ public class PathMap extends HashMap implements Externalizable { /* ------------------------------------------------------------ */ private static String __pathSpecSeparators = ":,"; - + /* ------------------------------------------------------------ */ /** Set the path spec separator. * Multiple path specification may be included in a single string @@ -72,7 +72,7 @@ public class PathMap extends HashMap implements Externalizable { __pathSpecSeparators=s; } - + /* --------------------------------------------------------------- */ final StringMap _prefixMap=new StringMap(); final StringMap _suffixMap=new StringMap(); @@ -83,7 +83,7 @@ public class PathMap extends HashMap implements Externalizable Entry _default=null; final Set _entrySet; boolean _nodefault=false; - + /* --------------------------------------------------------------- */ /** Construct empty PathMap. */ @@ -102,7 +102,7 @@ public class PathMap extends HashMap implements Externalizable _entrySet=entrySet(); _nodefault=nodefault; } - + /* --------------------------------------------------------------- */ /** Construct empty PathMap. */ @@ -111,7 +111,7 @@ public class PathMap extends HashMap implements Externalizable super (capacity); _entrySet=entrySet(); } - + /* --------------------------------------------------------------- */ /** Construct from dictionary PathMap. */ @@ -120,7 +120,7 @@ public class PathMap extends HashMap implements Externalizable putAll(m); _entrySet=entrySet(); } - + /* ------------------------------------------------------------ */ public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException @@ -128,7 +128,7 @@ public class PathMap extends HashMap implements Externalizable HashMap map = new HashMap(this); out.writeObject(map); } - + /* ------------------------------------------------------------ */ public void readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException @@ -136,7 +136,7 @@ public class PathMap extends HashMap implements Externalizable HashMap map = (HashMap)in.readObject(); this.putAll(map); } - + /* --------------------------------------------------------------- */ /** Add a single path match to the PathMap. * @param pathSpec The path specification, or comma separated list of @@ -148,16 +148,16 @@ public class PathMap extends HashMap implements Externalizable { StringTokenizer tok = new StringTokenizer(pathSpec.toString(),__pathSpecSeparators); Object old =null; - + while (tok.hasMoreTokens()) { String spec=tok.nextToken(); - + if (!spec.startsWith("/") && !spec.startsWith("*.")) throw new IllegalArgumentException("PathSpec "+spec+". must start with '/' or '*.'"); - + old = super.put(spec,object); - + // Make entry that was just created. Entry entry = new Entry(spec,object); @@ -176,7 +176,7 @@ public class PathMap extends HashMap implements Externalizable else if (spec.startsWith("*.")) _suffixMap.put(spec.substring(2),entry); else if (spec.equals(URIUtil.SLASH)) - { + { if (_nodefault) _exactMap.put(spec,entry); else @@ -193,7 +193,7 @@ public class PathMap extends HashMap implements Externalizable } } } - + return old; } @@ -209,8 +209,8 @@ public class PathMap extends HashMap implements Externalizable return entry.getValue(); return null; } - - + + /* --------------------------------------------------------------- */ /** Get the entry mapped by the best specification. * @param path the path. @@ -222,14 +222,14 @@ public class PathMap extends HashMap implements Externalizable if (path==null) return null; - - int l=path.length(); + + int l=path.length(); // try exact match entry=_exactMap.getEntry(path,0,l); if (entry!=null) return (Entry) entry.getValue(); - + // prefix search int i=l; while((i=path.lastIndexOf('/',i-1))>=0) @@ -238,11 +238,11 @@ public class PathMap extends HashMap implements Externalizable if (entry!=null) return (Entry) entry.getValue(); } - + // Prefix Default if (_prefixDefault!=null) return _prefixDefault; - + // Extension search i=0; while ((i=path.indexOf('.',i+1))>0) @@ -250,12 +250,12 @@ public class PathMap extends HashMap implements Externalizable entry=_suffixMap.getEntry(path,i+1,l-i-1); if (entry!=null) return (Entry) entry.getValue(); - } - + } + // Default return _default; } - + /* --------------------------------------------------------------- */ /** Get all entries matched by the path. * Best match first. @@ -263,20 +263,20 @@ public class PathMap extends HashMap implements Externalizable * @return LazyList of Map.Entry instances key=pathSpec */ public Object getLazyMatches(String path) - { + { Map.Entry entry; Object entries=null; if (path==null) return LazyList.getList(entries); - + int l=path.length(); // try exact match entry=_exactMap.getEntry(path,0,l); if (entry!=null) entries=LazyList.add(entries,entry.getValue()); - + // prefix search int i=l-1; while((i=path.lastIndexOf('/',i-1))>=0) @@ -285,11 +285,11 @@ public class PathMap extends HashMap implements Externalizable if (entry!=null) entries=LazyList.add(entries,entry.getValue()); } - + // Prefix Default if (_prefixDefault!=null) entries=LazyList.add(entries,_prefixDefault); - + // Extension search i=0; while ((i=path.indexOf('.',i+1))>0) @@ -305,13 +305,13 @@ public class PathMap extends HashMap implements Externalizable // Optimization for just the default if (entries==null) return _defaultSingletonList; - + entries=LazyList.add(entries,_default); } - + return entries; } - + /* --------------------------------------------------------------- */ /** Get all entries matched by the path. * Best match first. @@ -319,7 +319,7 @@ public class PathMap extends HashMap implements Externalizable * @return List of Map.Entry instances key=pathSpec */ public List getMatches(String path) - { + { return LazyList.getList(getLazyMatches(path)); } @@ -330,12 +330,12 @@ public class PathMap extends HashMap implements Externalizable * @return Whether the PathMap contains any entries that match this */ public boolean containsMatch(String path) - { + { Entry match = getMatch(path); return match!=null && !match.equals(_default); } - /* --------------------------------------------------------------- */ + /* --------------------------------------------------------------- */ @Override public Object remove(Object pathSpec) { @@ -362,7 +362,7 @@ public class PathMap extends HashMap implements Externalizable } return super.remove(pathSpec); } - + /* --------------------------------------------------------------- */ @Override public void clear() @@ -374,7 +374,7 @@ public class PathMap extends HashMap implements Externalizable _defaultSingletonList=null; super.clear(); } - + /* --------------------------------------------------------------- */ /** * @return true if match. @@ -397,7 +397,7 @@ public class PathMap extends HashMap implements Externalizable { if (!noDefault && pathSpec.length()==1 || pathSpec.equals(path)) return true; - + if(isPathWildcardMatch(pathSpec, path)) return true; } @@ -419,24 +419,24 @@ public class PathMap extends HashMap implements Externalizable } return false; } - - + + /* --------------------------------------------------------------- */ /** Return the portion of a path that matches a path spec. * @return null if no match at all. */ public static String pathMatch(String pathSpec, String path) - { + { char c = pathSpec.charAt(0); - + if (c=='/') { if (pathSpec.length()==1) return path; - + if (pathSpec.equals(path)) return path; - + if (isPathWildcardMatch(pathSpec, path)) return path.substring(0,pathSpec.length()-2); } @@ -448,7 +448,7 @@ public class PathMap extends HashMap implements Externalizable } return null; } - + /* --------------------------------------------------------------- */ /** Return the portion of a path that is after a path spec. * @return The path info string @@ -456,12 +456,12 @@ public class PathMap extends HashMap implements Externalizable public static String pathInfo(String pathSpec, String path) { char c = pathSpec.charAt(0); - + if (c=='/') { if (pathSpec.length()==1) return null; - + boolean wildcard = isPathWildcardMatch(pathSpec, path); // handle the case where pathSpec uses a wildcard and path info is "/*" @@ -474,7 +474,7 @@ public class PathMap extends HashMap implements Externalizable return null; return path.substring(pathSpec.length()-2); } - } + } return null; } @@ -484,7 +484,7 @@ public class PathMap extends HashMap implements Externalizable * @param base The base the path is relative to. * @param pathSpec The spec of the path segment to ignore. * @param path the additional path - * @return base plus path with pathspec removed + * @return base plus path with pathspec removed */ public static String relativePath(String base, String pathSpec, @@ -508,7 +508,7 @@ public class PathMap extends HashMap implements Externalizable path = base + URIUtil.SLASH + info; return path; } - + /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */ @@ -516,7 +516,7 @@ public class PathMap extends HashMap implements Externalizable { private final Object key; private final Object value; - private String mapped; + private String mapped; private transient String string; Entry(Object key, Object value) @@ -529,7 +529,7 @@ public class PathMap extends HashMap implements Externalizable { return key; } - + public Object getValue() { return value; diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index a08b6edc75d..bdaeaaf0123 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -74,6 +74,11 @@ jetty-server ${project.version} + + org.eclipse.jetty + jetty-client + ${project.version} + javax.servlet servlet-api diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java index b5516bcbf68..ca2614f828d 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java @@ -14,22 +14,23 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpExchange; import org.eclipse.jetty.http.HttpHeaderValues; import org.eclipse.jetty.http.HttpHeaders; -import org.eclipse.jetty.http.HttpSchemes; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.EofException; +import org.eclipse.jetty.server.Request; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.QueuedThreadPool; -public class ProxyRule extends Rule +public class ProxyRule extends PatternRule implements Rule.ApplyURI { private static final Logger _log = Log.getLogger(ProxyRule.class); - protected HttpClient _client; - protected String _hostHeader; + private HttpClient _client; + private String _hostHeader; + private String _proxyTo; - protected HashSet _DontProxyHeaders = new HashSet(); + private HashSet _DontProxyHeaders = new HashSet(); { _DontProxyHeaders.add("proxy-connection"); _DontProxyHeaders.add("connection"); @@ -58,13 +59,18 @@ public class ProxyRule extends Rule } /* ------------------------------------------------------------ */ - protected HttpURI proxyHttpURI(String scheme, String serverName, int serverPort, String uri) throws MalformedURLException + private HttpURI proxyHttpURI(String uri) throws MalformedURLException { - return new HttpURI(scheme + "://" + serverName + ":" + serverPort + uri); + return new HttpURI(_proxyTo + uri); + } + + public void applyURI(Request request, String oldTarget, String newTarget) throws IOException + { + System.out.println("applyURI called"); } @Override - public String matchAndApply(String target, HttpServletRequest req, HttpServletResponse res) throws IOException + protected String apply(String target, HttpServletRequest request, final HttpServletResponse response) throws IOException { synchronized (this) { @@ -81,9 +87,6 @@ public class ProxyRule extends Rule } } - final HttpServletRequest request = (HttpServletRequest)req; - final HttpServletResponse response = (HttpServletResponse)res; - final int debug = _log.isDebugEnabled()?request.hashCode():0; final InputStream in = request.getInputStream(); @@ -93,7 +96,7 @@ public class ProxyRule extends Rule if (request.getQueryString() != null) uri += "?" + request.getQueryString(); - HttpURI url = proxyHttpURI(request.getScheme(),request.getServerName(),request.getServerPort(),uri); + HttpURI url = proxyHttpURI(uri); if (debug != 0) _log.debug(debug + " proxy " + uri + "-->" + url); @@ -106,20 +109,24 @@ public class ProxyRule extends Rule HttpExchange exchange = new HttpExchange() { + @Override protected void onRequestCommitted() throws IOException { } + @Override protected void onRequestComplete() throws IOException { } + @Override protected void onResponseComplete() throws IOException { if (debug != 0) _log.debug(debug + " complete"); } + @Override protected void onResponseContent(Buffer content) throws IOException { if (debug != 0) @@ -127,10 +134,13 @@ public class ProxyRule extends Rule content.writeTo(out); } + @Override protected void onResponseHeaderComplete() throws IOException { } + @SuppressWarnings("deprecation") + @Override protected void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException { if (debug != 0) @@ -142,6 +152,7 @@ public class ProxyRule extends Rule response.setStatus(status); } + @Override protected void onResponseHeader(Buffer name, Buffer value) throws IOException { String s = name.toString().toLowerCase(); @@ -156,6 +167,7 @@ public class ProxyRule extends Rule _log.debug(debug + " " + name + "! " + value); } + @Override protected void onConnectionFailed(Throwable ex) { _log.warn(ex.toString()); @@ -166,6 +178,7 @@ public class ProxyRule extends Rule } } + @Override protected void onException(Throwable ex) { if (ex instanceof EofException) @@ -181,6 +194,7 @@ public class ProxyRule extends Rule } } + @Override protected void onExpire() { if (!response.isCommitted()) @@ -191,7 +205,6 @@ public class ProxyRule extends Rule }; - exchange.setScheme(HttpSchemes.HTTPS.equals(request.getScheme())?HttpSchemes.HTTPS_BUFFER:HttpSchemes.HTTP_BUFFER); exchange.setMethod(request.getMethod()); exchange.setURL(url.toString()); exchange.setVersion(request.getProtocol()); @@ -199,6 +212,30 @@ public class ProxyRule extends Rule if (debug != 0) _log.debug(debug + " " + request.getMethod() + " " + url + " " + request.getProtocol()); + boolean hasContent = createHeaders(request,debug,exchange); + + if (hasContent) + exchange.setRequestContentSource(in); + + /* + * we need to set the timeout on the continuation to take into account the timeout of the HttpClient and the HttpExchange + */ + long ctimeout = (_client.getTimeout() > exchange.getTimeout())?_client.getTimeout():exchange.getTimeout(); + + _client.send(exchange); + try + { + exchange.waitForDone(); + } + catch (InterruptedException e) + { + _log.info(e); + } + return target; + } + + private boolean createHeaders(final HttpServletRequest request, final int debug, HttpExchange exchange) + { // check connection header String connectionHdr = request.getHeader("Connection"); if (connectionHdr != null) @@ -265,18 +302,11 @@ public class ProxyRule extends Rule exchange.addRequestHeader("X-Forwarded-Host",request.getServerName()); exchange.addRequestHeader("X-Forwarded-Server",request.getLocalName()); } - - if (hasContent) - exchange.setRequestContentSource(in); - - /* - * we need to set the timeout on the continuation to take into account the timeout of the HttpClient and the HttpExchange - */ - long ctimeout = (_client.getTimeout() > exchange.getTimeout())?_client.getTimeout():exchange.getTimeout(); - - _client.send(exchange); - - return target; + return hasContent; } + public void setProxyTo(String proxyTo) + { + this._proxyTo = proxyTo; + } } diff --git a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java index 9f021a5794f..8a9415853f4 100644 --- a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java +++ b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java @@ -12,40 +12,66 @@ // ======================================================================== package org.eclipse.jetty.rewrite.handler; +import static org.junit.Assert.assertEquals; + import java.io.IOException; -import java.net.URI; import java.net.URLEncoder; -import org.eclipse.jetty.client.Address; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.eclipse.jetty.client.ContentExchange; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpExchange; -import org.eclipse.jetty.http.HttpHeaders; import org.eclipse.jetty.http.HttpMethods; -import org.eclipse.jetty.toolchain.test.SimpleRequest; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.handler.AbstractHandler; +import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; - -public class ProxyRuleTest extends AbstractRuleTestCase +public class ProxyRuleTest { private ProxyRule _rule; private RewriteHandler _handler; + private Server _proxyServer = new Server(); + private Connector _proxyServerConnector = new SelectChannelConnector(); + private Server _targetServer = new Server(); + private Connector _targetServerConnector= new SelectChannelConnector(); + private HttpClient httpClient = new HttpClient(); @Before public void init() throws Exception { - start(false); - _rule = new ProxyRule(); - + _targetServer.addConnector(_targetServerConnector); + _targetServer.setHandler(new AbstractHandler() + { + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, + ServletException + { + baseRequest.setHandled(true); + response.setStatus(201); + } + }); + _targetServer.start(); + + _rule = new ProxyRule(); + _rule.setPattern("/foo/*"); + _rule.setProxyTo("http://localhost:" + _targetServerConnector.getLocalPort()); _handler = new RewriteHandler(); _handler.setRewriteRequestURI(true); + _handler.setRules(new Rule[] + { _rule }); - _handler.setRules(new Rule[] { _rule } ); + _proxyServer.addConnector(_proxyServerConnector); + _proxyServer.setHandler(_handler); + _proxyServer.start(); - _server.setHandler(_handler); + httpClient.start(); } @After @@ -57,21 +83,30 @@ public class ProxyRuleTest extends AbstractRuleTestCase @Test public void testProxy() throws Exception { -// HttpClient httpClient = new HttpClient(); -// httpClient.setProxy(new Address("localhost", proxyPort())); -// httpClient.start(); -// -// try -// { -// ContentExchange exchange = new ContentExchange(true); -// exchange.setMethod(HttpMethods.GET); -// String body = "BODY"; -// exchange.setURL("https://localhost:" + serverConnector.getLocalPort() + "/echo?body=" + URLEncoder.encode(body, "UTF-8")); -// -// httpClient.send(exchange); -// assertEquals(HttpExchange.STATUS_COMPLETED, exchange.waitForDone()); -// //_rule.matchAndApply(null, _request, _response); -// -// //assertEquals(location, _response.getHeader(HttpHeaders.LOCATION)); + + ContentExchange exchange = new ContentExchange(true); + exchange.setMethod(HttpMethods.GET); + String body = "BODY"; + String url = "http://localhost:" + _proxyServerConnector.getLocalPort() + "/foo?body=" + URLEncoder.encode(body,"UTF-8"); + exchange.setURL(url); + + httpClient.send(exchange); + assertEquals(HttpExchange.STATUS_COMPLETED,exchange.waitForDone()); + assertEquals(201,exchange.getResponseStatus()); + } + + @Test + public void testProxyNoMatch() throws Exception + { + + ContentExchange exchange = new ContentExchange(true); + exchange.setMethod(HttpMethods.GET); + String body = "BODY"; + String url = "http://localhost:" + _proxyServerConnector.getLocalPort() + "/foobar?body=" + URLEncoder.encode(body,"UTF-8"); + exchange.setURL(url); + + httpClient.send(exchange); + assertEquals(HttpExchange.STATUS_COMPLETED,exchange.waitForDone()); + assertEquals(404,exchange.getResponseStatus()); } } From 5e6a9ea78e5030d7dc29de2a1122065f02cb731c Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Mon, 26 Sep 2011 17:14:07 +0200 Subject: [PATCH 080/134] beautified code, added javadoc --- .../jetty/rewrite/handler/ProxyRule.java | 28 ++++--- .../jetty/rewrite/handler/RewriteHandler.java | 73 ++++++++++--------- .../jetty/rewrite/handler/ProxyRuleTest.java | 24 +++++- 3 files changed, 80 insertions(+), 45 deletions(-) diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java index ca2614f828d..a913ca67e68 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java @@ -15,6 +15,7 @@ import org.eclipse.jetty.client.HttpExchange; import org.eclipse.jetty.http.HttpHeaderValues; import org.eclipse.jetty.http.HttpHeaders; import org.eclipse.jetty.http.HttpURI; +import org.eclipse.jetty.http.PathMap; import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.server.Request; @@ -92,14 +93,7 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI final InputStream in = request.getInputStream(); final OutputStream out = response.getOutputStream(); - String uri = request.getRequestURI(); - if (request.getQueryString() != null) - uri += "?" + request.getQueryString(); - - HttpURI url = proxyHttpURI(uri); - - if (debug != 0) - _log.debug(debug + " proxy " + uri + "-->" + url); + HttpURI url = createUrl(request,debug); if (url == null) { @@ -221,6 +215,7 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI * we need to set the timeout on the continuation to take into account the timeout of the HttpClient and the HttpExchange */ long ctimeout = (_client.getTimeout() > exchange.getTimeout())?_client.getTimeout():exchange.getTimeout(); + exchange.setTimeout(ctimeout); _client.send(exchange); try @@ -229,11 +224,26 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI } catch (InterruptedException e) { - _log.info(e); + _log.info("Exception while waiting for response on proxied request", e); } return target; } + private HttpURI createUrl(HttpServletRequest request, final int debug) throws MalformedURLException + { + String uri = request.getRequestURI(); + if (request.getQueryString() != null) + uri += "?" + request.getQueryString(); + uri = PathMap.pathInfo(_pattern,uri); + if(uri==null) + uri = "/"; + HttpURI url = proxyHttpURI(uri); + + if (debug != 0) + _log.debug(debug + " proxy " + uri + "-->" + url); + return url; + } + private boolean createHeaders(final HttpServletRequest request, final int debug, HttpExchange exchange) { // check connection header diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java index 98b9d0631a2..e563abd72f4 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java @@ -5,11 +5,11 @@ // 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 +// 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. +// You may elect to redistribute this code under either of these licenses. // ======================================================================== package org.eclipse.jetty.rewrite.handler; @@ -19,25 +19,24 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.http.PathMap; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.HandlerWrapper; /* ------------------------------------------------------------ */ /** *

    Rewrite handler is responsible for managing the rules. Its capabilities - * is not only limited for URL rewrites such as RewritePatternRule or RewriteRegexRule. - * There is also handling for cookies, headers, redirection, setting status or error codes - * whenever the rule finds a match. - * - *

    The rules can be matched by the either: pattern matching of PathMap - * (eg {@link PatternRule}), regular expressions (eg {@link RegexRule}) or certain conditions set + * is not only limited for URL rewrites such as RewritePatternRule or RewriteRegexRule. + * There is also handling for cookies, headers, redirection, setting status or error codes + * whenever the rule finds a match. + * + *

    The rules can be matched by the either: pattern matching of PathMap + * (eg {@link PatternRule}), regular expressions (eg {@link RegexRule}) or certain conditions set * (eg {@link MsieSslRule} - the requests must be in SSL mode). - * - *

    The rules can be grouped into rule containers (class {@link RuleContainer}), and will only + * + *

    The rules can be grouped into rule containers (class {@link RuleContainer}), and will only * be applied if the request matches the conditions for their container * (e.g., by virtual host name) - * + * *

    The list of predefined rules is: *

      *
    • {@link CookiePatternRule} - adds a new cookie in response.
    • @@ -46,28 +45,36 @@ import org.eclipse.jetty.server.handler.HandlerWrapper; *
    • {@link ResponsePatternRule} - sets the status/error codes.
    • *
    • {@link RewritePatternRule} - rewrites the requested URI.
    • *
    • {@link RewriteRegexRule} - rewrites the requested URI using regular expression for pattern matching.
    • + *
    • {@link ProxyRule} - proxies the requested URI to the host defined in proxyTo.
    • *
    • {@link MsieSslRule} - disables the keep alive on SSL for IE5 and IE6.
    • *
    • {@link LegacyRule} - the old version of rewrite.
    • *
    • {@link ForwardedSchemeHeaderRule} - set the scheme according to the headers present.
    • *
    • {@link VirtualHostRuleContainer} - checks whether the request matches one of a set of virtual host names.
    • *
    * - * + * * Here is a typical jetty.xml configuration would be:
    - * 
    + *
      *   <Set name="handler">
      *     <New id="Handlers" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
      *       <Set name="rules">
      *         <Array type="org.eclipse.jetty.rewrite.handler.Rule">
      *
    - *           <Item> 
    + *           <Item>
      *             <New id="rewrite" class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
      *               <Set name="pattern">/*</Set>
      *               <Set name="replacement">/test</Set>
      *             </New>
      *           </Item>
      *
    - *           <Item> 
    + *           <Item>
    + *             <New id="rewrite" class="org.eclipse.jetty.rewrite.handler.ProxyRule">
    + *               <Set name="pattern">/*</Set>
    + *               <Set name="proxyTo">http://webtide.com:8080</Set>
    + *             </New>
    + *           </Item>
    + *
    + *           <Item>
      *             <New id="response" class="org.eclipse.jetty.rewrite.handler.ResponsePatternRule">
      *               <Set name="pattern">/session/</Set>
      *               <Set name="code">400</Set>
    @@ -75,7 +82,7 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
      *             </New>
      *           </Item>
      *
    - *           <Item> 
    + *           <Item>
      *             <New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
      *               <Set name="pattern">*.jsp</Set>
      *               <Set name="name">server</Set>
    @@ -83,7 +90,7 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
      *             </New>
      *           </Item>
      *
    - *           <Item> 
    + *           <Item>
      *             <New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
      *               <Set name="pattern">*.jsp</Set>
      *               <Set name="name">title</Set>
    @@ -91,28 +98,28 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
      *             </New>
      *           </Item>
      *
    - *           <Item> 
    + *           <Item>
      *             <New id="redirect" class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
      *               <Set name="pattern">/test/dispatch</Set>
      *               <Set name="location">http://jetty.eclipse.org</Set>
      *             </New>
      *           </Item>
      *
    - *           <Item> 
    + *           <Item>
      *             <New id="regexRewrite" class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
      *               <Set name="regex">/test-jaas/$</Set>
      *               <Set name="replacement">/demo</Set>
      *             </New>
      *           </Item>
    - *           
    - *           <Item> 
    + *
    + *           <Item>
      *             <New id="forwardedHttps" class="org.eclipse.jetty.rewrite.handler.ForwardedSchemeHeaderRule">
      *               <Set name="header">X-Forwarded-Scheme</Set>
      *               <Set name="headerValue">https</Set>
      *               <Set name="scheme">https</Set>
      *             </New>
      *           </Item>
    - *           
    + *
      *           <Item>
      *             <New id="virtualHost" class="org.eclipse.jetty.rewrite.handler.VirtualHostRuleContainer">
      *
    @@ -134,10 +141,10 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
      *                   </New>
      *                 </Arg>
      *               </Call>
    - *    
    + *
      *             </New>
      *           </      Item>
    - * 
    + *
      *         </Array>
      *       </Set>
      *
    @@ -162,13 +169,13 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
      *     </New>
      *   </Set>
      * 
    - * + * */ public class RewriteHandler extends HandlerWrapper { - + private RuleContainer _rules; - + /* ------------------------------------------------------------ */ public RewriteHandler() { @@ -179,7 +186,7 @@ public class RewriteHandler extends HandlerWrapper /** * To enable configuration from jetty.xml on rewriteRequestURI, rewritePathInfo and * originalPathAttribute - * + * * @param legacyRule old style rewrite rule */ @Deprecated @@ -201,7 +208,7 @@ public class RewriteHandler extends HandlerWrapper /* ------------------------------------------------------------ */ /** * Assigns the rules to process. - * @param rules an array of {@link Rule}. + * @param rules an array of {@link Rule}. */ public void setRules(Rule[] rules) { @@ -297,13 +304,13 @@ public class RewriteHandler extends HandlerWrapper public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (isStarted()) - { + { String returned = _rules.matchAndApply(target, request, response); target = (returned == null) ? target : returned; - + if (!baseRequest.isHandled()) super.handle(target, baseRequest, request, response); } } - + } diff --git a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java index 8a9415853f4..65a0b4d0377 100644 --- a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java +++ b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java @@ -41,7 +41,7 @@ public class ProxyRuleTest private Server _proxyServer = new Server(); private Connector _proxyServerConnector = new SelectChannelConnector(); private Server _targetServer = new Server(); - private Connector _targetServerConnector= new SelectChannelConnector(); + private Connector _targetServerConnector = new SelectChannelConnector(); private HttpClient httpClient = new HttpClient(); @Before @@ -51,9 +51,11 @@ public class ProxyRuleTest _targetServer.setHandler(new AbstractHandler() { public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, - ServletException + ServletException { baseRequest.setHandled(true); + String responseString = "uri: " + request.getRequestURI() + " some content"; + response.getOutputStream().write(responseString.getBytes()); response.setStatus(201); } }); @@ -92,13 +94,29 @@ public class ProxyRuleTest httpClient.send(exchange); assertEquals(HttpExchange.STATUS_COMPLETED,exchange.waitForDone()); + assertEquals("uri: / some content",exchange.getResponseContent()); + assertEquals(201,exchange.getResponseStatus()); + } + + @Test + public void testProxyWithDeeperPath() throws Exception + { + + ContentExchange exchange = new ContentExchange(true); + exchange.setMethod(HttpMethods.GET); + String body = "BODY"; + String url = "http://localhost:" + _proxyServerConnector.getLocalPort() + "/foo/bar/foobar?body=" + URLEncoder.encode(body,"UTF-8"); + exchange.setURL(url); + + httpClient.send(exchange); + assertEquals(HttpExchange.STATUS_COMPLETED,exchange.waitForDone()); + assertEquals("uri: /bar/foobar some content",exchange.getResponseContent()); assertEquals(201,exchange.getResponseStatus()); } @Test public void testProxyNoMatch() throws Exception { - ContentExchange exchange = new ContentExchange(true); exchange.setMethod(HttpMethods.GET); String body = "BODY"; From e14cc536ee9021a622a163cd5fbb17b6e48d292f Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Mon, 26 Sep 2011 17:48:52 +0200 Subject: [PATCH 081/134] JETTY-1415: Start/Stop Server and Client only once in test, code format --- .../jetty/rewrite/handler/ProxyRule.java | 14 +++---- .../jetty/rewrite/handler/ProxyRuleTest.java | 37 ++++++++++--------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java index a913ca67e68..65efebc72a3 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java @@ -18,12 +18,11 @@ import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.PathMap; import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.EofException; -import org.eclipse.jetty.server.Request; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.QueuedThreadPool; -public class ProxyRule extends PatternRule implements Rule.ApplyURI +public class ProxyRule extends PatternRule { private static final Logger _log = Log.getLogger(ProxyRule.class); @@ -44,6 +43,7 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI _DontProxyHeaders.add("upgrade"); } + /* ------------------------------------------------------------ */ public ProxyRule() { _handling = true; @@ -51,6 +51,7 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI } + /* ------------------------------------------------------------ */ private void initializeClient() throws Exception { _client = new HttpClient(); @@ -65,11 +66,7 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI return new HttpURI(_proxyTo + uri); } - public void applyURI(Request request, String oldTarget, String newTarget) throws IOException - { - System.out.println("applyURI called"); - } - + /* ------------------------------------------------------------ */ @Override protected String apply(String target, HttpServletRequest request, final HttpServletResponse response) throws IOException { @@ -229,6 +226,7 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI return target; } + /* ------------------------------------------------------------ */ private HttpURI createUrl(HttpServletRequest request, final int debug) throws MalformedURLException { String uri = request.getRequestURI(); @@ -244,6 +242,7 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI return url; } + /* ------------------------------------------------------------ */ private boolean createHeaders(final HttpServletRequest request, final int debug, HttpExchange exchange) { // check connection header @@ -315,6 +314,7 @@ public class ProxyRule extends PatternRule implements Rule.ApplyURI return hasContent; } + /* ------------------------------------------------------------ */ public void setProxyTo(String proxyTo) { this._proxyTo = proxyTo; diff --git a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java index 65a0b4d0377..d4c90bee069 100644 --- a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java +++ b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java @@ -30,22 +30,22 @@ import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.nio.SelectChannelConnector; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; public class ProxyRuleTest { - private ProxyRule _rule; - private RewriteHandler _handler; - private Server _proxyServer = new Server(); - private Connector _proxyServerConnector = new SelectChannelConnector(); - private Server _targetServer = new Server(); - private Connector _targetServerConnector = new SelectChannelConnector(); - private HttpClient httpClient = new HttpClient(); + private static ProxyRule _rule; + private static RewriteHandler _handler; + private static Server _proxyServer = new Server(); + private static Connector _proxyServerConnector = new SelectChannelConnector(); + private static Server _targetServer = new Server(); + private static Connector _targetServerConnector = new SelectChannelConnector(); + private static HttpClient _httpClient = new HttpClient(); - @Before - public void init() throws Exception + @BeforeClass + public static void setupOnce() throws Exception { _targetServer.addConnector(_targetServerConnector); _targetServer.setHandler(new AbstractHandler() @@ -73,12 +73,15 @@ public class ProxyRuleTest _proxyServer.setHandler(_handler); _proxyServer.start(); - httpClient.start(); + _httpClient.start(); } - @After - public void destroy() + @AfterClass + public static void destroy() throws Exception { + _httpClient.stop(); + _proxyServer.stop(); + _targetServer.stop(); _rule = null; } @@ -92,7 +95,7 @@ public class ProxyRuleTest String url = "http://localhost:" + _proxyServerConnector.getLocalPort() + "/foo?body=" + URLEncoder.encode(body,"UTF-8"); exchange.setURL(url); - httpClient.send(exchange); + _httpClient.send(exchange); assertEquals(HttpExchange.STATUS_COMPLETED,exchange.waitForDone()); assertEquals("uri: / some content",exchange.getResponseContent()); assertEquals(201,exchange.getResponseStatus()); @@ -108,7 +111,7 @@ public class ProxyRuleTest String url = "http://localhost:" + _proxyServerConnector.getLocalPort() + "/foo/bar/foobar?body=" + URLEncoder.encode(body,"UTF-8"); exchange.setURL(url); - httpClient.send(exchange); + _httpClient.send(exchange); assertEquals(HttpExchange.STATUS_COMPLETED,exchange.waitForDone()); assertEquals("uri: /bar/foobar some content",exchange.getResponseContent()); assertEquals(201,exchange.getResponseStatus()); @@ -123,7 +126,7 @@ public class ProxyRuleTest String url = "http://localhost:" + _proxyServerConnector.getLocalPort() + "/foobar?body=" + URLEncoder.encode(body,"UTF-8"); exchange.setURL(url); - httpClient.send(exchange); + _httpClient.send(exchange); assertEquals(HttpExchange.STATUS_COMPLETED,exchange.waitForDone()); assertEquals(404,exchange.getResponseStatus()); } From bee0a6e7774979b3a3bd82e64d27c49551675885 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Mon, 26 Sep 2011 17:22:08 -0500 Subject: [PATCH 082/134] [Bug 358925] adjust some code and add license block --- .../jetty/rewrite/handler/ProxyRule.java | 40 +++++++++++++++++-- .../jetty/rewrite/handler/ProxyRuleTest.java | 31 +++++++------- 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java index 65efebc72a3..1eef5bc4470 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java @@ -1,5 +1,18 @@ package org.eclipse.jetty.rewrite.handler; +//======================================================================== +//Copyright (c) 2006-2009 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. +//======================================================================== + import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -48,7 +61,6 @@ public class ProxyRule extends PatternRule { _handling = true; _terminating = true; - } /* ------------------------------------------------------------ */ @@ -201,20 +213,25 @@ public class ProxyRule extends PatternRule exchange.setVersion(request.getProtocol()); if (debug != 0) + { _log.debug(debug + " " + request.getMethod() + " " + url + " " + request.getProtocol()); - + } + boolean hasContent = createHeaders(request,debug,exchange); if (hasContent) + { exchange.setRequestContentSource(in); - + } + /* - * we need to set the timeout on the continuation to take into account the timeout of the HttpClient and the HttpExchange + * we need to set the timeout on the exchange to take into account the timeout of the HttpClient and the HttpExchange */ long ctimeout = (_client.getTimeout() > exchange.getTimeout())?_client.getTimeout():exchange.getTimeout(); exchange.setTimeout(ctimeout); _client.send(exchange); + try { exchange.waitForDone(); @@ -230,15 +247,26 @@ public class ProxyRule extends PatternRule private HttpURI createUrl(HttpServletRequest request, final int debug) throws MalformedURLException { String uri = request.getRequestURI(); + if (request.getQueryString() != null) + { uri += "?" + request.getQueryString(); + } + uri = PathMap.pathInfo(_pattern,uri); + if(uri==null) + { uri = "/"; + } + HttpURI url = proxyHttpURI(uri); if (debug != 0) + { _log.debug(debug + " proxy " + uri + "-->" + url); + } + return url; } @@ -251,12 +279,16 @@ public class ProxyRule extends PatternRule { connectionHdr = connectionHdr.toLowerCase(); if (connectionHdr.indexOf("keep-alive") < 0 && connectionHdr.indexOf("close") < 0) + { connectionHdr = null; + } } // force host if (_hostHeader != null) + { exchange.setRequestHeader("Host",_hostHeader); + } // copy headers boolean xForwardedFor = false; diff --git a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java index d4c90bee069..9cb9def596a 100644 --- a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java +++ b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/ProxyRuleTest.java @@ -1,17 +1,18 @@ -// ======================================================================== -// Copyright (c) 2006-2009 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.rewrite.handler; +//======================================================================== +//Copyright (c) 2006-2009 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. +//======================================================================== + import static org.junit.Assert.assertEquals; import java.io.IOException; @@ -50,8 +51,7 @@ public class ProxyRuleTest _targetServer.addConnector(_targetServerConnector); _targetServer.setHandler(new AbstractHandler() { - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, - ServletException + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { baseRequest.setHandled(true); String responseString = "uri: " + request.getRequestURI() + " some content"; @@ -66,8 +66,7 @@ public class ProxyRuleTest _rule.setProxyTo("http://localhost:" + _targetServerConnector.getLocalPort()); _handler = new RewriteHandler(); _handler.setRewriteRequestURI(true); - _handler.setRules(new Rule[] - { _rule }); + _handler.setRules(new Rule[] { _rule }); _proxyServer.addConnector(_proxyServerConnector); _proxyServer.setHandler(_handler); From 7bc092bf8bcece75d8ec1c1bfef0c4032dc53898 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Mon, 26 Sep 2011 17:47:03 -0500 Subject: [PATCH 083/134] [Bug 358925] add common jetty-client proxy configuration setttings --- .../jetty/rewrite/handler/ProxyRule.java | 129 +++++++++++++++++- 1 file changed, 127 insertions(+), 2 deletions(-) diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java index 1eef5bc4470..be6d8ad0f5e 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java @@ -35,6 +35,10 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.QueuedThreadPool; +/** + * This rule allows the user to configure a particular rewrite rule that will proxy out + * to a configured location. This rule uses the jetty http client. + */ public class ProxyRule extends PatternRule { private static final Logger _log = Log.getLogger(ProxyRule.class); @@ -42,6 +46,16 @@ public class ProxyRule extends PatternRule private HttpClient _client; private String _hostHeader; private String _proxyTo; + + private int _connectorType = 2; + private String _maxThreads; + private String _maxConnections; + private String _timeout; + private String _idleTimeout; + private String _requestHeaderSize; + private String _requestBufferSize; + private String _responseHeaderSize; + private String _responseBufferSize; private HashSet _DontProxyHeaders = new HashSet(); { @@ -67,8 +81,52 @@ public class ProxyRule extends PatternRule private void initializeClient() throws Exception { _client = new HttpClient(); - _client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); - _client.setThreadPool(new QueuedThreadPool()); + _client.setConnectorType(_connectorType); + + if ( _maxThreads != null ) + { + _client.setThreadPool(new QueuedThreadPool(Integer.parseInt(_maxThreads))); + } + else + { + _client.setThreadPool(new QueuedThreadPool()); + } + + if ( _maxConnections != null ) + { + _client.setMaxConnectionsPerAddress(Integer.parseInt(_maxConnections)); + } + + if ( _timeout != null ) + { + _client.setTimeout(Long.parseLong(_timeout)); + } + + if ( _idleTimeout != null ) + { + _client.setIdleTimeout(Long.parseLong(_idleTimeout)); + } + + if ( _requestBufferSize != null ) + { + _client.setRequestBufferSize(Integer.parseInt(_requestBufferSize)); + } + + if ( _requestHeaderSize != null ) + { + _client.setRequestHeaderSize(Integer.parseInt(_requestHeaderSize)); + } + + if ( _responseBufferSize != null ) + { + _client.setResponseBufferSize(Integer.parseInt(_responseBufferSize)); + } + + if ( _responseHeaderSize != null ) + { + _client.setResponseHeaderSize(Integer.parseInt(_responseHeaderSize)); + } + _client.start(); } @@ -351,4 +409,71 @@ public class ProxyRule extends PatternRule { this._proxyTo = proxyTo; } + + /* ------------------------------------------------------------ */ + public void setMaxThreads(String maxThreads) + { + this._maxThreads = maxThreads; + } + + /* ------------------------------------------------------------ */ + public void setMaxConnections(String maxConnections) + { + _maxConnections = maxConnections; + } + + /* ------------------------------------------------------------ */ + public void setTimeout(String timeout) + { + _timeout = timeout; + } + + /* ------------------------------------------------------------ */ + public void setIdleTimeout(String idleTimeout) + { + _idleTimeout = idleTimeout; + } + + /* ------------------------------------------------------------ */ + public void setRequestHeaderSize(String requestHeaderSize) + { + _requestHeaderSize = requestHeaderSize; + } + + /* ------------------------------------------------------------ */ + public void setRequestBufferSize(String requestBufferSize) + { + _requestBufferSize = requestBufferSize; + } + + /* ------------------------------------------------------------ */ + public void setResponseHeaderSize(String responseHeaderSize) + { + _responseHeaderSize = responseHeaderSize; + } + + /* ------------------------------------------------------------ */ + public void setResponseBufferSize(String responseBufferSize) + { + _responseBufferSize = responseBufferSize; + } + + /* ------------------------------------------------------------ */ + public void addDontProxyHeaders(String dontProxyHeader) + { + _DontProxyHeaders.add(dontProxyHeader); + } + + /* ------------------------------------------------------------ */ + /** + * CONNECTOR_SOCKET = 0; + * CONNECTOR_SELECT_CHANNEL = 2; (default) + * + * @param connectorType + */ + public void setConnectorType( int connectorType ) + { + _connectorType = connectorType; + } + } From ba0ee9f216df2341f18d5c801f6069b48e1dbcb3 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Mon, 26 Sep 2011 17:50:12 -0500 Subject: [PATCH 084/134] [Bug 358925] bit more javadoc on usage --- .../java/org/eclipse/jetty/rewrite/handler/ProxyRule.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java index be6d8ad0f5e..99c6877e52b 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/ProxyRule.java @@ -38,6 +38,14 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool; /** * This rule allows the user to configure a particular rewrite rule that will proxy out * to a configured location. This rule uses the jetty http client. + * + * Rule rule = new ProxyRule(); + * rule.setPattern("/foo/*"); + * rule.setProxyTo("http://url.com"); + * + * see api for other configuration options which influence the configuration of the jetty + * client instance + * */ public class ProxyRule extends PatternRule { From b28a53ad52dcab0a388b9f1f48482e65d557427f Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 27 Sep 2011 11:13:20 +1000 Subject: [PATCH 085/134] 357240 safer SSL close --- .../io/nio/SslSelectChannelEndPoint.java | 160 ++++++++++++++++-- 1 file changed, 148 insertions(+), 12 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index c80bbceb9e3..09ee4353f41 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -206,6 +206,141 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } } + private int process() throws IOException + { + ByteBuffer bbuf = null; // TODO ??? + + int wraps=0; + + HandshakeStatus initialStatus = _engine.getHandshakeStatus(); + loop: while (true) + { + // If we have encrypted data in output buffer + if (isBufferingOutput()) + { + // we must flush it, as the other end might be + // waiting for that outgoing data before sending + // more incoming data + flush(); + + // If we were unable to flush all the data, then + // we should break the loop and wait for the call + // back to handle when the SelectSet detects that + // the channel is writable again. + if (isBufferingOutput()) + { + scheduleWrite(); + break loop; + } + } + + // handle the current hand share status + switch(_engine.getHandshakeStatus()) + { + case FINISHED: + case NOT_HANDSHAKING: + // If we are closing, then unwrap must have CLOSED result, + // so return -1 to signal upwards + if (_closing) + return -1; + + // otherwise we break loop with the data we have unwrapped. + break loop; + + case NEED_UNWRAP: + checkRenegotiate(); + // Need more data to be unwrapped so try another call to unwrap + if (!unwrap(bbuf) && _engine.getHandshakeStatus()==HandshakeStatus.NEED_UNWRAP) + { + // If the unwrap call did not make any progress and we are still in + // NEED_UNWRAP, then we should break the loop and wait for more data to + // arrive. + break loop; + } + // progress was made so continue the loop. + break; + + case NEED_TASK: + { + // A task needs to be run, so run it! + + Runnable task; + while ((task=_engine.getDelegatedTask())!=null) + { + task.run(); + } + + // Detect SUN JVM Bug!!! + if(initialStatus==HandshakeStatus.NOT_HANDSHAKING && + _engine.getHandshakeStatus()==HandshakeStatus.NEED_UNWRAP && wraps==0) + { + // This should be NEED_WRAP + // The fix simply detects the signature of the bug and then close the connection (fail-fast) so that ff3 will delegate to using SSL instead of TLS. + // This is a jvm bug on java1.6 where the SSLEngine expects more data from the initial handshake when the client(ff3-tls) already had given it. + // See http://jira.codehaus.org/browse/JETTY-567 for more details + if (_debug) __log.warn(_session+" JETTY-567"); + return -1; + } + break; + } + + case NEED_WRAP: + { + checkRenegotiate(); + // The SSL needs to send some handshake data to the other side, + // so let fill become a flush for a little bit. + wraps++; + needOutBuffer(); + ByteBuffer out_buffer=_outNIOBuffer.getByteBuffer(); + synchronized(out_buffer) + { + try + { + // call wrap with empty application buffers, so it can + // generate required handshake messages into _outNIOBuffer + _outNIOBuffer.compact(); + int put=_outNIOBuffer.putIndex(); + out_buffer.position(); + _result=null; + _result=_engine.wrap(__NO_BUFFERS,out_buffer); + if (_debug) __log.debug(_session+" fill wrap "+_result); + switch(_result.getStatus()) + { + case BUFFER_OVERFLOW: + case BUFFER_UNDERFLOW: + LOG.warn("wrap {}",_result); + _closing=true; + break; + case CLOSED: + _closing=true; + break; + } + _outNIOBuffer.setPutIndex(put+_result.bytesProduced()); + } + catch(SSLException e) + { + super.close(); + throw e; + } + finally + { + out_buffer.position(0); + } + } + + // flush the encrypted outNIOBuffer + flush(); + freeOutBuffer(); + + break; + } + } + } + + return -1; // TODO + } + + /* ------------------------------------------------------------ */ protected void sslClose() throws IOException { @@ -650,24 +785,25 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint /* ------------------------------------------------------------ */ @Override public void flush() throws IOException - { - if (_outNIOBuffer==null) - return; - - int len=_outNIOBuffer.length(); + { if (isBufferingOutput()) { int flushed=super.flush(_outNIOBuffer); - if (_debug) __log.debug(_session+" Flushed "+flushed+"/"+len); - if (isBufferingOutput()) + if (_debug) + __log.debug(_session+" Flushed "+flushed+" left="+_outNIOBuffer.length()); + } + else if (_closing) + { + if (_engine.isOutboundDone()) { - // Try again after yield.... cheaper than a reschedule. - Thread.yield(); - flushed=super.flush(_outNIOBuffer); - if (_debug) __log.debug(_session+" flushed "+flushed+"/"+len); + if (_debug) + __log.debug(_session+" close"); + super.close(); } - else if (_closing && !_engine.isOutboundDone()) + else { + if (_debug) + __log.debug(_session+" closeOutbound"); _engine.closeOutbound(); } } From 90af3cc35974538df01684a2af928bcb25190cc2 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Mon, 26 Sep 2011 20:57:58 -0500 Subject: [PATCH 086/134] update jetty-version-maven-plugin version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9bbf848c240..92439b310e3 100644 --- a/pom.xml +++ b/pom.xml @@ -185,7 +185,7 @@ org.eclipse.jetty.toolchain jetty-version-maven-plugin - 1.0.3 + 1.0.6 org.apache.maven.plugins From 20cce2069d7d0587e4c49eaa6c2e15b8d77402c0 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Tue, 27 Sep 2011 12:37:38 +1000 Subject: [PATCH 087/134] 358784 JSP broken on Java 1.5 --- jetty-aggregate/jetty-all-server/pom.xml | 2 +- jetty-aggregate/jetty-all/pom.xml | 2 +- jetty-aggregate/jetty-webapp/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jetty-aggregate/jetty-all-server/pom.xml b/jetty-aggregate/jetty-all-server/pom.xml index ec94c3d2af1..91b0e1aa518 100644 --- a/jetty-aggregate/jetty-all-server/pom.xml +++ b/jetty-aggregate/jetty-all-server/pom.xml @@ -24,7 +24,7 @@ unpack-dependencies - META-INF/**,org/eclipse/** + META-INF/**,org/eclipse/**,org/apache/jasper/compiler/** **/MANIFEST.MF,javax/** ${project.build.directory}/classes false diff --git a/jetty-aggregate/jetty-all/pom.xml b/jetty-aggregate/jetty-all/pom.xml index 0e9d64808aa..e3a68e71201 100644 --- a/jetty-aggregate/jetty-all/pom.xml +++ b/jetty-aggregate/jetty-all/pom.xml @@ -20,7 +20,7 @@ unpack-dependencies - META-INF/**,org/eclipse/** + META-INF/**,org/eclipse/**,org/apache/jasper/compiler/* **/MANIFEST.MF,javax/** ${project.build.directory}/classes false diff --git a/jetty-aggregate/jetty-webapp/pom.xml b/jetty-aggregate/jetty-webapp/pom.xml index 9db6c5896fa..df20cc17244 100644 --- a/jetty-aggregate/jetty-webapp/pom.xml +++ b/jetty-aggregate/jetty-webapp/pom.xml @@ -21,7 +21,7 @@ unpack-dependencies - META-INF/**,org/eclipse/** + META-INF/**,org/eclipse/**,org/apache/jasper/compiler/** **/MANIFEST.MF,javax/** ${project.build.directory}/classes false From 44923230e37ec875b6164a9613f99830065b389d Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 27 Sep 2011 16:57:17 +1000 Subject: [PATCH 088/134] 357240 safer SSL close --- .../eclipse/jetty/io/nio/SelectorManager.java | 3 +- .../io/nio/SslSelectChannelEndPoint.java | 630 ++++-------------- .../jetty/server/AsyncHttpConnection.java | 3 +- .../jetty/server/HttpServerTestBase.java | 9 +- .../jetty/server/ssl/SSLCloseTest.java | 181 +++++ .../ssl/SslSelectChannelServerTest.java | 16 + 6 files changed, 351 insertions(+), 491 deletions(-) create mode 100644 jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index dfb8141d61c..092775a37a6 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -512,7 +512,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa try { - ch.close(); + if (ch!=null) + ch.close(); } catch(IOException e2) { diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 09ee4353f41..380310851cd 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -41,16 +41,16 @@ import org.eclipse.jetty.util.log.Logger; */ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { - private static final Logger LOG = Log.getLogger(SslSelectChannelEndPoint.class); - - public static final Logger __log=Log.getLogger("org.eclipse.jetty.io.nio").getLogger("ssl"); + public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio").getLogger("ssl"); - private static final ByteBuffer[] __NO_BUFFERS={}; + private static final Buffer __EMPTY_BUFFER=new DirectNIOBuffer(0); + private static final ByteBuffer __ZERO_BUFFER=ByteBuffer.allocate(0); private final Buffers _buffers; private final SSLEngine _engine; private final SSLSession _session; + private int _inCount; private volatile NIOBuffer _inNIOBuffer; private volatile NIOBuffer _outNIOBuffer; @@ -62,7 +62,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint private boolean _handshook=false; private boolean _allowRenegotiate=false; - private final boolean _debug = __log.isDebugEnabled(); // snapshot debug status for optimizer + private final boolean _debug = LOG.isDebugEnabled(); // snapshot debug status for optimizer /* ------------------------------------------------------------ */ public SslSelectChannelEndPoint(Buffers buffers,SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key, SSLEngine engine, int maxIdleTime) @@ -75,7 +75,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint _engine=engine; _session=engine.getSession(); - if (_debug) __log.debug(_session+" channel="+channel); + if (_debug) LOG.debug(_session+" channel="+channel); } /* ------------------------------------------------------------ */ @@ -89,7 +89,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint _engine=engine; _session=engine.getSession(); - if (_debug) __log.debug(_session+" channel="+channel); + if (_debug) LOG.debug(_session+" channel="+channel); } int _outCount; @@ -119,7 +119,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } } - int _inCount; /* ------------------------------------------------------------ */ private void needInBuffer() { @@ -196,9 +195,12 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint @Override public void shutdownOutput() throws IOException { + LOG.debug("{} shutdownOutput",_session); try { - sslClose(); + // All SSL closes should be graceful, as it is more secure. + // So normal SSL close can be used here. + close(); } finally { @@ -206,79 +208,111 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } } - private int process() throws IOException + /* ------------------------------------------------------------ */ + private int process(ByteBuffer inbuf, Buffer header, Buffer buffer) throws IOException { - ByteBuffer bbuf = null; // TODO ??? + if (_debug) + LOG.debug("process {} {} {}",inbuf!=null,header!=null,buffer!=null); + + // If there is no place to put incoming application data, + if (inbuf==null) + { + // use ZERO buffer + inbuf=__ZERO_BUFFER; + } + + int received=0; + int sent=0; - int wraps=0; HandshakeStatus initialStatus = _engine.getHandshakeStatus(); - loop: while (true) + boolean progress=true; + + while (progress) { - // If we have encrypted data in output buffer - if (isBufferingOutput()) + progress=false; + + // flush output data { + int len=_outNIOBuffer==null?0:_outNIOBuffer.length(); + // we must flush it, as the other end might be // waiting for that outgoing data before sending // more incoming data flush(); - // If we were unable to flush all the data, then - // we should break the loop and wait for the call - // back to handle when the SelectSet detects that - // the channel is writable again. - if (isBufferingOutput()) - { - scheduleWrite(); - break loop; - } + // If we have written some bytes, then progress has been made. + progress|=(_outNIOBuffer==null?0:_outNIOBuffer.length())0||_result.bytesConsumed()>0; + } + else if (buffer!=null && buffer.hasContent()) + { + c=wrap(buffer); + progress=_result.bytesProduced()>0||_result.bytesConsumed()>0; + } + + if (c>0) + sent+=c; + else if (c<0 && sent==0) + sent=-1; + } + + // Try unwrapping some application data + if (inbuf.remaining()>0 && _inNIOBuffer!=null && _inNIOBuffer.hasContent()) + { + int space=inbuf.remaining(); + progress|=unwrap(inbuf); + received+=space-inbuf.remaining(); } - // progress was made so continue the loop. break; + case NEED_TASK: { // A task needs to be run, so run it! - Runnable task; while ((task=_engine.getDelegatedTask())!=null) { + progress=true; task.run(); } // Detect SUN JVM Bug!!! if(initialStatus==HandshakeStatus.NOT_HANDSHAKING && - _engine.getHandshakeStatus()==HandshakeStatus.NEED_UNWRAP && wraps==0) + _engine.getHandshakeStatus()==HandshakeStatus.NEED_UNWRAP && sent==0) { // This should be NEED_WRAP // The fix simply detects the signature of the bug and then close the connection (fail-fast) so that ff3 will delegate to using SSL instead of TLS. // This is a jvm bug on java1.6 where the SSLEngine expects more data from the initial handshake when the client(ff3-tls) already had given it. // See http://jira.codehaus.org/browse/JETTY-567 for more details - if (_debug) __log.warn(_session+" JETTY-567"); + if (_debug) LOG.warn(_session+" JETTY-567"); return -1; } break; @@ -287,187 +321,64 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint case NEED_WRAP: { checkRenegotiate(); - // The SSL needs to send some handshake data to the other side, - // so let fill become a flush for a little bit. - wraps++; - needOutBuffer(); - ByteBuffer out_buffer=_outNIOBuffer.getByteBuffer(); - synchronized(out_buffer) + + // The SSL needs to send some handshake data to the other side + int c=0; + if (header!=null && header.hasContent()) { - try - { - // call wrap with empty application buffers, so it can - // generate required handshake messages into _outNIOBuffer - _outNIOBuffer.compact(); - int put=_outNIOBuffer.putIndex(); - out_buffer.position(); - _result=null; - _result=_engine.wrap(__NO_BUFFERS,out_buffer); - if (_debug) __log.debug(_session+" fill wrap "+_result); - switch(_result.getStatus()) - { - case BUFFER_OVERFLOW: - case BUFFER_UNDERFLOW: - LOG.warn("wrap {}",_result); - _closing=true; - break; - case CLOSED: - _closing=true; - break; - } - _outNIOBuffer.setPutIndex(put+_result.bytesProduced()); - } - catch(SSLException e) - { - super.close(); - throw e; - } - finally - { - out_buffer.position(0); - } + if (buffer!=null && buffer.hasContent()) + c=wrap(header,buffer); + else + c=wrap(header); } + else if (buffer!=null && buffer.hasContent()) + c=wrap(buffer); + else + c=wrap(__EMPTY_BUFFER); - // flush the encrypted outNIOBuffer - flush(); - freeOutBuffer(); + progress=_result.bytesProduced()>0||_result.bytesConsumed()>0; + if (c>0) + sent+=c; + else if (c<0 && sent==0) + sent=-1; + + break; + } + + case NEED_UNWRAP: + { + checkRenegotiate(); + + // Need more data to be unwrapped so try another call to unwrap + progress|=unwrap(inbuf); + if (_closing) + inbuf.clear(); + break; } } + + if (_debug) LOG.debug("{} progress {}",_session,progress); } - - return -1; // TODO + + if (_debug) LOG.debug("{} received {} sent {}",_session,received,sent); + return (received<0||sent<0)?-1:(received+sent); } - /* ------------------------------------------------------------ */ - protected void sslClose() throws IOException - { - if (_closing) - return; - _closing=true; - - // TODO - this really should not be done in a loop here - but with async callbacks. - long end=System.currentTimeMillis()+getMaxIdleTime(); - try - { - while (isOpen() && isBufferingOutput()&& System.currentTimeMillis()0) - flush(); - _outNIOBuffer.compact(); - int put=_outNIOBuffer.putIndex(); - out_buffer.position(put); - _result=null; - _result=_engine.wrap(__NO_BUFFERS,out_buffer); - if (_debug) __log.debug(_session+" close wrap "+_result); - _outNIOBuffer.setPutIndex(put+_result.bytesProduced()); - } - catch(SSLException e) - { - super.close(); - throw e; - } - finally - { - out_buffer.position(0); - freeOutBuffer(); - } - - break; - } - } - } - } - catch (ThreadDeath x) - { - super.close(); - throw x; - } - catch (Throwable x) - { - LOG.debug(x); - super.close(); - } - } /* ------------------------------------------------------------ */ @Override public void close() throws IOException { - try - { - sslClose(); - } - finally - { - super.close(); - } + if (_closing) + return; + LOG.debug("{} close",_session); + _closing=true; + + // Processing will call flush(), which will handle the closing state with a closeOutbound then shutdownOutput + process(null,null,null); } /* ------------------------------------------------------------ */ @@ -478,18 +389,20 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint @Override public int fill(Buffer buffer) throws IOException { + LOG.debug("{} fill",_session); // This end point only works on NIO buffer type (director // or indirect), so extract the NIO buffer that is wrapped // by the passed jetty Buffer. - final ByteBuffer bbuf=extractInputBuffer(buffer); + ByteBuffer bbuf=((NIOBuffer)buffer).getByteBuffer(); + // remember the original size of the unencrypted buffer int size=buffer.length(); - HandshakeStatus initialStatus = _engine.getHandshakeStatus(); - //noinspection SynchronizationOnLocalVariableOrMethodParameter + synchronized (bbuf) { + bbuf.position(buffer.putIndex()); try { // Call the SSLEngine unwrap method to process data in @@ -497,129 +410,9 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint // super.fill is called to read encrypted bytes. unwrap(bbuf); - // Loop through the SSL engine state machine - - int wraps=0; - loop: while (true) - { - // If we have encrypted data in output buffer - if (isBufferingOutput()) - { - // we must flush it, as the other end might be - // waiting for that outgoing data before sending - // more incoming data - flush(); - - // If we were unable to flush all the data, then - // we should break the loop and wait for the call - // back to handle when the SelectSet detects that - // the channel is writable again. - if (isBufferingOutput()) - break loop; - } - - // handle the current hand share status - switch(_engine.getHandshakeStatus()) - { - case FINISHED: - case NOT_HANDSHAKING: - // If we are closing, then unwrap must have CLOSED result, - // so return -1 to signal upwards - if (_closing) - return -1; - - // otherwise we break loop with the data we have unwrapped. - break loop; - - case NEED_UNWRAP: - checkRenegotiate(); - // Need more data to be unwrapped so try another call to unwrap - if (!unwrap(bbuf) && _engine.getHandshakeStatus()==HandshakeStatus.NEED_UNWRAP) - { - // If the unwrap call did not make any progress and we are still in - // NEED_UNWRAP, then we should break the loop and wait for more data to - // arrive. - break loop; - } - // progress was made so continue the loop. - break; - - case NEED_TASK: - { - // A task needs to be run, so run it! - - Runnable task; - while ((task=_engine.getDelegatedTask())!=null) - { - task.run(); - } - - // Detect SUN JVM Bug!!! - if(initialStatus==HandshakeStatus.NOT_HANDSHAKING && - _engine.getHandshakeStatus()==HandshakeStatus.NEED_UNWRAP && wraps==0) - { - // This should be NEED_WRAP - // The fix simply detects the signature of the bug and then close the connection (fail-fast) so that ff3 will delegate to using SSL instead of TLS. - // This is a jvm bug on java1.6 where the SSLEngine expects more data from the initial handshake when the client(ff3-tls) already had given it. - // See http://jira.codehaus.org/browse/JETTY-567 for more details - if (_debug) __log.warn(_session+" JETTY-567"); - return -1; - } - break; - } - - case NEED_WRAP: - { - checkRenegotiate(); - // The SSL needs to send some handshake data to the other side, - // so let fill become a flush for a little bit. - wraps++; - needOutBuffer(); - ByteBuffer out_buffer=_outNIOBuffer.getByteBuffer(); - synchronized(out_buffer) - { - try - { - // call wrap with empty application buffers, so it can - // generate required handshake messages into _outNIOBuffer - _outNIOBuffer.compact(); - int put=_outNIOBuffer.putIndex(); - out_buffer.position(); - _result=null; - _result=_engine.wrap(__NO_BUFFERS,out_buffer); - if (_debug) __log.debug(_session+" fill wrap "+_result); - switch(_result.getStatus()) - { - case BUFFER_OVERFLOW: - case BUFFER_UNDERFLOW: - LOG.warn("wrap {}",_result); - _closing=true; - break; - case CLOSED: - _closing=true; - break; - } - _outNIOBuffer.setPutIndex(put+_result.bytesProduced()); - } - catch(SSLException e) - { - super.close(); - throw e; - } - finally - { - out_buffer.position(0); - } - } - - // flush the encrypted outNIOBuffer - flush(); - freeOutBuffer(); - - break; - } - } - } + int progress = process(bbuf,null,null); + + // TODO ??? } finally { @@ -640,7 +433,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint @Override public int flush(Buffer buffer) throws IOException { - return flush(buffer,null,null); + LOG.debug("{} flush1",_session); + return process(null,buffer,null); } @@ -650,136 +444,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint @Override public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException { - int consumed=0; - int available=header==null?0:header.length(); - if (buffer!=null) - available+=buffer.length(); - - needOutBuffer(); - ByteBuffer out_buffer=_outNIOBuffer.getByteBuffer(); - loop: while (true) - { - if (_outNIOBuffer.length()>0) - { - flush(); - if (isBufferingOutput()) - break loop; - } - - switch(_engine.getHandshakeStatus()) - { - case FINISHED: - case NOT_HANDSHAKING: - if (_closing || available==0) - { - if (consumed==0) - consumed= -1; - break loop; - } - - int c; - if (header!=null && header.length()>0) - { - if (buffer!=null && buffer.length()>0) - c=wrap(header,buffer); - else - c=wrap(header); - } - else - c=wrap(buffer); - - - if (c>0) - { - _handshook=true; - consumed+=c; - available-=c; - } - else if (c<0) - { - if (consumed==0) - consumed=-1; - break loop; - } - - break; - - case NEED_UNWRAP: - checkRenegotiate(); - Buffer buf =_buffers.getBuffer(_engine.getSession().getApplicationBufferSize()); - try - { - ByteBuffer bbuf = ((NIOBuffer)buf).getByteBuffer(); - if (!unwrap(bbuf) && _engine.getHandshakeStatus()==HandshakeStatus.NEED_UNWRAP) - { - break loop; - } - } - finally - { - _buffers.returnBuffer(buf); - } - - break; - - case NEED_TASK: - { - Runnable task; - while ((task=_engine.getDelegatedTask())!=null) - { - task.run(); - } - break; - } - - case NEED_WRAP: - { - checkRenegotiate(); - synchronized(out_buffer) - { - try - { - _outNIOBuffer.compact(); - int put=_outNIOBuffer.putIndex(); - out_buffer.position(); - _result=null; - _result=_engine.wrap(__NO_BUFFERS,out_buffer); - if (_debug) __log.debug(_session+" flush wrap "+_result); - switch(_result.getStatus()) - { - case BUFFER_OVERFLOW: - case BUFFER_UNDERFLOW: - LOG.warn("unwrap {}",_result); - _closing=true; - break; - case CLOSED: - _closing=true; - break; - } - _outNIOBuffer.setPutIndex(put+_result.bytesProduced()); - } - catch(SSLException e) - { - super.close(); - throw e; - } - finally - { - out_buffer.position(0); - } - } - - flush(); - if (isBufferingOutput()) - break loop; - - break; - } - } - } - - freeOutBuffer(); - return consumed; + LOG.debug("{} flush3",_session); + return process(null,header,buffer); } /* ------------------------------------------------------------ */ @@ -790,20 +456,20 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { int flushed=super.flush(_outNIOBuffer); if (_debug) - __log.debug(_session+" Flushed "+flushed+" left="+_outNIOBuffer.length()); + LOG.debug(_session+" flushed "+flushed+" left="+_outNIOBuffer.length()); } else if (_closing) { - if (_engine.isOutboundDone()) + if (_engine.isOutboundDone() && !super.isOutputShutdown()) { if (_debug) - __log.debug(_session+" close"); - super.close(); + LOG.debug(_session+" flush shutdownOutput"); + super.shutdownOutput(); } else { if (_debug) - __log.debug(_session+" closeOutbound"); + LOG.debug(_session+" flush closeOutbound"); _engine.closeOutbound(); } } @@ -819,16 +485,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } } - /* ------------------------------------------------------------ */ - private ByteBuffer extractInputBuffer(Buffer buffer) - { - assert buffer instanceof NIOBuffer; - NIOBuffer nbuf=(NIOBuffer)buffer; - ByteBuffer bbuf=nbuf.getByteBuffer(); - bbuf.position(buffer.putIndex()); - return bbuf; - } - /* ------------------------------------------------------------ */ /** * @return true if progress is made @@ -851,7 +507,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint try { int filled=super.fill(_inNIOBuffer); - if (_debug) __log.debug(_session+" unwrap filled "+filled); + if (_debug) LOG.debug(_session+" filled "+filled); if (filled < 0) remoteClosed = true; // break the loop if no progress is made (we have read everything there is to read) @@ -878,6 +534,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint // If we have no progress and no data if (total_filled==0 && _inNIOBuffer.length()==0) { + // Do we need to close? if (isOpen() && remoteClosed) { try @@ -911,7 +568,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint // Do the unwrap _result=_engine.unwrap(in_buffer,buffer); - if (_debug) __log.debug(_session+" unwrap unwrap "+_result); + if (_debug) LOG.debug(_session+" unwrap "+_result); // skip the bytes consumed _inNIOBuffer.skip(_result.bytesConsumed()); @@ -935,7 +592,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint switch(_result.getStatus()) { case BUFFER_OVERFLOW: - throw new IllegalStateException(_result.toString()+" "+buffer.position()+" "+buffer.limit()); + LOG.debug("{} BUFFER_OVERFLOW",_session); + return false; case BUFFER_UNDERFLOW: // Not enough data, @@ -1005,7 +663,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint _result=null; _result=_engine.wrap(_gather,out_buffer); - if (_debug) __log.debug(_session+" wrap wrap "+_result); + if (_debug) LOG.debug(_session+" wrap wrap "+_result); _outNIOBuffer.setGetIndex(0); _outNIOBuffer.setPutIndex(_result.bytesProduced()); consumed=_result.bytesConsumed(); @@ -1088,7 +746,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint out_buffer.limit(out_buffer.capacity()); _result=null; _result=_engine.wrap(_gather[0],out_buffer); - if (_debug) __log.debug(_session+" wrap wrap "+_result); + if (_debug) LOG.debug(_session+" wrap "+_result); _outNIOBuffer.setGetIndex(0); _outNIOBuffer.setPutIndex(_result.bytesProduced()); consumed=_result.bytesConsumed(); @@ -1182,7 +840,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint final NIOBuffer i=_inNIOBuffer; final NIOBuffer o=_outNIOBuffer; return "SSL"+super.toString()+","+_engine.getHandshakeStatus()+", in/out="+ - (i==null?0:_inNIOBuffer.length())+"/"+(o==null?0:o.length())+ + (i==null?0:i.length())+"/"+(o==null?0:o.length())+ " bi/o="+isBufferingInput()+"/"+isBufferingOutput()+ " "+_result; } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index adc3dc18e0b..dee1227637b 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -26,6 +26,7 @@ public class AsyncHttpConnection extends HttpConnection public Connection handle() throws IOException { + LOG.debug("handle {}",this); Connection connection = this; boolean some_progress=false; boolean progress=true; @@ -42,7 +43,6 @@ public class AsyncHttpConnection extends HttpConnection progress=false; try { - LOG.debug("async request",_request); // Handle resumed request if (_request._async.isAsync() && !_request._async.isComplete()) @@ -145,6 +145,7 @@ public class AsyncHttpConnection extends HttpConnection } } } + LOG.debug("unhandle {}",this); } return connection; } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index 2b510cd8504..43b0978f169 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -490,17 +490,17 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture configureServer(new BigBlockHandler()); Socket client=newSocket(HOST,_connector.getLocalPort()); - client.setSoTimeout(10000); + client.setSoTimeout(20000); try { OutputStream os=client.getOutputStream(); BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); os.write(( - "GET / HTTP/1.1\r\n"+ + "GET /r1 HTTP/1.1\r\n"+ "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ "\r\n"+ - "GET / HTTP/1.1\r\n"+ + "GET /r2 HTTP/1.1\r\n"+ "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ "connection: close\r\n"+ "\r\n" @@ -583,6 +583,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture } } + // Handler that sends big blocks of data in each of 10 writes, and then sends the time it took for each big block. protected static class BigBlockHandler extends AbstractHandler { public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException @@ -598,10 +599,12 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture long[] times=new long[10]; for (int i=0;i Date: Tue, 27 Sep 2011 22:37:27 +1000 Subject: [PATCH 089/134] 357240 safer SSL close --- .../test/java/org/eclipse/jetty/server/HttpServerTestBase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index 43b0978f169..aa75b07c2b4 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -447,6 +447,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture long start=System.currentTimeMillis(); Socket client=newSocket(HOST,_connector.getLocalPort()); + int total=0; try { OutputStream os=client.getOutputStream(); @@ -461,7 +462,6 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture ).getBytes()); os.flush(); - int total=0; int len=0; byte[] buf=new byte[1024*32]; @@ -480,6 +480,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture } finally { + System.err.println("Got "+total+" of "+(512*1024)); client.close(); } } From ded51437000367369b88e2758c85069b422fc261 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 27 Sep 2011 15:00:20 +0200 Subject: [PATCH 090/134] Split "if" statement in case of flushing while closing, so if the input is shutdown we do not call closeOutbound(). --- .../io/nio/SslSelectChannelEndPoint.java | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 380310851cd..e591e44b38c 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -42,7 +42,7 @@ import org.eclipse.jetty.util.log.Logger; public class SslSelectChannelEndPoint extends SelectChannelEndPoint { public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio").getLogger("ssl"); - + private static final Buffer __EMPTY_BUFFER=new DirectNIOBuffer(0); private static final ByteBuffer __ZERO_BUFFER=ByteBuffer.allocate(0); @@ -153,7 +153,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint SSLEngineResult result = _result; return result!=null && (result.bytesConsumed()>0 || result.bytesProduced()>0); } - + /* ------------------------------------------------------------ */ /** * @return True if SSL re-negotiation is allowed (default false) @@ -213,29 +213,29 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { if (_debug) LOG.debug("process {} {} {}",inbuf!=null,header!=null,buffer!=null); - - // If there is no place to put incoming application data, + + // If there is no place to put incoming application data, if (inbuf==null) { // use ZERO buffer inbuf=__ZERO_BUFFER; } - + int received=0; int sent=0; - - + + HandshakeStatus initialStatus = _engine.getHandshakeStatus(); boolean progress=true; - + while (progress) { progress=false; - + // flush output data { int len=_outNIOBuffer==null?0:_outNIOBuffer.length(); - + // we must flush it, as the other end might be // waiting for that outgoing data before sending // more incoming data @@ -251,15 +251,15 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { case FINISHED: throw new IllegalStateException(); - + case NOT_HANDSHAKING: - + _handshook=true; - + // If closing, don't process application data if (_closing) break; - + // Try wrapping some application data if (header!=null||buffer!=null) { @@ -277,7 +277,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint c=wrap(buffer); progress=_result.bytesProduced()>0||_result.bytesConsumed()>0; } - + if (c>0) sent+=c; else if (c<0 && sent==0) @@ -293,7 +293,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } break; - + case NEED_TASK: { // A task needs to be run, so run it! @@ -342,31 +342,31 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint else if (c<0 && sent==0) sent=-1; - + break; } - + case NEED_UNWRAP: { checkRenegotiate(); - + // Need more data to be unwrapped so try another call to unwrap progress|=unwrap(inbuf); if (_closing) inbuf.clear(); - + break; } } - + if (_debug) LOG.debug("{} progress {}",_session,progress); } if (_debug) LOG.debug("{} received {} sent {}",_session,received,sent); return (received<0||sent<0)?-1:(received+sent); } - - + + /* ------------------------------------------------------------ */ @Override @@ -376,7 +376,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint return; LOG.debug("{} close",_session); _closing=true; - + // Processing will call flush(), which will handle the closing state with a closeOutbound then shutdownOutput process(null,null,null); } @@ -388,18 +388,18 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint */ @Override public int fill(Buffer buffer) throws IOException - { + { LOG.debug("{} fill",_session); // This end point only works on NIO buffer type (director // or indirect), so extract the NIO buffer that is wrapped // by the passed jetty Buffer. ByteBuffer bbuf=((NIOBuffer)buffer).getByteBuffer(); - + // remember the original size of the unencrypted buffer int size=buffer.length(); - + synchronized (bbuf) { bbuf.position(buffer.putIndex()); @@ -411,7 +411,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint unwrap(bbuf); int progress = process(bbuf,null,null); - + // TODO ??? } finally @@ -451,24 +451,27 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint /* ------------------------------------------------------------ */ @Override public void flush() throws IOException - { + { if (isBufferingOutput()) { int flushed=super.flush(_outNIOBuffer); - if (_debug) + if (_debug) LOG.debug(_session+" flushed "+flushed+" left="+_outNIOBuffer.length()); } else if (_closing) { - if (_engine.isOutboundDone() && !super.isOutputShutdown()) + if (_engine.isOutboundDone()) { - if (_debug) - LOG.debug(_session+" flush shutdownOutput"); - super.shutdownOutput(); + if (!super.isOutputShutdown()) + { + if (_debug) + LOG.debug(_session+" flush shutdownOutput"); + super.shutdownOutput(); + } } else { - if (_debug) + if (_debug) LOG.debug(_session+" flush closeOutbound"); _engine.closeOutbound(); } From 9f885dcc6e2181bbc82584e8ac00628f280f7376 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 27 Sep 2011 23:41:49 +1000 Subject: [PATCH 091/134] 357240 removed gather write --- .../io/nio/SslSelectChannelEndPoint.java | 193 +++++------------- 1 file changed, 48 insertions(+), 145 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 380310851cd..262f2bb2795 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -54,8 +54,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint private volatile NIOBuffer _inNIOBuffer; private volatile NIOBuffer _outNIOBuffer; - private final ByteBuffer[] _gather=new ByteBuffer[2]; - private boolean _closing=false; private SSLEngineResult _result; @@ -209,16 +207,16 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } /* ------------------------------------------------------------ */ - private int process(ByteBuffer inbuf, Buffer header, Buffer buffer) throws IOException + private int process(ByteBuffer inBBuf, Buffer outBuf) throws IOException { if (_debug) - LOG.debug("process {} {} {}",inbuf!=null,header!=null,buffer!=null); + LOG.debug("process {} {}",inBBuf!=null,outBuf!=null); // If there is no place to put incoming application data, - if (inbuf==null) + if (inBBuf==null) { // use ZERO buffer - inbuf=__ZERO_BUFFER; + inBBuf=__ZERO_BUFFER; } int received=0; @@ -261,20 +259,12 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint break; // Try wrapping some application data - if (header!=null||buffer!=null) + if (outBuf!=null) { int c=0; - if (header!=null && header.hasContent()) + if (outBuf!=null && outBuf.hasContent()) { - if (buffer!=null && buffer.hasContent()) - c=wrap(header,buffer); - else - c=wrap(header); - progress=_result.bytesProduced()>0||_result.bytesConsumed()>0; - } - else if (buffer!=null && buffer.hasContent()) - { - c=wrap(buffer); + c=wrap(outBuf); progress=_result.bytesProduced()>0||_result.bytesConsumed()>0; } @@ -285,11 +275,11 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } // Try unwrapping some application data - if (inbuf.remaining()>0 && _inNIOBuffer!=null && _inNIOBuffer.hasContent()) + if (inBBuf.remaining()>0 && _inNIOBuffer!=null && _inNIOBuffer.hasContent()) { - int space=inbuf.remaining(); - progress|=unwrap(inbuf); - received+=space-inbuf.remaining(); + int space=inBBuf.remaining(); + progress|=unwrap(inBBuf); + received+=space-inBBuf.remaining(); } break; @@ -324,16 +314,9 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint // The SSL needs to send some handshake data to the other side int c=0; - if (header!=null && header.hasContent()) - { - if (buffer!=null && buffer.hasContent()) - c=wrap(header,buffer); - else - c=wrap(header); - } - else if (buffer!=null && buffer.hasContent()) - c=wrap(buffer); - else + if (outBuf!=null && outBuf.hasContent()) + c=wrap(outBuf); + else c=wrap(__EMPTY_BUFFER); progress=_result.bytesProduced()>0||_result.bytesConsumed()>0; @@ -341,7 +324,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint sent+=c; else if (c<0 && sent==0) sent=-1; - break; } @@ -351,9 +333,9 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint checkRenegotiate(); // Need more data to be unwrapped so try another call to unwrap - progress|=unwrap(inbuf); + progress|=unwrap(inBBuf); if (_closing) - inbuf.clear(); + inBBuf.clear(); break; } @@ -378,7 +360,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint _closing=true; // Processing will call flush(), which will handle the closing state with a closeOutbound then shutdownOutput - process(null,null,null); + process(null,null); } /* ------------------------------------------------------------ */ @@ -409,10 +391,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint // the inBuffer. If there is no data in the inBuffer, then // super.fill is called to read encrypted bytes. unwrap(bbuf); - - int progress = process(bbuf,null,null); - - // TODO ??? + process(bbuf,null); } finally { @@ -434,7 +413,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint public int flush(Buffer buffer) throws IOException { LOG.debug("{} flush1",_session); - return process(null,buffer,null); + return process(null,buffer); } @@ -445,7 +424,24 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException { LOG.debug("{} flush3",_session); - return process(null,header,buffer); + + int len=0; + int flushed=0; + if (header!=null && header.hasContent()) + { + len=header.length(); + flushed=flush(header); + } + if (flushed==len && buffer!=null && buffer.hasContent()) + { + int f=flush(buffer); + if (f>=0) + flushed+=f; + else if (flushed==0) + flushed=-1; + } + + return flushed; } /* ------------------------------------------------------------ */ @@ -633,122 +629,29 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint return ByteBuffer.wrap(buffer.array()); } - /* ------------------------------------------------------------ */ - private int wrap(final Buffer header, final Buffer buffer) throws IOException - { - _gather[0]=extractOutputBuffer(header); - - synchronized(_gather[0]) - { - _gather[0].position(header.getIndex()); - _gather[0].limit(header.putIndex()); - - _gather[1]=extractOutputBuffer(buffer); - - synchronized(_gather[1]) - { - _gather[1].position(buffer.getIndex()); - _gather[1].limit(buffer.putIndex()); - - needOutBuffer(); - ByteBuffer out_buffer=_outNIOBuffer.getByteBuffer(); - synchronized(out_buffer) - { - int consumed=0; - try - { - _outNIOBuffer.clear(); - out_buffer.position(0); - out_buffer.limit(out_buffer.capacity()); - - _result=null; - _result=_engine.wrap(_gather,out_buffer); - if (_debug) LOG.debug(_session+" wrap wrap "+_result); - _outNIOBuffer.setGetIndex(0); - _outNIOBuffer.setPutIndex(_result.bytesProduced()); - consumed=_result.bytesConsumed(); - } - catch(SSLException e) - { - LOG.warn(getRemoteAddr()+":"+getRemotePort()+" "+e); - super.close(); - throw e; - } - finally - { - out_buffer.position(0); - - if (consumed>0) - { - int len=consumed0) - { - int len=consumed0?_result.bytesConsumed():-1; - - case OK: - return _result.bytesConsumed(); - case CLOSED: - _closing=true; - return _result.bytesConsumed()>0?_result.bytesConsumed():-1; - - default: - LOG.warn("wrap "+_result); - throw new IOException(_result.toString()); - } - } - /* ------------------------------------------------------------ */ private int wrap(final Buffer buffer) throws IOException { - _gather[0]=extractOutputBuffer(buffer); - synchronized(_gather[0]) + ByteBuffer bbuf=extractOutputBuffer(buffer); + synchronized(bbuf) { - ByteBuffer bb; - - _gather[0].position(buffer.getIndex()); - _gather[0].limit(buffer.putIndex()); int consumed=0; needOutBuffer(); + _outNIOBuffer.compact(); ByteBuffer out_buffer=_outNIOBuffer.getByteBuffer(); synchronized(out_buffer) { try { - _outNIOBuffer.clear(); - out_buffer.position(0); - out_buffer.limit(out_buffer.capacity()); + bbuf.position(buffer.getIndex()); + bbuf.limit(buffer.putIndex()); + out_buffer.position(_outNIOBuffer.putIndex()); + _result=null; - _result=_engine.wrap(_gather[0],out_buffer); + _result=_engine.wrap(bbuf,out_buffer); if (_debug) LOG.debug(_session+" wrap "+_result); - _outNIOBuffer.setGetIndex(0); - _outNIOBuffer.setPutIndex(_result.bytesProduced()); + _outNIOBuffer.setPutIndex(out_buffer.position()); consumed=_result.bytesConsumed(); } catch(SSLException e) @@ -760,14 +663,14 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint finally { out_buffer.position(0); + bbuf.position(0); + bbuf.limit(bbuf.capacity()); if (consumed>0) { int len=consumed Date: Wed, 28 Sep 2011 00:08:40 +1000 Subject: [PATCH 092/134] 357240 work in progress --- .../jetty/io/nio/SslSelectChannelEndPoint.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 4aef78fb7db..06dac971ea4 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -194,16 +194,9 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint public void shutdownOutput() throws IOException { LOG.debug("{} shutdownOutput",_session); - try - { - // All SSL closes should be graceful, as it is more secure. - // So normal SSL close can be used here. - close(); - } - finally - { - super.shutdownOutput(); - } + // All SSL closes should be graceful, as it is more secure. + // So normal SSL close can be used here. + close(); } /* ------------------------------------------------------------ */ From ac7fcd9ab76f40e81609332437b6aad480fe42a1 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 28 Sep 2011 00:29:17 +1000 Subject: [PATCH 093/134] 357240 work in progress --- .../jetty/io/nio/SslSelectChannelEndPoint.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 06dac971ea4..4674daeb5e8 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -592,11 +592,13 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint _closing=true; // return true is some bytes somewhere were moved about. return total_filled>0 ||_result.bytesConsumed()>0 || _result.bytesProduced()>0; + case OK: // return true is some bytes somewhere were moved about. return total_filled>0 ||_result.bytesConsumed()>0 || _result.bytesProduced()>0; + default: - LOG.warn("unwrap "+_result); + LOG.warn("unwrap default: "+_result); throw new IOException(_result.toString()); } } @@ -662,11 +664,13 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } switch(_result.getStatus()) { - case BUFFER_OVERFLOW: case BUFFER_UNDERFLOW: - LOG.warn("unwrap {}",_result); - _closing=true; - return _result.bytesConsumed()>0?_result.bytesConsumed():-1; + throw new IllegalStateException(); + + case BUFFER_OVERFLOW: + LOG.debug("wrap {}",_result); + flush(); + return 0; case OK: return _result.bytesConsumed(); @@ -675,7 +679,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint return _result.bytesConsumed()>0?_result.bytesConsumed():-1; default: - LOG.warn("wrap "+_result); + LOG.warn("wrap default "+_result); throw new IOException(_result.toString()); } } From c20ce1fc4e09fb8e425a4dee78eea66add0ded60 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 28 Sep 2011 10:44:43 +1000 Subject: [PATCH 094/134] 357240 remove buffer counts --- .../eclipse/jetty/io/nio/SslSelectChannelEndPoint.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 4674daeb5e8..68167db4296 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -50,7 +50,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint private final SSLEngine _engine; private final SSLSession _session; - private int _inCount; private volatile NIOBuffer _inNIOBuffer; private volatile NIOBuffer _outNIOBuffer; @@ -90,14 +89,12 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint if (_debug) LOG.debug(_session+" channel="+channel); } - int _outCount; /* ------------------------------------------------------------ */ private void needOutBuffer() { synchronized (this) { - _outCount++; if (_outNIOBuffer==null) _outNIOBuffer=(NIOBuffer)_buffers.getBuffer(_session.getPacketBufferSize()); } @@ -108,11 +105,10 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { synchronized (this) { - if (--_outCount<=0 && _outNIOBuffer!=null && _outNIOBuffer.length()==0) + if (_outNIOBuffer!=null && _outNIOBuffer.length()==0) { _buffers.returnBuffer(_outNIOBuffer); _outNIOBuffer=null; - _outCount=0; } } } @@ -122,7 +118,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { synchronized (this) { - _inCount++; if(_inNIOBuffer==null) _inNIOBuffer=(NIOBuffer)_buffers.getBuffer(_session.getPacketBufferSize()); } @@ -133,11 +128,10 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { synchronized (this) { - if (--_inCount<=0 &&_inNIOBuffer!=null && _inNIOBuffer.length()==0) + if (_inNIOBuffer!=null && _inNIOBuffer.length()==0) { _buffers.returnBuffer(_inNIOBuffer); _inNIOBuffer=null; - _inCount=0; } } } From 76c0479ed32e8e0c0b4431895fbf2fea41d1260f Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 28 Sep 2011 11:26:24 +1000 Subject: [PATCH 095/134] JETTY-1439 space in directory installation path causes classloader problem --- .../org/eclipse/jetty/start/Classpath.java | 154 +++++++----------- 1 file changed, 61 insertions(+), 93 deletions(-) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Classpath.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Classpath.java index 0f49e0b28b8..3668254783e 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Classpath.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Classpath.java @@ -23,36 +23,39 @@ import java.net.URLClassLoader; import java.util.StringTokenizer; import java.util.Vector; - /** * Class to handle CLASSPATH construction */ -public class Classpath { +public class Classpath +{ - private final Vector _elements = new Vector(); + private final Vector _elements = new Vector(); public Classpath() - {} + { + } public Classpath(String initial) { addClasspath(initial); } - + public File[] getElements() { return _elements.toArray(new File[_elements.size()]); } - + public int count() { return _elements.size(); } - + public boolean addComponent(String component) { - if ((component != null)&&(component.length()>0)) { - try { + if ((component != null) && (component.length() > 0)) + { + try + { File f = new File(component); if (f.exists()) { @@ -63,36 +66,46 @@ public class Classpath { return true; } } - } catch (IOException e) {} + } + catch (IOException e) + { + } } return false; } - + public boolean addComponent(File component) { - if (component != null) { - try { - if (component.exists()) { + if (component != null) + { + try + { + if (component.exists()) + { File key = component.getCanonicalFile(); - if (!_elements.contains(key)) { + if (!_elements.contains(key)) + { _elements.add(key); return true; } } - } catch (IOException e) {} + } + catch (IOException e) + { + } } return false; } public boolean addClasspath(String s) { - boolean added=false; + boolean added = false; if (s != null) { StringTokenizer t = new StringTokenizer(s, File.pathSeparator); while (t.hasMoreTokens()) { - added|=addComponent(t.nextToken()); + added |= addComponent(t.nextToken()); } } return added; @@ -103,40 +116,49 @@ public class Classpath { int i = 0; for (File element : _elements) { - out.printf("%2d: %s\n",i++,element.getAbsolutePath()); + out.printf("%2d: %s\n", i++, element.getAbsolutePath()); } } - + @Override public String toString() { StringBuffer cp = new StringBuffer(1024); int cnt = _elements.size(); - if (cnt >= 1) { - cp.append( ((_elements.elementAt(0))).getPath() ); + if (cnt >= 1) + { + cp.append(((_elements.elementAt(0))).getPath()); } - for (int i=1; i < cnt; i++) { + for (int i = 1; i < cnt; i++) + { cp.append(File.pathSeparatorChar); - cp.append( ((_elements.elementAt(i))).getPath() ); + cp.append(((_elements.elementAt(i))).getPath()); } return cp.toString(); } - - public ClassLoader getClassLoader() { + + public ClassLoader getClassLoader() + { int cnt = _elements.size(); URL[] urls = new URL[cnt]; - for (int i=0; i < cnt; i++) { - try { - String u=_elements.elementAt(i).toURI().toURL().toString(); - urls[i] = new URL(encodeFileURL(u)); - } catch (MalformedURLException e) {} + for (int i = 0; i < cnt; i++) + { + try + { + urls[i] = _elements.elementAt(i).toURI().toURL(); + } + catch (MalformedURLException e) + { + } } - + ClassLoader parent = Thread.currentThread().getContextClassLoader(); - if (parent == null) { + if (parent == null) + { parent = Classpath.class.getClassLoader(); } - if (parent == null) { + if (parent == null) + { parent = ClassLoader.getSystemClassLoader(); } return new Loader(urls, parent); @@ -152,71 +174,17 @@ public class Classpath { @Override public String toString() { - return "startJarLoader@"+Long.toHexString(hashCode()); + return "startJarLoader@" + Long.toHexString(hashCode()); } } - - public static String encodeFileURL(String path) - { - byte[] bytes; - try - { - bytes=path.getBytes("utf-8"); - } - catch (UnsupportedEncodingException e) - { - bytes=path.getBytes(); - } - - StringBuffer buf = new StringBuffer(bytes.length*2); - buf.append("file:"); - - synchronized(buf) - { - for (int i=5;i='a' && b<='z' || b>='A' && b<='Z' || b>='0' && b<='9') - { - buf.append((char)b); - continue; - } - } - buf.append('%'); - buf.append(Integer.toHexString((0xf0&b)>>4)); - buf.append(Integer.toHexString((0x0f&b))); - continue; - } - } - } - return buf.toString(); - } + /** - * Overlay another classpath, copying its elements into place on this Classpath, while eliminating duplicate entries - * on the classpath. + * Overlay another classpath, copying its elements into place on this + * Classpath, while eliminating duplicate entries on the classpath. * - * @param cpOther - * the other classpath to overlay + * @param cpOther the other classpath to overlay */ public void overlay(Classpath cpOther) { From 65e7d65442e027ce4046b09bdc914bb338513603 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 28 Sep 2011 14:59:34 +1000 Subject: [PATCH 096/134] 358959 File descriptor leak with UnresolvedAddressException --- .../eclipse/jetty/client/SelectConnector.java | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index 7a561727abe..fd37190a2b5 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -91,36 +91,23 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector public void startConnection( HttpDestination destination ) throws IOException { + SocketChannel channel = null; try { - SocketChannel channel = SocketChannel.open(); + channel = SocketChannel.open(); Address address = destination.isProxied() ? destination.getProxy() : destination.getAddress(); channel.socket().setTcpNoDelay(true); if (_httpClient.isConnectBlocking()) { - channel.socket().connect(address.toSocketAddress(), _httpClient.getConnectTimeout()); - channel.configureBlocking(false); - _selectorManager.register( channel, destination ); + channel.socket().connect(address.toSocketAddress(), _httpClient.getConnectTimeout()); + channel.configureBlocking(false); + _selectorManager.register( channel, destination ); } else { channel.configureBlocking(false); - try - { - channel.connect(address.toSocketAddress()); - } - catch (UnresolvedAddressException uae) - { - channel.close(); - throw uae; - } - catch ( UnknownHostException uhe ) - { - channel.close(); - throw uhe; - } - + channel.connect(address.toSocketAddress()); _selectorManager.register(channel,destination); ConnectTimeout connectTimeout = new ConnectTimeout(channel,destination); _httpClient.schedule(connectTimeout,_httpClient.getConnectTimeout()); @@ -130,6 +117,8 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector } catch(IOException ex) { + if (channel != null) + channel.close(); destination.onConnectionFailed(ex); } } From 6eaa1364e39fcc57a20d46dbfa89bcaea8811b99 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 28 Sep 2011 16:21:57 +1000 Subject: [PATCH 097/134] 357240 work in progress --- .../eclipse/jetty/client/HttpConnection.java | 5 ++ .../eclipse/jetty/client/HttpExchange.java | 15 +++- .../client/AsyncSslHttpExchangeTest.java | 9 ++- .../jetty/client/HttpExchangeTest.java | 73 ++++++++++++++++-- .../org/eclipse/jetty/http/HttpParser.java | 2 +- .../jetty/io/nio/SelectChannelEndPoint.java | 6 +- .../io/nio/SslSelectChannelEndPoint.java | 76 ++++++++----------- .../jetty/server/HttpServerTestBase.java | 4 +- .../server/ssl/SslTruncationAttackTest.java | 11 --- 9 files changed, 130 insertions(+), 71 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java index 7dbd756f07f..7fad3b9dcca 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java @@ -355,6 +355,7 @@ public class HttpConnection extends AbstractConnection implements Dumpable } } + /* TODO - is this needed ? if (_generator.isComplete() && !_parser.isComplete()) { if (!_endp.isOpen() || _endp.isInputShutdown()) @@ -364,6 +365,7 @@ public class HttpConnection extends AbstractConnection implements Dumpable close(); } } + */ if (complete || failed) { @@ -669,6 +671,9 @@ public class HttpConnection extends AbstractConnection implements Dumpable case HttpExchange.STATUS_EXCEPTED: case HttpExchange.STATUS_EXPIRED: break; + case HttpExchange.STATUS_PARSING_CONTENT: + if (_endp.isInputShutdown() && _parser.isState(HttpParser.STATE_EOF_CONTENT)) + break; default: String exch= exchange.toString(); String reason = _endp.isOpen()?(_endp.isInputShutdown()?"half closed: ":"local close: "):"closed: "; diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java index a7f1197b340..f3fca478122 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java @@ -107,8 +107,10 @@ public class HttpExchange private long _timeout = -1; private volatile Timeout.Task _timeoutTask; - private long _lastStateChange=-1; + private long _lastStateChange=System.currentTimeMillis(); private long _sent=-1; + private int _lastState=-1; + private int _lastStatePeriod=-1; boolean _onRequestCompleteDone; boolean _onResponseCompleteDone; @@ -188,7 +190,10 @@ public class HttpExchange boolean set = false; if (oldStatus!=newStatus) { - _lastStateChange=System.currentTimeMillis(); + long now = System.currentTimeMillis(); + _lastStatePeriod=(int)(now-_lastStateChange); + _lastState=oldStatus; + _lastStateChange=now; if (newStatus==STATUS_SENDING_REQUEST) _sent=_lastStateChange; } @@ -816,8 +821,10 @@ public class HttpExchange String state=toState(getStatus()); long now=System.currentTimeMillis(); long forMs = now -_lastStateChange; - String s= String.format("%s@%x=%s//%s%s#%s(%dms)",getClass().getSimpleName(),hashCode(),_method,_address,_uri,state,forMs); - if (getStatus()>=STATUS_SENDING_REQUEST) + String s= _lastState>=0 + ?String.format("%s@%x=%s//%s%s#%s(%dms)->%s(%dms)",getClass().getSimpleName(),hashCode(),_method,_address,_uri,toState(_lastState),_lastStatePeriod,state,forMs) + :String.format("%s@%x=%s//%s%s#%s(%dms)",getClass().getSimpleName(),hashCode(),_method,_address,_uri,state,forMs); + if (getStatus()>=STATUS_SENDING_REQUEST && _sent>0) s+="sent="+(now-_sent)+"ms"; return s; } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java index e8c2accd48d..068d497dad6 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java @@ -16,6 +16,7 @@ package org.eclipse.jetty.client; import org.eclipse.jetty.client.helperClasses.AsyncSslServerAndClientCreator; import org.eclipse.jetty.client.helperClasses.ServerAndClientCreator; import org.junit.BeforeClass; +import org.junit.Test; public class AsyncSslHttpExchangeTest extends SslHttpExchangeTest { @@ -35,6 +36,12 @@ public class AsyncSslHttpExchangeTest extends SslHttpExchangeTest { super.testPerf(); } - + + @Test + public void testPerf1() throws Exception + { + sender(1,true); + } + } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index 77b353a0420..0e0efc3d5a9 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -129,6 +129,7 @@ public class HttpExchangeTest final CountDownLatch latch = new CountDownLatch(nb); HttpExchange[] httpExchange = new HttpExchange[nb]; long start = System.currentTimeMillis(); + final boolean verbose=false; for (int i = 0; i < nb; i++) { final int n = i; @@ -142,6 +143,8 @@ public class HttpExchangeTest @Override protected void onRequestCommitted() { + if (verbose) + System.err.println("[ "); result = "committed"; } @@ -149,6 +152,8 @@ public class HttpExchangeTest @Override protected void onRequestComplete() throws IOException { + if (verbose) + System.err.println("[ =="); result = "sent"; } @@ -156,6 +161,8 @@ public class HttpExchangeTest /* ------------------------------------------------------------ */ protected void onResponseStatus(Buffer version, int status, Buffer reason) { + if (verbose) + System.err.println("] "+version+" "+status+" "+reason); result = "status"; } @@ -163,12 +170,16 @@ public class HttpExchangeTest @Override protected void onResponseHeader(Buffer name, Buffer value) { + if (verbose) + System.err.println("] "+name+": "+value); } /* ------------------------------------------------------------ */ @Override protected void onResponseHeaderComplete() throws IOException { + if (verbose) + System.err.println("] -"); result = "content"; super.onResponseHeaderComplete(); } @@ -178,18 +189,22 @@ public class HttpExchangeTest protected void onResponseContent(Buffer content) { len += content.length(); + if (verbose) + System.err.println("] "+content.length()+" -> "+len); } /* ------------------------------------------------------------ */ @Override protected void onResponseComplete() { + if (verbose) + System.err.println("] =="); result = "complete"; if (len == 2009) latch.countDown(); else { - System.err.println(n + " ONLY " + len); + System.err.println(n + " ONLY " + len+ "/2009"); } complete.countDown(); } @@ -198,6 +213,8 @@ public class HttpExchangeTest @Override protected void onConnectionFailed(Throwable ex) { + if (verbose) + System.err.println("] "+ex); complete.countDown(); result = "failed"; System.err.println(n + " FAILED " + ex); @@ -208,6 +225,8 @@ public class HttpExchangeTest @Override protected void onException(Throwable ex) { + if (verbose) + System.err.println("] "+ex); complete.countDown(); result = "excepted"; System.err.println(n + " EXCEPTED " + ex); @@ -218,6 +237,8 @@ public class HttpExchangeTest @Override protected void onExpire() { + if (verbose) + System.err.println("] expired"); complete.countDown(); result = "expired"; System.err.println(n + " EXPIRED " + len); @@ -228,7 +249,7 @@ public class HttpExchangeTest @Override public String toString() { - return n+" "+result+" "+len; + return n+"/"+result+"/"+len+"/"+super.toString(); } }; @@ -374,7 +395,50 @@ public class HttpExchangeTest public void testBigPostWithContentExchange() throws Exception { int size =32; - ContentExchange httpExchange=new ContentExchange(); + ContentExchange httpExchange=new ContentExchange() + { + + @Override + protected synchronized void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException + { + System.err.println("] "+version+" "+status+" "+reason); + // TODO Auto-generated method stub + super.onResponseStatus(version,status,reason); + } + + @Override + protected synchronized void onResponseHeader(Buffer name, Buffer value) throws IOException + { + System.err.println("] "+name+": "+value); + // TODO Auto-generated method stub + super.onResponseHeader(name,value); + } + + @Override + protected synchronized void onResponseContent(Buffer content) throws IOException + { + System.err.println("] "+content.length()); + // TODO Auto-generated method stub + super.onResponseContent(content); + } + + @Override + protected void onRequestComplete() throws IOException + { + System.err.println("] =="); + // TODO Auto-generated method stub + super.onRequestComplete(); + } + + @Override + protected void onResponseHeaderComplete() throws IOException + { + System.err.println("] --"); + // TODO Auto-generated method stub + super.onResponseHeaderComplete(); + } + + }; Buffer babuf = new ByteArrayBuffer(size*36*1024); Buffer niobuf = new DirectNIOBuffer(size*36*1024); @@ -394,7 +458,6 @@ public class HttpExchangeTest _httpClient.send(httpExchange); int status = httpExchange.waitForDone(); - assertEquals(HttpExchange.STATUS_COMPLETED,status); String result=httpExchange.getResponseContent(); assertEquals(babuf.length(),result.length()); @@ -406,9 +469,9 @@ public class HttpExchangeTest httpExchange.setRequestContent(niobuf); _httpClient.send(httpExchange); status = httpExchange.waitForDone(); + assertEquals(HttpExchange.STATUS_COMPLETED, status); result=httpExchange.getResponseContent(); assertEquals(niobuf.length(),result.length()); - assertEquals(HttpExchange.STATUS_COMPLETED, status); } /* ------------------------------------------------------------ */ diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index aecc18b069c..9194d6b1242 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -268,7 +268,7 @@ public class HttpParser implements Parser { long filled=fill(); - if (filled < 0) + if (filled < 0 || _endp.isInputShutdown()) { if (_headResponse && _state>STATE_END) { diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 5a8ed7842b6..0d15cc52041 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -569,20 +569,20 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo catch (EofException e) { __log.debug("EOF", e); - try{close();} + try{getChannel().close();} catch(IOException e2){__log.ignore(e2);} } catch (IOException e) { __log.warn(e.toString()); __log.debug(e); - try{close();} + try{getChannel().close();} catch(IOException e2){__log.ignore(e2);} } catch (Throwable e) { __log.warn("handle failed", e); - try{close();} + try{getChannel().close();} catch(IOException e2){__log.ignore(e2);} } dispatched=!undispatch(); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 68167db4296..d60adbf6cb5 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -330,6 +330,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } if (_debug) LOG.debug("{} received {} sent {}",_session,received,sent); + + freeInBuffer(); return (received<0||sent<0)?-1:(received+sent); } @@ -383,13 +385,15 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint buffer.setPutIndex(bbuf.position()); bbuf.position(0); } - - // return the number of unencrypted bytes filled. - int filled=buffer.length()-size; - if (filled>0) - _handshook=true; - return filled; } + // return the number of unencrypted bytes filled. + int filled=buffer.length()-size; + if (filled>0) + _handshook=true; + else if (filled==0 && isInputShutdown()) + return -1; + + return filled; } /* ------------------------------------------------------------ */ @@ -433,18 +437,30 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint public void flush() throws IOException { LOG.debug(_session+" flush"); + if (!isOpen()) + throw new EofException(); + if (isBufferingOutput()) { int flushed=super.flush(_outNIOBuffer); if (_debug) LOG.debug(_session+" flushed "+flushed+" left="+_outNIOBuffer.length()); } - else if (_engine.isOutboundDone() && !super.isOutputShutdown()) + else if (_engine.isOutboundDone() && super.isOpen()) { if (_debug) LOG.debug(_session+" flush shutdownOutput"); - super.shutdownOutput(); + try + { + super.shutdownOutput(); + } + catch(IOException e) + { + LOG.ignore(e); + } } + + freeOutBuffer(); } /* ------------------------------------------------------------ */ @@ -466,41 +482,21 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint needInBuffer(); ByteBuffer in_buffer=_inNIOBuffer.getByteBuffer(); - if (_inNIOBuffer.hasContent()) - _inNIOBuffer.compact(); - else - _inNIOBuffer.clear(); + _inNIOBuffer.compact(); int total_filled=0; boolean remoteClosed = false; // loop filling as much encrypted data as we can into the buffer while (_inNIOBuffer.space()>0 && super.isOpen()) { - try - { - int filled=super.fill(_inNIOBuffer); - if (_debug) LOG.debug(_session+" filled "+filled); - if (filled < 0) - remoteClosed = true; - // break the loop if no progress is made (we have read everything there is to read) - if (filled<=0) - break; - total_filled+=filled; - } - catch(IOException e) - { - if (_inNIOBuffer.length()==0) - { - freeInBuffer(); - if (_outNIOBuffer!=null) - { - _outNIOBuffer.clear(); - freeOutBuffer(); - } - throw e; - } + int filled=super.fill(_inNIOBuffer); + if (_debug) LOG.debug(_session+" filled "+filled); + if (filled < 0) + remoteClosed = true; + // break the loop if no progress is made (we have read everything there is to read) + if (filled<=0) break; - } + total_filled+=filled; } // If we have no progress and no data @@ -521,9 +517,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } } - freeInBuffer(); - freeOutBuffer(); - if (!isOpen()) throw new EofException(); @@ -548,7 +541,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint catch(SSLException e) { LOG.warn(getRemoteAddr() + ":" + getRemotePort() + " " + e); - freeOutBuffer(); super.close(); throw e; } @@ -557,7 +549,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint // reset the buffer so it can be managed by the _inNIOBuffer again. in_buffer.position(0); in_buffer.limit(in_buffer.capacity()); - freeInBuffer(); } // handle the unwrap results @@ -650,9 +641,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint buffer.skip(len); consumed-=len; } - assert consumed==0; - - freeOutBuffer(); } } } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index aa75b07c2b4..5d84335a060 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -600,12 +600,12 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture long[] times=new long[10]; for (int i=0;i Date: Wed, 28 Sep 2011 20:33:03 +1000 Subject: [PATCH 098/134] 357240 work in progress --- .../jetty/io/nio/SelectChannelEndPoint.java | 52 ++++++++++++------- .../eclipse/jetty/io/nio/SelectorManager.java | 37 +++++++------ .../io/nio/SslSelectChannelEndPoint.java | 16 +++--- .../jetty/server/AsyncHttpConnection.java | 2 +- .../server/BusySelectChannelServerTest.java | 7 +++ .../jetty/server/ConnectorTimeoutTest.java | 6 +++ 6 files changed, 74 insertions(+), 46 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 0d15cc52041..84623ce9aa6 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -34,7 +34,7 @@ import org.eclipse.jetty.util.log.Logger; */ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPoint, ConnectedEndPoint { - public static final Logger __log=Log.getLogger("org.eclipse.jetty.io.nio"); + public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio"); private final SelectorManager.SelectSet _selectSet; private final SelectorManager _manager; @@ -54,7 +54,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo private boolean _writeBlocked; private boolean _open; private volatile long _idleTimestamp; - + /* ------------------------------------------------------------ */ public SelectChannelEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key, int maxIdleTime) throws IOException @@ -206,7 +206,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo if(!dispatched) { _dispatched = false; - __log.warn("Dispatched Failed! "+this+" to "+_manager); + LOG.warn("Dispatched Failed! "+this+" to "+_manager); updateKey(); } } @@ -350,7 +350,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo } catch (InterruptedException e) { - __log.warn(e); + LOG.warn(e); } finally { @@ -395,7 +395,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo } catch (InterruptedException e) { - __log.warn(e); + LOG.warn(e); } finally { @@ -408,7 +408,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo catch(Throwable e) { // TODO remove this if it finds nothing - __log.warn(e); + LOG.warn(e); if (e instanceof RuntimeException) throw (RuntimeException)e; if (e instanceof Error) @@ -424,10 +424,22 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo } return true; } + + /* ------------------------------------------------------------ */ + /* short cut for busyselectChannelServerTest */ + public void clearWritable() + { + _writable=false; + } /* ------------------------------------------------------------ */ public void scheduleWrite() { + if (_writable==true) + { + LOG.warn("Required scheduleWrite"); + } + _writable=false; updateKey(); } @@ -455,7 +467,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo catch(Exception e) { _key=null; - __log.ignore(e); + LOG.ignore(e); } } @@ -493,7 +505,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo } catch (Exception e) { - __log.ignore(e); + LOG.ignore(e); if (_key!=null && _key.isValid()) { _key.cancel(); @@ -555,7 +567,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo final Connection next = _connection.handle(); if (next!=_connection) { - __log.debug("{} replaced {}",next,_connection); + LOG.debug("{} replaced {}",next,_connection); _connection=next; continue; } @@ -564,26 +576,26 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo } catch (ClosedChannelException e) { - __log.ignore(e); + LOG.ignore(e); } catch (EofException e) { - __log.debug("EOF", e); + LOG.debug("EOF", e); try{getChannel().close();} - catch(IOException e2){__log.ignore(e2);} + catch(IOException e2){LOG.ignore(e2);} } catch (IOException e) { - __log.warn(e.toString()); - __log.debug(e); + LOG.warn(e.toString()); + LOG.debug(e); try{getChannel().close();} - catch(IOException e2){__log.ignore(e2);} + catch(IOException e2){LOG.ignore(e2);} } catch (Throwable e) { - __log.warn("handle failed", e); + LOG.warn("handle failed", e); try{getChannel().close();} - catch(IOException e2){__log.ignore(e2);} + catch(IOException e2){LOG.ignore(e2);} } dispatched=!undispatch(); } @@ -595,7 +607,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo dispatched=!undispatch(); while (dispatched) { - __log.warn("SCEP.run() finally DISPATCHED"); + LOG.warn("SCEP.run() finally DISPATCHED"); dispatched=!undispatch(); } } @@ -615,7 +627,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo } catch (IOException e) { - __log.ignore(e); + LOG.ignore(e); } finally { @@ -630,7 +642,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo synchronized(this) { return "SCEP@" + hashCode() + _channel+ - "[d=" + _dispatched + ",io=" + _interestOps+ + "[o="+isOpen()+" d=" + _dispatched + ",io=" + _interestOps+ ",w=" + _writable + ",rb=" + _readBlocked + ",wb=" + _writeBlocked + "]"; } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index 092775a37a6..56720f4a9d3 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -938,28 +938,31 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa } Selector selector=_selector; - final ArrayList dump = new ArrayList(selector.keys().size()*2); - dump.add(where); + if (selector!=null) + { + final ArrayList dump = new ArrayList(selector.keys().size()*2); + dump.add(where); - final CountDownLatch latch = new CountDownLatch(1); + final CountDownLatch latch = new CountDownLatch(1); - addChange(new ChangeTask(){ - public void run() + addChange(new ChangeTask(){ + public void run() + { + dumpKeyState(dump); + latch.countDown(); + } + }); + + try { - dumpKeyState(dump); - latch.countDown(); + latch.await(5,TimeUnit.SECONDS); } - }); - - try - { - latch.await(5,TimeUnit.SECONDS); + catch(InterruptedException e) + { + LOG.ignore(e); + } + AggregateLifeCycle.dump(out,indent,dump); } - catch(InterruptedException e) - { - LOG.ignore(e); - } - AggregateLifeCycle.dump(out,indent,dump); } /* ------------------------------------------------------------ */ diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index d60adbf6cb5..3c1b663bc19 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -56,8 +56,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint private boolean _closing=false; private SSLEngineResult _result; - private boolean _handshook=false; - private boolean _allowRenegotiate=false; + private volatile boolean _handshook=false; + private boolean _allowRenegotiate=true; private final boolean _debug = LOG.isDebugEnabled(); // snapshot debug status for optimizer @@ -239,8 +239,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint case NOT_HANDSHAKING: - _handshook=true; - // If closing, don't process application data if (_closing) { @@ -388,9 +386,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } // return the number of unencrypted bytes filled. int filled=buffer.length()-size; - if (filled>0) - _handshook=true; - else if (filled==0 && isInputShutdown()) + if (filled==0 && isInputShutdown()) return -1; return filled; @@ -533,6 +529,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint // Do the unwrap _result=_engine.unwrap(in_buffer,buffer); + if (!_handshook && _result.getHandshakeStatus()==SSLEngineResult.HandshakeStatus.FINISHED) + _handshook=true; if (_debug) LOG.debug(_session+" unwrap "+_result); // skip the bytes consumed @@ -620,6 +618,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint _result=null; _result=_engine.wrap(bbuf,out_buffer); if (_debug) LOG.debug(_session+" wrap "+_result); + if (!_handshook && _result.getHandshakeStatus()==SSLEngineResult.HandshakeStatus.FINISHED) + _handshook=true; _outNIOBuffer.setPutIndex(out_buffer.position()); consumed=_result.bytesConsumed(); } @@ -710,7 +710,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { final NIOBuffer i=_inNIOBuffer; final NIOBuffer o=_outNIOBuffer; - return "SSL"+super.toString()+","+_engine.getHandshakeStatus()+", in/out="+ + return "SSL"+super.toString()+","+(_engine==null?"-":_engine.getHandshakeStatus())+", in/out="+ (i==null?0:i.length())+"/"+(o==null?0:o.length())+ " bi/o="+isBufferingInput()+"/"+isBufferingOutput()+ " "+_result; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index dee1227637b..97b66d0585b 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -124,7 +124,7 @@ public class AsyncHttpConnection extends HttpConnection _parser.returnBuffers(); // Are we write blocked - if (_generator.isCommitted() && !_generator.isComplete()) + if (_generator.isCommitted() && !_generator.isComplete() && _endp.isOpen()) ((AsyncEndPoint)_endp).scheduleWrite(); else _generator.returnBuffers(); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/BusySelectChannelServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/BusySelectChannelServerTest.java index 5dde4771887..1f6c6852a8f 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/BusySelectChannelServerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/BusySelectChannelServerTest.java @@ -52,7 +52,10 @@ public class BusySelectChannelServerTest extends HttpServerTestBase { int x=write++&0xff; if (x<8) + { + clearWritable(); return 0; + } if (x<32) return flush(header); return super.flush(header,buffer,trailer); @@ -67,7 +70,10 @@ public class BusySelectChannelServerTest extends HttpServerTestBase { int x=write++&0xff; if (x<8) + { + clearWritable(); return 0; + } if (x<32) { View v = new View(buffer); @@ -75,6 +81,7 @@ public class BusySelectChannelServerTest extends HttpServerTestBase int l=super.flush(v); if (l>0) buffer.skip(l); + clearWritable(); return l; } return super.flush(buffer); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java index 26caaa934b5..67158287b2e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java @@ -45,6 +45,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @Test public void testMaxIdleWithRequest10() throws Exception { + System.err.println("testMaxIdleWithRequest10"); configureServer(new HelloWorldHandler()); Socket client=newSocket(HOST,_connector.getLocalPort()); client.setSoTimeout(10000); @@ -76,6 +77,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @Test public void testMaxIdleWithRequest11() throws Exception { + System.err.println("testMaxIdleWithRequest11"); configureServer(new EchoHandler()); Socket client=newSocket(HOST,_connector.getLocalPort()); client.setSoTimeout(10000); @@ -110,6 +112,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @Test public void testMaxIdleNoRequest() throws Exception { + System.err.println("testMaxIdleNoRequest"); configureServer(new EchoHandler()); Socket client=newSocket(HOST,_connector.getLocalPort()); client.setSoTimeout(10000); @@ -138,6 +141,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @Test public void testMaxIdleWithSlowRequest() throws Exception { + System.err.println("testMaxIdleWithSlowRequest"); configureServer(new EchoHandler()); Socket client=newSocket(HOST,_connector.getLocalPort()); client.setSoTimeout(10000); @@ -178,6 +182,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @Test public void testMaxIdleWithSlowResponse() throws Exception { + System.err.println("testMaxIdleWithSlowResponse"); configureServer(new SlowResponseHandler()); Socket client=newSocket(HOST,_connector.getLocalPort()); client.setSoTimeout(10000); @@ -207,6 +212,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture @Test public void testMaxIdleWithWait() throws Exception { + System.err.println("testMaxIdleWithWait"); configureServer(new WaitHandler()); Socket client=newSocket(HOST,_connector.getLocalPort()); client.setSoTimeout(10000); From 444c09fce75ccb9ccfbddbbf8df33aaace461bab Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 28 Sep 2011 20:37:31 +1000 Subject: [PATCH 099/134] 357240 switch fix --- .../java/org/eclipse/jetty/server/AsyncHttpConnection.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index 97b66d0585b..84557ca7959 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -38,7 +38,7 @@ public class AsyncHttpConnection extends HttpConnection boolean more_in_buffer =false; - while (_endp.isOpen() && (more_in_buffer || progress)) + while (_endp.isOpen() && (more_in_buffer || progress) && connection==this) { progress=false; try @@ -94,7 +94,7 @@ public class AsyncHttpConnection extends HttpConnection { _parser.reset(); _generator.reset(true); - return switched; + connection=switched; } } From fbf0fad0762f9c1a57e7a9084bd7fc3adcbfcb4a Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 28 Sep 2011 22:50:38 +1000 Subject: [PATCH 100/134] 357240 improved ishut/oshut handling --- .../jetty/client/HttpExchangeTest.java | 24 +++++++------- .../eclipse/jetty/io/nio/ChannelEndPoint.java | 32 +++++++++++++++---- .../jetty/io/nio/SelectChannelEndPoint.java | 4 +-- .../io/nio/SslSelectChannelEndPoint.java | 14 ++++++-- .../jetty/server/AsyncHttpConnection.java | 11 ++++++- .../ssl/SslSelectChannelTimeoutTest.java | 9 ++++++ 6 files changed, 67 insertions(+), 27 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index 0e0efc3d5a9..b4ab244364c 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -49,6 +49,7 @@ import org.junit.Test; */ public class HttpExchangeTest { + final static boolean verbose=false; protected static int _maxConnectionsPerAddress = 2; protected static String _scheme = "http"; protected static Server _server; @@ -129,7 +130,6 @@ public class HttpExchangeTest final CountDownLatch latch = new CountDownLatch(nb); HttpExchange[] httpExchange = new HttpExchange[nb]; long start = System.currentTimeMillis(); - final boolean verbose=false; for (int i = 0; i < nb; i++) { final int n = i; @@ -397,44 +397,42 @@ public class HttpExchangeTest int size =32; ContentExchange httpExchange=new ContentExchange() { - @Override protected synchronized void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException { - System.err.println("] "+version+" "+status+" "+reason); - // TODO Auto-generated method stub - super.onResponseStatus(version,status,reason); + if (verbose) + super.onResponseStatus(version,status,reason); } @Override protected synchronized void onResponseHeader(Buffer name, Buffer value) throws IOException { - System.err.println("] "+name+": "+value); - // TODO Auto-generated method stub + if (verbose) + System.err.println("] "+name+": "+value); super.onResponseHeader(name,value); } @Override protected synchronized void onResponseContent(Buffer content) throws IOException { - System.err.println("] "+content.length()); - // TODO Auto-generated method stub + if (verbose) + System.err.println("] "+content.length()); super.onResponseContent(content); } @Override protected void onRequestComplete() throws IOException { - System.err.println("] =="); - // TODO Auto-generated method stub + if (verbose) + System.err.println("] =="); super.onRequestComplete(); } @Override protected void onResponseHeaderComplete() throws IOException { - System.err.println("] --"); - // TODO Auto-generated method stub + if (verbose) + System.err.println("] --"); super.onResponseHeaderComplete(); } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java index 3a8f2b18fbf..5a78f9ffcbf 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java @@ -109,9 +109,12 @@ public class ChannelEndPoint implements EndPoint if (_channel.isOpen() && _channel instanceof SocketChannel) { Socket socket= ((SocketChannel)_channel).socket(); - if (!socket.isClosed()&&!socket.isInputShutdown()) + if (!socket.isClosed()) { - socket.shutdownInput(); + if(socket.isOutputShutdown()) + socket.close(); + else if (!socket.isInputShutdown()) + socket.shutdownInput(); } } } @@ -124,9 +127,12 @@ public class ChannelEndPoint implements EndPoint if (_channel.isOpen() && _channel instanceof SocketChannel) { Socket socket= ((SocketChannel)_channel).socket(); - if (!socket.isClosed()&&!socket.isOutputShutdown()) + if (!socket.isClosed()) { - socket.shutdownOutput(); + if (socket.isInputShutdown()) + socket.close(); + else if (!socket.isOutputShutdown()) + socket.shutdownOutput(); } } } @@ -170,6 +176,14 @@ public class ChannelEndPoint implements EndPoint { bbuf.position(buffer.putIndex()); len=_channel.read(bbuf); + + + LOG.debug("{} {} {} read={}", + this.getChannel().isOpen(), + this.isInputShutdown(), + this.isOutputShutdown(), + this.getChannel().isOpen(), + len); } finally { @@ -178,13 +192,17 @@ public class ChannelEndPoint implements EndPoint } } - if (len<0 && isOpen() && !isInputShutdown()) + if (len<0 && isOpen()) { - shutdownInput(); + if (!isInputShutdown()) + shutdownInput(); + else if (isOutputShutdown()) + _channel.close(); } } catch (IOException x) { + LOG.debug(x); try { close(); @@ -196,7 +214,6 @@ public class ChannelEndPoint implements EndPoint if (len>0) throw x; - LOG.ignore(x); len=-1; } } @@ -255,6 +272,7 @@ public class ChannelEndPoint implements EndPoint { throw new IOException("Not Implemented"); } + return len; } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 84623ce9aa6..5682507cadc 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -436,9 +436,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo public void scheduleWrite() { if (_writable==true) - { - LOG.warn("Required scheduleWrite"); - } + LOG.debug("Required scheduleWrite {}",this); _writable=false; updateKey(); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 3c1b663bc19..0a66b809de4 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -59,7 +59,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint private volatile boolean _handshook=false; private boolean _allowRenegotiate=true; - private final boolean _debug = LOG.isDebugEnabled(); // snapshot debug status for optimizer + private volatile boolean _debug = LOG.isDebugEnabled(); // snapshot debug status for optimizer /* ------------------------------------------------------------ */ public SslSelectChannelEndPoint(Buffers buffers,SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key, SSLEngine engine, int maxIdleTime) @@ -355,6 +355,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint @Override public int fill(Buffer buffer) throws IOException { + _debug=LOG.isDebugEnabled(); LOG.debug("{} fill",_session); // This end point only works on NIO buffer type (director // or indirect), so extract the NIO buffer that is wrapped @@ -396,6 +397,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint @Override public int flush(Buffer buffer) throws IOException { + _debug=LOG.isDebugEnabled(); LOG.debug("{} flush1",_session); return process(null,buffer); } @@ -407,6 +409,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint @Override public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException { + _debug=LOG.isDebugEnabled(); LOG.debug("{} flush3",_session); int len=0; @@ -474,7 +477,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint * @return true if progress is made */ private boolean unwrap(ByteBuffer buffer) throws IOException - { + { needInBuffer(); ByteBuffer in_buffer=_inNIOBuffer.getByteBuffer(); @@ -482,6 +485,9 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint int total_filled=0; boolean remoteClosed = false; + + LOG.debug("{} unwrap {} {}",_session,_inNIOBuffer.space()>0,super.isOpen()); + // loop filling as much encrypted data as we can into the buffer while (_inNIOBuffer.space()>0 && super.isOpen()) { @@ -696,6 +702,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } /* ------------------------------------------------------------ */ +/* @Override public void scheduleWrite() { @@ -703,7 +710,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint if (!HandshakeStatus.NEED_UNWRAP.equals(_engine.getHandshakeStatus()) || super.isBufferingOutput()) super.scheduleWrite(); } - +*/ + /* ------------------------------------------------------------ */ @Override public String toString() diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java index 84557ca7959..b08315b84e0 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java @@ -7,6 +7,7 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.io.nio.ChannelEndPoint; import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -14,7 +15,7 @@ import org.eclipse.jetty.util.log.Logger; public class AsyncHttpConnection extends HttpConnection { private final static int NO_PROGRESS_INFO = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_INFO",100); - private final static int NO_PROGRESS_CLOSE = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_CLOSE",1000); + private final static int NO_PROGRESS_CLOSE = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_CLOSE",200); private static final Logger LOG = Log.getLogger(AsyncHttpConnection.class); private int _total_no_progress; @@ -134,7 +135,15 @@ public class AsyncHttpConnection extends HttpConnection _total_no_progress++; if (NO_PROGRESS_INFO>0 && _total_no_progress%NO_PROGRESS_INFO==0 && (NO_PROGRESS_CLOSE<=0 || _total_no_progress< NO_PROGRESS_CLOSE)) + { LOG.info("EndPoint making no progress: "+_total_no_progress+" "+_endp); + + LOG.setDebugEnabled(true); + Log.getLogger("org.eclipse.jetty.io.nio").getLogger("ssl").setDebugEnabled(true); + Log.getLogger(ChannelEndPoint.class).setDebugEnabled(true); + + } + if (NO_PROGRESS_CLOSE>0 && _total_no_progress>NO_PROGRESS_CLOSE) { LOG.warn("Closing EndPoint making no progress: "+_total_no_progress+" "+_endp); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSelectChannelTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSelectChannelTimeoutTest.java index 2da1cace9b4..159987866e6 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSelectChannelTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslSelectChannelTimeoutTest.java @@ -23,6 +23,7 @@ import javax.net.ssl.TrustManagerFactory; import org.eclipse.jetty.http.ssl.SslContextFactory; import org.eclipse.jetty.server.ConnectorTimeoutTest; import org.junit.BeforeClass; +import org.junit.Test; public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest { @@ -57,4 +58,12 @@ public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest } + @Test + public void testNoProgress() throws Exception + { + testMaxIdleNoRequest(); + super.testMaxIdleWithSlowRequest(); + } + + } From 1420253643767fca0294dff9aebec3e75d0e4f61 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 28 Sep 2011 22:58:14 +1000 Subject: [PATCH 101/134] 357240 improved ishut/oshut handling --- .../java/org/eclipse/jetty/io/nio/ChannelEndPoint.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java index 5a78f9ffcbf..516e1cc6f75 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java @@ -166,8 +166,8 @@ public class ChannelEndPoint implements EndPoint { final NIOBuffer nbuf = (NIOBuffer)buf; final ByteBuffer bbuf=nbuf.getByteBuffer(); - //noinspection SynchronizationOnLocalVariableOrMethodParameter + //noinspection SynchronizationOnLocalVariableOrMethodParameter try { synchronized(bbuf) @@ -176,14 +176,6 @@ public class ChannelEndPoint implements EndPoint { bbuf.position(buffer.putIndex()); len=_channel.read(bbuf); - - - LOG.debug("{} {} {} read={}", - this.getChannel().isOpen(), - this.isInputShutdown(), - this.isOutputShutdown(), - this.getChannel().isOpen(), - len); } finally { From f73a6422f0d307b3f1469521975c2f77e5c0862d Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 29 Sep 2011 00:02:06 +1000 Subject: [PATCH 102/134] 357240 fixed client test --- .../org/eclipse/jetty/client/HttpExchangeTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index b4ab244364c..1ef37e38165 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -397,11 +397,14 @@ public class HttpExchangeTest int size =32; ContentExchange httpExchange=new ContentExchange() { + int total; + @Override protected synchronized void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException { if (verbose) - super.onResponseStatus(version,status,reason); + System.err.println("] "+version+" "+status+" "+reason); + super.onResponseStatus(version,status,reason); } @Override @@ -416,7 +419,10 @@ public class HttpExchangeTest protected synchronized void onResponseContent(Buffer content) throws IOException { if (verbose) - System.err.println("] "+content.length()); + { + total+=content.length(); + System.err.println("] "+content.length()+" -> "+total); + } super.onResponseContent(content); } From a531fbc5a2cd8edfb3629e2f157e76ab325c1b16 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 29 Sep 2011 00:09:13 +1000 Subject: [PATCH 103/134] 357240 fixed client tests --- .../jetty/client/AsyncSslHttpExchangeTest.java | 5 +++-- .../ExternalKeyStoreAsyncSslHttpExchangeTest.java | 5 +++-- .../org/eclipse/jetty/client/HttpExchangeTest.java | 11 +++++++---- .../org/eclipse/jetty/client/SslHttpExchangeTest.java | 5 +++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java index 068d497dad6..ce9dd9654fc 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java @@ -15,6 +15,7 @@ package org.eclipse.jetty.client; import org.eclipse.jetty.client.helperClasses.AsyncSslServerAndClientCreator; import org.eclipse.jetty.client.helperClasses.ServerAndClientCreator; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -22,8 +23,8 @@ public class AsyncSslHttpExchangeTest extends SslHttpExchangeTest { private static ServerAndClientCreator serverAndClientCreator = new AsyncSslServerAndClientCreator(); - @BeforeClass - public static void setUpOnce() throws Exception + @Before + public void setUpOnce() throws Exception { _scheme="https"; _server = serverAndClientCreator.createServer(); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java index 303cdcbec53..27af22c21ed 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalKeyStoreAsyncSslHttpExchangeTest.java @@ -15,6 +15,7 @@ package org.eclipse.jetty.client; import org.eclipse.jetty.client.helperClasses.ExternalKeyStoreAsyncSslServerAndClientCreator; import org.eclipse.jetty.client.helperClasses.ServerAndClientCreator; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -22,8 +23,8 @@ public class ExternalKeyStoreAsyncSslHttpExchangeTest extends SslHttpExchangeTes { private static ServerAndClientCreator serverAndClientCreator = new ExternalKeyStoreAsyncSslServerAndClientCreator(); - @BeforeClass - public static void setUpOnce() throws Exception + @Before + public void setUpOnce() throws Exception { _scheme="https"; _server = serverAndClientCreator.createServer(); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index 1ef37e38165..8c681388a0e 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -39,7 +39,9 @@ import org.eclipse.jetty.io.nio.DirectNIOBuffer; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.toolchain.test.Stress; import org.eclipse.jetty.util.component.AbstractLifeCycle; +import org.junit.After; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -64,8 +66,9 @@ public class HttpExchangeTest } /* ------------------------------------------------------------ */ - @BeforeClass - public static void setUpOnce() throws Exception + // TODO work out why BeforeClass does not work here? + @Before + public void setUpOnce() throws Exception { _scheme = "http"; _server = serverAndClientCreator.createServer(); @@ -74,8 +77,8 @@ public class HttpExchangeTest } /* ------------------------------------------------------------ */ - @AfterClass - public static void tearDownOnce() throws Exception + @After + public void tearDownOnce() throws Exception { _httpClient.stop(); long startTime = System.currentTimeMillis(); diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java index c7c8b887eb8..8ec13c1ef21 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java @@ -21,6 +21,7 @@ import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.toolchain.test.Stress; import org.junit.Assume; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -32,8 +33,8 @@ public class SslHttpExchangeTest extends HttpExchangeTest protected static ServerAndClientCreator serverAndClientCreator = new SslServerAndClientCreator(); /* ------------------------------------------------------------ */ - @BeforeClass - public static void setUpOnce() throws Exception + @Before + public void setUpOnce() throws Exception { _scheme="https"; _server = serverAndClientCreator.createServer(); From 603ee3dae17407806385c8ebedfe93a44ce55312 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 29 Sep 2011 00:23:31 +1000 Subject: [PATCH 104/134] 357240 fixed client tests --- .../helperClasses/AbstractSslServerAndClientCreator.java | 3 ++- .../org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java index 72e626e0087..d7df2a39168 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/helperClasses/AbstractSslServerAndClientCreator.java @@ -17,6 +17,7 @@ package org.eclipse.jetty.client.helperClasses; import org.eclipse.jetty.http.ssl.SslContextFactory; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.server.ssl.SslSocketConnector; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.log.Log; @@ -34,7 +35,7 @@ public abstract class AbstractSslServerAndClientCreator implements ServerAndClie public Server createServer() throws Exception { Server server = new Server(); - // SslSelectChannelConnector connector = new SslSelectChannelConnector(); + //SslSelectChannelConnector connector = new SslSelectChannelConnector(); SslSocketConnector connector = new SslSocketConnector(); String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 0a66b809de4..7476800bde8 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -143,6 +143,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint public boolean isProgressing() { SSLEngineResult result = _result; + _result=null; return result!=null && (result.bytesConsumed()>0 || result.bytesProduced()>0); } From d37f2ca10c6bb17d237fce75a755ad73f35844ae Mon Sep 17 00:00:00 2001 From: David Kellum Date: Thu, 22 Sep 2011 00:02:19 -0700 Subject: [PATCH 105/134] JETTY-1420 Set Host header for new request in RedirectListener --- .../eclipse/jetty/client/RedirectListener.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java b/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java index b46d2bcc4fa..cb06692fe81 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java @@ -115,8 +115,9 @@ public class RedirectListener extends HttpEventListenerWrapper _exchange.setRequestURI(_location); // destination may have changed - HttpDestination destination=_destination.getHttpClient().getDestination(_exchange.getAddress(),HttpSchemes.HTTPS.equals(String.valueOf(_exchange.getScheme()))); - + boolean isHttps = HttpSchemes.HTTPS.equals(String.valueOf(_exchange.getScheme())); + HttpDestination destination=_destination.getHttpClient().getDestination(_exchange.getAddress(),isHttps); + if (_destination==destination) _destination.resend(_exchange); else @@ -129,6 +130,19 @@ public class RedirectListener extends HttpEventListenerWrapper _exchange.getEventListener().onRetry(); _exchange.reset(); _exchange.setEventListener(listener); + + // Set the new Host header + Address adr = _exchange.getAddress(); + int port = adr.getPort(); + StringBuilder hh = new StringBuilder( 64 ); + hh.append( adr.getHost() ); + if( !( ( port == 80 && !isHttps ) || + ( port == 443 && isHttps ) ) ) { + hh.append( ':' ); + hh.append( port ); + } + _exchange.setRequestHeader( HttpHeaders.HOST, hh.toString() ); + destination.send(_exchange); } From 40b25e6f5a594b6a68eb2727289137735696aab2 Mon Sep 17 00:00:00 2001 From: David Kellum Date: Thu, 22 Sep 2011 00:20:08 -0700 Subject: [PATCH 106/134] JETTY-1421 Implement RedirectListener.onException,onConnectionFailed --- .../jetty/client/RedirectListener.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java b/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java index cb06692fe81..140ce9f1ce9 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java @@ -170,5 +170,28 @@ public class RedirectListener extends HttpEventListenerWrapper super.onRetry(); } -} + /** + * Delegate failed connection + */ + @Override + public void onConnectionFailed( Throwable ex ) + { + setDelegatingRequests(true); + setDelegatingResponses(true); + + super.onConnectionFailed( ex ); + } + + /** + * Delegate onException + */ + @Override + public void onException( Throwable ex ) + { + setDelegatingRequests(true); + setDelegatingResponses(true); + + super.onException( ex ); + } +} From 74d5e800f6a5d26e7cf393335617695bb771f83f Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 28 Sep 2011 10:34:08 -0500 Subject: [PATCH 107/134] fix some formatting issues with code conventions --- .../jetty/client/RedirectListener.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java b/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java index 140ce9f1ce9..00bc4595432 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java @@ -110,38 +110,48 @@ public class RedirectListener extends HttpEventListenerWrapper if (_location != null) { if (_location.indexOf("://")>0) + { _exchange.setURL(_location); + } else + { _exchange.setRequestURI(_location); + } // destination may have changed boolean isHttps = HttpSchemes.HTTPS.equals(String.valueOf(_exchange.getScheme())); HttpDestination destination=_destination.getHttpClient().getDestination(_exchange.getAddress(),isHttps); if (_destination==destination) + { _destination.resend(_exchange); + } else { // unwrap to find ultimate listener. HttpEventListener listener=this; while(listener instanceof HttpEventListenerWrapper) + { listener=((HttpEventListenerWrapper)listener).getEventListener(); + } + //reset the listener _exchange.getEventListener().onRetry(); _exchange.reset(); _exchange.setEventListener(listener); // Set the new Host header - Address adr = _exchange.getAddress(); - int port = adr.getPort(); - StringBuilder hh = new StringBuilder( 64 ); - hh.append( adr.getHost() ); - if( !( ( port == 80 && !isHttps ) || - ( port == 443 && isHttps ) ) ) { - hh.append( ':' ); - hh.append( port ); + Address address = _exchange.getAddress(); + int port = address.getPort(); + StringBuilder hostHeader = new StringBuilder( 64 ); + hostHeader.append( address.getHost() ); + if( !( ( port == 80 && !isHttps ) || ( port == 443 && isHttps ) ) ) + { + hostHeader.append( ':' ); + hostHeader.append( port ); } - _exchange.setRequestHeader( HttpHeaders.HOST, hh.toString() ); + + _exchange.setRequestHeader( HttpHeaders.HOST, hostHeader.toString() ); destination.send(_exchange); } From cceef37f17f3c61fe515d0866e396914468f51f7 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Wed, 28 Sep 2011 17:24:24 +0200 Subject: [PATCH 108/134] 359255: Code format --- .../eclipse/jetty/client/HttpExchange.java | 439 ++++++++++-------- 1 file changed, 252 insertions(+), 187 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java index a7f1197b340..9f431e51e74 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java @@ -35,7 +35,9 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.Timeout; /** - *

    An HTTP client API that encapsulates an exchange (a request and its response) with a HTTP server.

    + *

    + * An HTTP client API that encapsulates an exchange (a request and its response) with a HTTP server. + *

    * * This object encapsulates: *
      @@ -48,23 +50,25 @@ import org.eclipse.jetty.util.thread.Timeout; *
    • The ability to intercept callbacks (see {@link #setEventListener(HttpEventListener)} *
    * - *

    The HttpExchange class is intended to be used by a developer wishing to have close asynchronous - * interaction with the the exchange.
    - * Typically a developer will extend the HttpExchange class with a derived - * class that overrides some or all of the onXxx callbacks.
    - * There are also some predefined HttpExchange subtypes that can be used as a basis, - * see {@link org.eclipse.jetty.client.ContentExchange} and {@link org.eclipse.jetty.client.CachedExchange}.

    + *

    + * The HttpExchange class is intended to be used by a developer wishing to have close asynchronous interaction with the the exchange.
    + * Typically a developer will extend the HttpExchange class with a derived class that overrides some or all of the onXxx callbacks.
    + * There are also some predefined HttpExchange subtypes that can be used as a basis, see {@link org.eclipse.jetty.client.ContentExchange} and + * {@link org.eclipse.jetty.client.CachedExchange}. + *

    * - *

    Typically the HttpExchange is passed to the {@link HttpClient#send(HttpExchange)} method, which in - * turn selects a {@link HttpDestination} and calls its {@link HttpDestination#send(HttpExchange)}, which - * then creates or selects a {@link HttpConnection} and calls its {@link HttpConnection#send(HttpExchange)}. - * A developer may wish to directly call send on the destination or connection if they wish to bypass - * some handling provided (eg Cookie handling in the HttpDestination).

    + *

    + * Typically the HttpExchange is passed to the {@link HttpClient#send(HttpExchange)} method, which in turn selects a {@link HttpDestination} and calls its + * {@link HttpDestination#send(HttpExchange)}, which then creates or selects a {@link HttpConnection} and calls its {@link HttpConnection#send(HttpExchange)}. A + * developer may wish to directly call send on the destination or connection if they wish to bypass some handling provided (eg Cookie handling in the + * HttpDestination). + *

    * - *

    In some circumstances, the HttpClient or HttpDestination may wish to retry a HttpExchange (eg. failed - * pipeline request, authentication retry or redirection). In such cases, the HttpClient and/or HttpDestination - * may insert their own HttpExchangeListener to intercept and filter the call backs intended for the - * HttpExchange.

    + *

    + * In some circumstances, the HttpClient or HttpDestination may wish to retry a HttpExchange (eg. failed pipeline request, authentication retry or redirection). + * In such cases, the HttpClient and/or HttpDestination may insert their own HttpExchangeListener to intercept and filter the call backs intended for the + * HttpExchange. + *

    */ public class HttpExchange { @@ -106,9 +110,9 @@ public class HttpExchange // a timeout for this exchange private long _timeout = -1; private volatile Timeout.Task _timeoutTask; - - private long _lastStateChange=-1; - private long _sent=-1; + + private long _lastStateChange = -1; + private long _sent = -1; boolean _onRequestCompleteDone; boolean _onResponseCompleteDone; @@ -131,8 +135,10 @@ public class HttpExchange } /** - * @param status the status to wait for - * @throws InterruptedException if the waiting thread is interrupted + * @param status + * the status to wait for + * @throws InterruptedException + * if the waiting thread is interrupted * @deprecated Use {@link #waitForDone()} instead */ @Deprecated @@ -142,21 +148,17 @@ public class HttpExchange } /** - * Wait until the exchange is "done". - * Done is defined as when a final state has been passed to the - * HttpExchange via the associated onXxx call. Note that an - * exchange can transit a final state when being used as part - * of a dialog (eg {@link SecurityListener}. Done status - * is thus defined as:
    -     *   done == onConnectionFailed
    -     *        || onException
    -     *        || onExpire
    -     *        || onRequestComplete && onResponseComplete
    +     * Wait until the exchange is "done". Done is defined as when a final state has been passed to the HttpExchange via the associated onXxx call. Note that an
    +     * exchange can transit a final state when being used as part of a dialog (eg {@link SecurityListener}. Done status is thus defined as:
    +     *
    +     * 
    +     * done == onConnectionFailed || onException || onExpire || onRequestComplete && onResponseComplete
          * 
    + * * @return the done status * @throws InterruptedException */ - public int waitForDone () throws InterruptedException + public int waitForDone() throws InterruptedException { synchronized (this) { @@ -170,12 +172,12 @@ public class HttpExchange { // TODO - this should do a cancel and wakeup everybody that was waiting. // might need a version number concept - synchronized(this) + synchronized (this) { - _timeoutTask=null; - _onRequestCompleteDone=false; - _onResponseCompleteDone=false; - _onDone=false; + _timeoutTask = null; + _onRequestCompleteDone = false; + _onResponseCompleteDone = false; + _onDone = false; setStatus(STATUS_START); } } @@ -186,13 +188,13 @@ public class HttpExchange { int oldStatus = _status.get(); boolean set = false; - if (oldStatus!=newStatus) + if (oldStatus != newStatus) { - _lastStateChange=System.currentTimeMillis(); - if (newStatus==STATUS_SENDING_REQUEST) - _sent=_lastStateChange; + _lastStateChange = System.currentTimeMillis(); + if (newStatus == STATUS_SENDING_REQUEST) + _sent = _lastStateChange; } - + // State machine: from which old status you can go into which new status switch (oldStatus) { @@ -204,7 +206,7 @@ public class HttpExchange case STATUS_WAITING_FOR_COMMIT: case STATUS_CANCELLING: case STATUS_EXCEPTED: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; } break; @@ -214,10 +216,10 @@ public class HttpExchange case STATUS_WAITING_FOR_COMMIT: case STATUS_CANCELLING: case STATUS_EXCEPTED: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onExpire(); break; } @@ -228,10 +230,10 @@ public class HttpExchange case STATUS_SENDING_REQUEST: case STATUS_CANCELLING: case STATUS_EXCEPTED: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onExpire(); break; } @@ -240,15 +242,15 @@ public class HttpExchange switch (newStatus) { case STATUS_WAITING_FOR_RESPONSE: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onRequestCommitted(); break; case STATUS_CANCELLING: case STATUS_EXCEPTED: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onExpire(); break; } @@ -259,10 +261,10 @@ public class HttpExchange case STATUS_PARSING_HEADERS: case STATUS_CANCELLING: case STATUS_EXCEPTED: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onExpire(); break; } @@ -271,15 +273,15 @@ public class HttpExchange switch (newStatus) { case STATUS_PARSING_CONTENT: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onResponseHeaderComplete(); break; case STATUS_CANCELLING: case STATUS_EXCEPTED: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onExpire(); break; } @@ -288,15 +290,15 @@ public class HttpExchange switch (newStatus) { case STATUS_COMPLETED: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onResponseComplete(); break; case STATUS_CANCELLING: case STATUS_EXCEPTED: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) getEventListener().onExpire(); break; } @@ -307,12 +309,12 @@ public class HttpExchange case STATUS_START: case STATUS_EXCEPTED: case STATUS_WAITING_FOR_RESPONSE: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_CANCELLING: case STATUS_EXPIRED: // Don't change the status, it's too late - set=true; + set = true; break; } break; @@ -321,12 +323,12 @@ public class HttpExchange { case STATUS_EXCEPTED: case STATUS_CANCELLED: - if (set=_status.compareAndSet(oldStatus,newStatus)) + if (set = _status.compareAndSet(oldStatus,newStatus)) done(); break; default: // Ignore other statuses, we're cancelling - set=true; + set = true; break; } break; @@ -336,10 +338,10 @@ public class HttpExchange switch (newStatus) { case STATUS_START: - set=_status.compareAndSet(oldStatus,newStatus); + set = _status.compareAndSet(oldStatus,newStatus); break; default: - set=true; + set = true; break; } break; @@ -369,7 +371,7 @@ public class HttpExchange * @deprecated */ @Deprecated - public boolean isDone (int status) + public boolean isDone(int status) { return isDone(); } @@ -381,10 +383,10 @@ public class HttpExchange public void setEventListener(HttpEventListener listener) { - _listener=listener; + _listener = listener; } - public void setTimeout( long timeout ) + public void setTimeout(long timeout) { _timeout = timeout; } @@ -395,7 +397,8 @@ public class HttpExchange } /** - * @param url an absolute URL (for example 'http://localhost/foo/bar?a=1') + * @param url + * an absolute URL (for example 'http://localhost/foo/bar?a=1') */ public void setURL(String url) { @@ -403,7 +406,8 @@ public class HttpExchange } /** - * @param address the address of the server + * @param address + * the address of the server */ public void setAddress(Address address) { @@ -421,8 +425,7 @@ public class HttpExchange /** * the local address used by the connection * - * Note: this method will not be populated unless the exchange - * has been executed by the HttpClient + * Note: this method will not be populated unless the exchange has been executed by the HttpClient * * @return the local address used for the running of the exchange if available, null otherwise. */ @@ -432,15 +435,17 @@ public class HttpExchange } /** - * @param scheme the scheme of the URL (for example 'http') + * @param scheme + * the scheme of the URL (for example 'http') */ public void setScheme(Buffer scheme) { _scheme = scheme; } - + /** - * @param scheme the scheme of the URL (for example 'http') + * @param scheme + * the scheme of the URL (for example 'http') */ public void setScheme(String scheme) { @@ -464,7 +469,8 @@ public class HttpExchange } /** - * @param version the HTTP protocol version as integer, 9, 10 or 11 for 0.9, 1.0 or 1.1 + * @param version + * the HTTP protocol version as integer, 9, 10 or 11 for 0.9, 1.0 or 1.1 */ public void setVersion(int version) { @@ -472,7 +478,8 @@ public class HttpExchange } /** - * @param version the HTTP protocol version as string + * @param version + * the HTTP protocol version as string */ public void setVersion(String version) { @@ -493,7 +500,8 @@ public class HttpExchange } /** - * @param method the HTTP method (for example 'GET') + * @param method + * the HTTP method (for example 'GET') */ public void setMethod(String method) { @@ -528,9 +536,10 @@ public class HttpExchange } /** - * Set the request URI + * Set the request URI * - * @param uri new request URI + * @param uri + * new request URI * @see #setRequestURI(String) * @deprecated */ @@ -541,38 +550,41 @@ public class HttpExchange } /** - * Set the request URI + * Set the request URI * * Per RFC 2616 sec5, Request-URI = "*" | absoluteURI | abs_path | authority
    - * where:

    - * "*" - request applies to server itself
    + * where:
    + *
    + * "*" - request applies to server itself
    * absoluteURI - required for proxy requests, e.g. http://localhost:8080/context
    - * (this form is generated automatically by HttpClient)
    - * abs_path - used for most methods, e.g. /context
    - * authority - used for CONNECT method only, e.g. localhost:8080
    + * (this form is generated automatically by HttpClient)
    + * abs_path - used for most methods, e.g. /context
    + * authority - used for CONNECT method only, e.g. localhost:8080
    *
    * For complete definition of URI components, see RFC 2396 sec3.
    - * - * @param uri new request URI + * + * @param uri + * new request URI */ public void setRequestURI(String uri) { _uri = uri; } - + /* ------------------------------------------------------------ */ /** - * @param uri an absolute URI (for example 'http://localhost/foo/bar?a=1') + * @param uri + * an absolute URI (for example 'http://localhost/foo/bar?a=1') */ public void setURI(URI uri) { if (!uri.isAbsolute()) - throw new IllegalArgumentException("!Absolute URI: "+uri); - + throw new IllegalArgumentException("!Absolute URI: " + uri); + if (uri.isOpaque()) - throw new IllegalArgumentException("Opaque URI: "+uri); - - LOG.debug("URI = {}", uri.toASCIIString()); + throw new IllegalArgumentException("Opaque URI: " + uri); + + LOG.debug("URI = {}",uri.toASCIIString()); String scheme = uri.getScheme(); int port = uri.getPort(); @@ -584,13 +596,16 @@ public class HttpExchange HttpURI httpUri = new HttpURI(uri); String completePath = httpUri.getCompletePath(); - setRequestURI(completePath==null ? "/" : completePath); + setRequestURI(completePath == null?"/":completePath); } /** * Adds the specified request header - * @param name the header name - * @param value the header value + * + * @param name + * the header name + * @param value + * the header value */ public void addRequestHeader(String name, String value) { @@ -599,8 +614,11 @@ public class HttpExchange /** * Adds the specified request header - * @param name the header name - * @param value the header value + * + * @param name + * the header name + * @param value + * the header value */ public void addRequestHeader(Buffer name, Buffer value) { @@ -609,30 +627,37 @@ public class HttpExchange /** * Sets the specified request header - * @param name the header name - * @param value the header value + * + * @param name + * the header name + * @param value + * the header value */ public void setRequestHeader(String name, String value) { - getRequestFields().put(name, value); + getRequestFields().put(name,value); } /** * Sets the specified request header - * @param name the header name - * @param value the header value + * + * @param name + * the header name + * @param value + * the header value */ public void setRequestHeader(Buffer name, Buffer value) { - getRequestFields().put(name, value); + getRequestFields().put(name,value); } /** - * @param value the content type of the request + * @param value + * the content type of the request */ public void setRequestContentType(String value) { - getRequestFields().put(HttpHeaders.CONTENT_TYPE_BUFFER, value); + getRequestFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,value); } /** @@ -644,7 +669,8 @@ public class HttpExchange } /** - * @param requestContent the request content + * @param requestContent + * the request content */ public void setRequestContent(Buffer requestContent) { @@ -652,7 +678,8 @@ public class HttpExchange } /** - * @param stream the request content as a stream + * @param stream + * the request content as a stream */ public void setRequestContentSource(InputStream stream) { @@ -710,7 +737,8 @@ public class HttpExchange } /** - * @param retryStatus whether a retry will be attempted or not + * @param retryStatus + * whether a retry will be attempted or not */ public void setRetryStatus(boolean retryStatus) { @@ -718,13 +746,10 @@ public class HttpExchange } /** - * Initiates the cancelling of this exchange. - * The status of the exchange is set to {@link #STATUS_CANCELLING}. - * Cancelling the exchange is an asynchronous operation with respect to the request/response, - * and as such checking the request/response status of a cancelled exchange may return undefined results - * (for example it may have only some of the response headers being sent by the server). - * The cancelling of the exchange is completed when the exchange status (see {@link #getStatus()}) is - * {@link #STATUS_CANCELLED}, and this can be waited using {@link #waitForDone()}. + * Initiates the cancelling of this exchange. The status of the exchange is set to {@link #STATUS_CANCELLING}. Cancelling the exchange is an asynchronous + * operation with respect to the request/response, and as such checking the request/response status of a cancelled exchange may return undefined results + * (for example it may have only some of the response headers being sent by the server). The cancelling of the exchange is completed when the exchange + * status (see {@link #getStatus()}) is {@link #STATUS_CANCELLED}, and this can be waited using {@link #waitForDone()}. */ public void cancel() { @@ -734,10 +759,10 @@ public class HttpExchange private void done() { - synchronized(this) + synchronized (this) { disassociate(); - _onDone=true; + _onDone = true; notifyAll(); } } @@ -766,8 +791,8 @@ public class HttpExchange void associate(HttpConnection connection) { - if (connection.getEndPoint().getLocalHost() != null) - _localAddress = new Address(connection.getEndPoint().getLocalHost(), connection.getEndPoint().getLocalPort()); + if (connection.getEndPoint().getLocalHost() != null) + _localAddress = new Address(connection.getEndPoint().getLocalHost(),connection.getEndPoint().getLocalPort()); _connection = connection; if (getStatus() == STATUS_CANCELLING) @@ -791,34 +816,59 @@ public class HttpExchange public static String toState(int s) { String state; - switch(s) + switch (s) { - case STATUS_START: state="START"; break; - case STATUS_WAITING_FOR_CONNECTION: state="CONNECTING"; break; - case STATUS_WAITING_FOR_COMMIT: state="CONNECTED"; break; - case STATUS_SENDING_REQUEST: state="SENDING"; break; - case STATUS_WAITING_FOR_RESPONSE: state="WAITING"; break; - case STATUS_PARSING_HEADERS: state="HEADERS"; break; - case STATUS_PARSING_CONTENT: state="CONTENT"; break; - case STATUS_COMPLETED: state="COMPLETED"; break; - case STATUS_EXPIRED: state="EXPIRED"; break; - case STATUS_EXCEPTED: state="EXCEPTED"; break; - case STATUS_CANCELLING: state="CANCELLING"; break; - case STATUS_CANCELLED: state="CANCELLED"; break; - default: state="UNKNOWN"; + case STATUS_START: + state = "START"; + break; + case STATUS_WAITING_FOR_CONNECTION: + state = "CONNECTING"; + break; + case STATUS_WAITING_FOR_COMMIT: + state = "CONNECTED"; + break; + case STATUS_SENDING_REQUEST: + state = "SENDING"; + break; + case STATUS_WAITING_FOR_RESPONSE: + state = "WAITING"; + break; + case STATUS_PARSING_HEADERS: + state = "HEADERS"; + break; + case STATUS_PARSING_CONTENT: + state = "CONTENT"; + break; + case STATUS_COMPLETED: + state = "COMPLETED"; + break; + case STATUS_EXPIRED: + state = "EXPIRED"; + break; + case STATUS_EXCEPTED: + state = "EXCEPTED"; + break; + case STATUS_CANCELLING: + state = "CANCELLING"; + break; + case STATUS_CANCELLED: + state = "CANCELLED"; + break; + default: + state = "UNKNOWN"; } return state; } - + @Override public String toString() { - String state=toState(getStatus()); - long now=System.currentTimeMillis(); - long forMs = now -_lastStateChange; - String s= String.format("%s@%x=%s//%s%s#%s(%dms)",getClass().getSimpleName(),hashCode(),_method,_address,_uri,state,forMs); - if (getStatus()>=STATUS_SENDING_REQUEST) - s+="sent="+(now-_sent)+"ms"; + String state = toState(getStatus()); + long now = System.currentTimeMillis(); + long forMs = now - _lastStateChange; + String s = String.format("%s@%x=%s//%s%s#%s(%dms)",getClass().getSimpleName(),hashCode(),_method,_address,_uri,state,forMs); + if (getStatus() >= STATUS_SENDING_REQUEST) + s += "sent=" + (now - _sent) + "ms"; return s; } @@ -830,79 +880,93 @@ public class HttpExchange } /** - * Callback called when the request headers have been sent to the server. - * This implementation does nothing. - * @throws IOException allowed to be thrown by overriding code + * Callback called when the request headers have been sent to the server. This implementation does nothing. + * + * @throws IOException + * allowed to be thrown by overriding code */ protected void onRequestCommitted() throws IOException { } /** - * Callback called when the request and its body have been sent to the server. - * This implementation does nothing. - * @throws IOException allowed to be thrown by overriding code + * Callback called when the request and its body have been sent to the server. This implementation does nothing. + * + * @throws IOException + * allowed to be thrown by overriding code */ protected void onRequestComplete() throws IOException { } /** - * Callback called when a response status line has been received from the server. - * This implementation does nothing. - * @param version the HTTP version - * @param status the HTTP status code - * @param reason the HTTP status reason string - * @throws IOException allowed to be thrown by overriding code + * Callback called when a response status line has been received from the server. This implementation does nothing. + * + * @param version + * the HTTP version + * @param status + * the HTTP status code + * @param reason + * the HTTP status reason string + * @throws IOException + * allowed to be thrown by overriding code */ protected void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException { } /** - * Callback called for each response header received from the server. - * This implementation does nothing. - * @param name the header name - * @param value the header value - * @throws IOException allowed to be thrown by overriding code + * Callback called for each response header received from the server. This implementation does nothing. + * + * @param name + * the header name + * @param value + * the header value + * @throws IOException + * allowed to be thrown by overriding code */ protected void onResponseHeader(Buffer name, Buffer value) throws IOException { } /** - * Callback called when the response headers have been completely received from the server. - * This implementation does nothing. - * @throws IOException allowed to be thrown by overriding code + * Callback called when the response headers have been completely received from the server. This implementation does nothing. + * + * @throws IOException + * allowed to be thrown by overriding code */ protected void onResponseHeaderComplete() throws IOException { } /** - * Callback called for each chunk of the response content received from the server. - * This implementation does nothing. - * @param content the buffer holding the content chunk - * @throws IOException allowed to be thrown by overriding code + * Callback called for each chunk of the response content received from the server. This implementation does nothing. + * + * @param content + * the buffer holding the content chunk + * @throws IOException + * allowed to be thrown by overriding code */ protected void onResponseContent(Buffer content) throws IOException { } /** - * Callback called when the entire response has been received from the server - * This implementation does nothing. - * @throws IOException allowed to be thrown by overriding code + * Callback called when the entire response has been received from the server This implementation does nothing. + * + * @throws IOException + * allowed to be thrown by overriding code */ protected void onResponseComplete() throws IOException { } /** - * Callback called when an exception was thrown during an attempt to establish the connection - * with the server (for example the server is not listening). + * Callback called when an exception was thrown during an attempt to establish the connection with the server (for example the server is not listening). * This implementation logs a warning. - * @param x the exception thrown attempting to establish the connection with the server + * + * @param x + * the exception thrown attempting to establish the connection with the server */ protected void onConnectionFailed(Throwable x) { @@ -910,9 +974,10 @@ public class HttpExchange } /** - * Callback called when any other exception occurs during the handling of this exchange. - * This implementation logs a warning. - * @param x the exception thrown during the handling of this exchange + * Callback called when any other exception occurs during the handling of this exchange. This implementation logs a warning. + * + * @param x + * the exception thrown during the handling of this exchange */ protected void onException(Throwable x) { @@ -920,8 +985,7 @@ public class HttpExchange } /** - * Callback called when no response has been received within the timeout. - * This implementation logs a warning. + * Callback called when no response has been received within the timeout. This implementation logs a warning. */ protected void onExpire() { @@ -929,9 +993,10 @@ public class HttpExchange } /** - * Callback called when the request is retried (due to failures or authentication). - * Implementations must reset any consumable content that needs to be sent. - * @throws IOException allowed to be thrown by overriding code + * Callback called when the request is retried (due to failures or authentication). Implementations must reset any consumable content that needs to be sent. + * + * @throws IOException + * allowed to be thrown by overriding code */ protected void onRetry() throws IOException { @@ -950,8 +1015,7 @@ public class HttpExchange } /** - * @return true if the exchange should have listeners configured for it by the destination, - * false if this is being managed elsewhere + * @return true if the exchange should have listeners configured for it by the destination, false if this is being managed elsewhere * @see #setConfigureListeners(boolean) */ public boolean configureListeners() @@ -960,7 +1024,8 @@ public class HttpExchange } /** - * @param autoConfigure whether the listeners are configured by the destination or elsewhere + * @param autoConfigure + * whether the listeners are configured by the destination or elsewhere */ public void setConfigureListeners(boolean autoConfigure) { @@ -983,7 +1048,7 @@ public class HttpExchange HttpClient httpClient = destination.getHttpClient(); long timeout = getTimeout(); if (timeout > 0) - httpClient.schedule(_timeoutTask, timeout); + httpClient.schedule(_timeoutTask,timeout); else httpClient.schedule(_timeoutTask); } @@ -1047,7 +1112,7 @@ public class HttpExchange } finally { - synchronized(HttpExchange.this) + synchronized (HttpExchange.this) { _onRequestCompleteDone = true; // Member _onDone may already be true, for example @@ -1068,7 +1133,7 @@ public class HttpExchange } finally { - synchronized(HttpExchange.this) + synchronized (HttpExchange.this) { _onResponseCompleteDone = true; // Member _onDone may already be true, for example @@ -1103,7 +1168,7 @@ public class HttpExchange public void onRetry() { - HttpExchange.this.setRetryStatus( true ); + HttpExchange.this.setRetryStatus(true); try { HttpExchange.this.onRetry(); From 1e5b85a2cb459873b5e7b1ded145b05fd3889ace Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Wed, 28 Sep 2011 17:25:46 +0200 Subject: [PATCH 109/134] 359255: Allow HttpExchange state change from START to EXPIRED --- .../eclipse/jetty/client/HttpExchange.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java index 9f431e51e74..e3e07a187b5 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java @@ -208,6 +208,9 @@ public class HttpExchange case STATUS_EXCEPTED: set = _status.compareAndSet(oldStatus,newStatus); break; + case STATUS_EXPIRED: + set = setStatusExpired(newStatus,oldStatus); + break; } break; case STATUS_WAITING_FOR_CONNECTION: @@ -219,8 +222,7 @@ public class HttpExchange set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set = _status.compareAndSet(oldStatus,newStatus)) - getEventListener().onExpire(); + set = setStatusExpired(newStatus,oldStatus); break; } break; @@ -233,8 +235,7 @@ public class HttpExchange set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set = _status.compareAndSet(oldStatus,newStatus)) - getEventListener().onExpire(); + set = setStatusExpired(newStatus,oldStatus); break; } break; @@ -250,8 +251,7 @@ public class HttpExchange set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set = _status.compareAndSet(oldStatus,newStatus)) - getEventListener().onExpire(); + set = setStatusExpired(newStatus,oldStatus); break; } break; @@ -264,8 +264,7 @@ public class HttpExchange set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set = _status.compareAndSet(oldStatus,newStatus)) - getEventListener().onExpire(); + set = setStatusExpired(newStatus,oldStatus); break; } break; @@ -281,8 +280,7 @@ public class HttpExchange set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set = _status.compareAndSet(oldStatus,newStatus)) - getEventListener().onExpire(); + set = setStatusExpired(newStatus,oldStatus); break; } break; @@ -298,8 +296,7 @@ public class HttpExchange set = _status.compareAndSet(oldStatus,newStatus); break; case STATUS_EXPIRED: - if (set = _status.compareAndSet(oldStatus,newStatus)) - getEventListener().onExpire(); + set = setStatusExpired(newStatus,oldStatus); break; } break; @@ -359,6 +356,14 @@ public class HttpExchange } } + private boolean setStatusExpired(int newStatus, int oldStatus) + { + boolean set; + if (set = _status.compareAndSet(oldStatus,newStatus)) + getEventListener().onExpire(); + return set; + } + public boolean isDone() { synchronized (this) From af698b00235cd95d4ed216962226db742fa8a6a7 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 28 Sep 2011 14:38:14 -0500 Subject: [PATCH 110/134] Add a ResourceHandler test, we seem to be missing even a basic one --- .../server/handler/ResourceHandlerTest.java | 76 +++++++++++++++++++ .../src/test/resources/simple/simple.txt | 1 + 2 files changed, 77 insertions(+) create mode 100644 jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java create mode 100644 jetty-server/src/test/resources/simple/simple.txt diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java new file mode 100644 index 00000000000..91681b321f7 --- /dev/null +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java @@ -0,0 +1,76 @@ +package org.eclipse.jetty.server.handler; +//======================================================================== +//Copyright (c) 1999-2009 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. +//======================================================================== + +import java.net.URI; + +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.bio.SocketConnector; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.toolchain.test.SimpleRequest; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import junit.framework.Assert; +import junit.framework.TestCase; + +/** + * Resource Handler test + * + * TODO: increase the testing going on here + */ +public class ResourceHandlerTest extends TestCase +{ + private static Server _server; + private static Connector _connector; + private static ContextHandler _contextHandler; + private static ResourceHandler _resourceHandler; + + + @BeforeClass + public void setUp() throws Exception + { + _server = new Server(); + _connector = new SocketConnector(); + _server.setConnectors(new Connector[] { _connector }); + + _resourceHandler = new ResourceHandler(); + + _contextHandler = new ContextHandler("/resource"); + _contextHandler.setHandler(_resourceHandler); + _server.setHandler(_contextHandler); + _server.start(); + } + + /* ------------------------------------------------------------ */ + @AfterClass + public void tearDown() throws Exception + { + _server.stop(); + } + + @Test + public void testSimpleResourceHandler() throws Exception + { + _resourceHandler.setResourceBase(MavenTestingUtils.getTestResourceDir("simple").getAbsolutePath()); + + SimpleRequest sr = new SimpleRequest(new URI("http://localhost:" + _connector.getLocalPort())); + + Assert.assertEquals("simple text", sr.getString("/resource/simple.txt")); + + Assert.assertNotNull("missing jetty.css" , sr.getString("/resource/jetty-dir.css")); + } + +} diff --git a/jetty-server/src/test/resources/simple/simple.txt b/jetty-server/src/test/resources/simple/simple.txt new file mode 100644 index 00000000000..f2403aead5a --- /dev/null +++ b/jetty-server/src/test/resources/simple/simple.txt @@ -0,0 +1 @@ +simple text \ No newline at end of file From e7af27ad340a5888bf816a4aad11b3d2e43f01ec Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 28 Sep 2011 16:16:09 -0500 Subject: [PATCH 111/134] [Bug 359309] add unit tests showing the problem, 1/4 pass right now, the 3 failing are marked @Ignore for now. --- .../eclipse/jetty/servlet/DispatcherTest.java | 157 +++++++++++++++--- .../dispatchResourceTest/content.txt | 1 + 2 files changed, 139 insertions(+), 19 deletions(-) create mode 100644 jetty-servlet/src/test/resources/dispatchResourceTest/content.txt diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index e2d8694939f..967ecc7849c 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -14,27 +14,39 @@ package org.eclipse.jetty.servlet; import java.io.IOException; +import java.io.PrintWriter; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.servlet.GenericServlet; import javax.servlet.RequestDispatcher; import javax.servlet.Servlet; +import javax.servlet.ServletContext; import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; import javax.servlet.ServletRequest; import javax.servlet.ServletRequestWrapper; import javax.servlet.ServletResponse; import javax.servlet.ServletResponseWrapper; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; import org.eclipse.jetty.server.Dispatcher; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.handler.ContextHandler; +import org.eclipse.jetty.server.handler.ContextHandlerCollection; +import org.eclipse.jetty.server.handler.ResourceHandler; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -44,17 +56,27 @@ public class DispatcherTest { private Server _server; private LocalConnector _connector; - private ServletContextHandler _context; - + private ContextHandlerCollection _contextCollection; + private ServletContextHandler _contextHandler; + private ResourceHandler _resourceHandler; + @Before public void init() throws Exception { _server = new Server(); _server.setSendServerVersion(false); _connector = new LocalConnector(); - _context = new ServletContextHandler(); - _context.setContextPath("/context"); - _server.setHandler(_context); + + _contextCollection = new ContextHandlerCollection(); + _contextHandler = new ServletContextHandler(); + _contextHandler.setContextPath("/context"); + _contextCollection.addHandler(_contextHandler); + _resourceHandler = new ResourceHandler(); + _resourceHandler.setResourceBase(MavenTestingUtils.getTestResourceDir("dispatchResourceTest").getAbsolutePath()); + ContextHandler resourceContextHandler = new ContextHandler("/resource"); + resourceContextHandler.setHandler(_resourceHandler); + _contextCollection.addHandler(resourceContextHandler); + _server.setHandler(_contextCollection); _server.addConnector( _connector ); _server.start(); @@ -70,8 +92,8 @@ public class DispatcherTest @Test public void testForward() throws Exception { - _context.addServlet(ForwardServlet.class, "/ForwardServlet/*"); - _context.addServlet(AssertForwardServlet.class, "/AssertForwardServlet/*"); + _contextHandler.addServlet(ForwardServlet.class, "/ForwardServlet/*"); + _contextHandler.addServlet(AssertForwardServlet.class, "/AssertForwardServlet/*"); String expected= "HTTP/1.1 200 OK\r\n"+ @@ -87,8 +109,8 @@ public class DispatcherTest @Test public void testInclude() throws Exception { - _context.addServlet(IncludeServlet.class, "/IncludeServlet/*"); - _context.addServlet(AssertIncludeServlet.class, "/AssertIncludeServlet/*"); + _contextHandler.addServlet(IncludeServlet.class, "/IncludeServlet/*"); + _contextHandler.addServlet(AssertIncludeServlet.class, "/AssertIncludeServlet/*"); String expected= "HTTP/1.1 200 OK\r\n"+ @@ -103,9 +125,9 @@ public class DispatcherTest @Test public void testForwardThenInclude() throws Exception { - _context.addServlet(ForwardServlet.class, "/ForwardServlet/*"); - _context.addServlet(IncludeServlet.class, "/IncludeServlet/*"); - _context.addServlet(AssertForwardIncludeServlet.class, "/AssertForwardIncludeServlet/*"); + _contextHandler.addServlet(ForwardServlet.class, "/ForwardServlet/*"); + _contextHandler.addServlet(IncludeServlet.class, "/IncludeServlet/*"); + _contextHandler.addServlet(AssertForwardIncludeServlet.class, "/AssertForwardIncludeServlet/*"); String expected= "HTTP/1.1 200 OK\r\n"+ @@ -120,9 +142,9 @@ public class DispatcherTest @Test public void testIncludeThenForward() throws Exception { - _context.addServlet(IncludeServlet.class, "/IncludeServlet/*"); - _context.addServlet(ForwardServlet.class, "/ForwardServlet/*"); - _context.addServlet(AssertIncludeForwardServlet.class, "/AssertIncludeForwardServlet/*"); + _contextHandler.addServlet(IncludeServlet.class, "/IncludeServlet/*"); + _contextHandler.addServlet(ForwardServlet.class, "/ForwardServlet/*"); + _contextHandler.addServlet(AssertIncludeForwardServlet.class, "/AssertIncludeForwardServlet/*"); String expected= @@ -140,8 +162,8 @@ public class DispatcherTest @Test public void testServletForward() throws Exception { - _context.addServlet(DispatchServletServlet.class, "/dispatch/*"); - _context.addServlet(RogerThatServlet.class, "/roger/*"); + _contextHandler.addServlet(DispatchServletServlet.class, "/dispatch/*"); + _contextHandler.addServlet(RogerThatServlet.class, "/roger/*"); String expected= "HTTP/1.1 200 OK\r\n"+ @@ -157,8 +179,8 @@ public class DispatcherTest @Test public void testServletInclude() throws Exception { - _context.addServlet(DispatchServletServlet.class, "/dispatch/*"); - _context.addServlet(RogerThatServlet.class, "/roger/*"); + _contextHandler.addServlet(DispatchServletServlet.class, "/dispatch/*"); + _contextHandler.addServlet(RogerThatServlet.class, "/roger/*"); String expected= "HTTP/1.1 200 OK\r\n"+ @@ -171,6 +193,61 @@ public class DispatcherTest assertEquals(expected, responses); } + @Test + public void testWorkingResourceHandler() throws Exception + { + String responses = _connector.getResponses("GET /resource/content.txt HTTP/1.0\n" + "Host: localhost\n\n"); + + assertTrue(responses.contains("content goes here")); // from inside the context.txt file + } + + @Test + @Ignore("currently fails") + public void testIncludeToResourceHandler() throws Exception + { + _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); + + String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?type=include HTTP/1.0\n" + "Host: localhost\n\n"); + + // from inside the context.txt file + assertTrue(responses.contains("content goes here")); + } + + @Test + public void testForwardToResourceHandler() throws Exception + { + _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); + + String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?type=forward HTTP/1.0\n" + "Host: localhost\n\n"); + + // from inside the context.txt file + assertTrue(responses.contains("content goes here")); + } + + @Test + @Ignore("currently fails") + public void testWrappedIncludeToResourceHandler() throws Exception + { + _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); + + String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?type=include&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n"); + + // from inside the context.txt file + assertTrue(responses.contains("content goes here")); + } + + @Test + @Ignore("currently fails") + public void testWrappedForwardToResourceHandler() throws Exception + { + _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); + + String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?type=forward&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n"); + + // from inside the context.txt file + assertTrue(responses.contains("content goes here")); + } + public static class ForwardServlet extends HttpServlet implements Servlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException @@ -230,6 +307,48 @@ public class DispatcherTest } } + public static class DispatchToResourceServlet extends HttpServlet implements Servlet + { + @Override + public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException + { + ServletContext targetContext = getServletConfig().getServletContext().getContext("/resource"); + + RequestDispatcher dispatcher = targetContext.getRequestDispatcher(req.getPathInfo()); + + if ( "true".equals(req.getParameter("wrapped"))) + { + if (req.getParameter("type").equals("forward")) + { + dispatcher.forward(new ServletRequestWrapper(req),new ServletResponseWrapper(res)); + } + else if (req.getParameter("type").equals("include")) + { + dispatcher.include(new ServletRequestWrapper(req),new ServletResponseWrapper(res)); + } + else + { + throw new ServletException("type of forward or include is required"); + } + } + else + { + if (req.getParameter("type").equals("forward")) + { + dispatcher.forward(req,res); + } + else if (req.getParameter("type").equals("include")) + { + dispatcher.include(req,res); + } + else + { + throw new ServletException("type of forward or include is required"); + } + } + } + } + public static class AssertForwardServlet extends HttpServlet implements Servlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException diff --git a/jetty-servlet/src/test/resources/dispatchResourceTest/content.txt b/jetty-servlet/src/test/resources/dispatchResourceTest/content.txt new file mode 100644 index 00000000000..815d4403267 --- /dev/null +++ b/jetty-servlet/src/test/resources/dispatchResourceTest/content.txt @@ -0,0 +1 @@ +content goes here \ No newline at end of file From f45a72004572bbf5ec17f1d4939572e9c5b2beb4 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 29 Sep 2011 08:06:51 +1000 Subject: [PATCH 112/134] 357240 debug client tests --- .../java/org/eclipse/jetty/client/HttpExchangeTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index 8c681388a0e..e36828c17fc 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -51,7 +51,7 @@ import org.junit.Test; */ public class HttpExchangeTest { - final static boolean verbose=false; + final static boolean verbose=true; protected static int _maxConnectionsPerAddress = 2; protected static String _scheme = "http"; protected static Server _server; @@ -264,7 +264,11 @@ public class HttpExchangeTest _httpClient.send(httpExchange[n]); } - assertTrue(complete.await(45,TimeUnit.SECONDS)); + Thread.sleep(2000); + System.err.println(_httpClient.dump()); + + assertTrue(complete.await(10,TimeUnit.SECONDS)); + long elapsed=System.currentTimeMillis()-start; From f14bbbfc0a3c384e48c8701174c669251bd70aa7 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 29 Sep 2011 08:17:23 +1000 Subject: [PATCH 113/134] fixed bad merge --- .../main/java/org/eclipse/jetty/client/HttpExchange.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java index 026b275f361..6840adcabd2 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java @@ -110,17 +110,10 @@ public class HttpExchange // a timeout for this exchange private long _timeout = -1; private volatile Timeout.Task _timeoutTask; -<<<<<<< HEAD - private long _lastStateChange=System.currentTimeMillis(); private long _sent=-1; private int _lastState=-1; private int _lastStatePeriod=-1; -======= - - private long _lastStateChange = -1; - private long _sent = -1; ->>>>>>> master boolean _onRequestCompleteDone; boolean _onResponseCompleteDone; From 45e6cfa790ad978d489f3ea68a493fcd32dc30ba Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 28 Sep 2011 18:02:27 -0500 Subject: [PATCH 114/134] [Bug 359309] fix unit test to use HttpServlet*Wrappers and reformat the resourcehandler a bit to debug last two issues --- .../jetty/server/handler/ResourceHandler.java | 20 ++++++++----- .../eclipse/jetty/servlet/DispatcherTest.java | 30 +++++++++++-------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 1d3f196c127..8372e64450c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -295,15 +295,15 @@ public class ResourceHandler extends AbstractHandler { String servletPath; String pathInfo; - Boolean included =request.getAttribute(Dispatcher.INCLUDE_REQUEST_URI)!=null; - if (included!=null && included.booleanValue()) + Boolean included = request.getAttribute(Dispatcher.INCLUDE_REQUEST_URI) != null; + if (included != null && included.booleanValue()) { - servletPath=(String)request.getAttribute(Dispatcher.INCLUDE_SERVLET_PATH); - pathInfo=(String)request.getAttribute(Dispatcher.INCLUDE_PATH_INFO); - if (servletPath==null) + servletPath = (String)request.getAttribute(Dispatcher.INCLUDE_SERVLET_PATH); + pathInfo = (String)request.getAttribute(Dispatcher.INCLUDE_PATH_INFO); + if (servletPath == null) { - servletPath=request.getServletPath(); - pathInfo=request.getPathInfo(); + servletPath = request.getServletPath(); + pathInfo = request.getPathInfo(); } } else @@ -312,7 +312,7 @@ public class ResourceHandler extends AbstractHandler servletPath = request.getServletPath(); pathInfo = request.getPathInfo(); } - + String pathInContext=URIUtil.addPaths(servletPath,pathInfo); return getResource(pathInContext); } @@ -353,14 +353,18 @@ public class ResourceHandler extends AbstractHandler return; boolean skipContentBody = false; + if(!HttpMethods.GET.equals(request.getMethod())) { if(!HttpMethods.HEAD.equals(request.getMethod())) + { return; + } skipContentBody = true; } Resource resource = getResource(request); + if (resource==null || !resource.exists()) { if (target.endsWith("/jetty-dir.css")) diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index 967ecc7849c..871bd7da6c6 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -37,6 +37,8 @@ import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; +import junit.framework.Assert; + import org.eclipse.jetty.server.Dispatcher; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Server; @@ -202,14 +204,17 @@ public class DispatcherTest } @Test - @Ignore("currently fails") + @Ignore("failing") public void testIncludeToResourceHandler() throws Exception { _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); - String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?type=include HTTP/1.0\n" + "Host: localhost\n\n"); + String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?do=include HTTP/1.0\n" + "Host: localhost\n\n"); // from inside the context.txt file + Assert.assertNotNull(responses); + + System.out.println(responses); assertTrue(responses.contains("content goes here")); } @@ -218,31 +223,30 @@ public class DispatcherTest { _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); - String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?type=forward HTTP/1.0\n" + "Host: localhost\n\n"); + String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?do=forward HTTP/1.0\n" + "Host: localhost\n\n"); // from inside the context.txt file assertTrue(responses.contains("content goes here")); } @Test - @Ignore("currently fails") + @Ignore("failing") public void testWrappedIncludeToResourceHandler() throws Exception { _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); - String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?type=include&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n"); + String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?do=include&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n"); // from inside the context.txt file assertTrue(responses.contains("content goes here")); } @Test - @Ignore("currently fails") public void testWrappedForwardToResourceHandler() throws Exception { _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); - String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?type=forward&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n"); + String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?do=forward&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n"); // from inside the context.txt file assertTrue(responses.contains("content goes here")); @@ -318,13 +322,13 @@ public class DispatcherTest if ( "true".equals(req.getParameter("wrapped"))) { - if (req.getParameter("type").equals("forward")) + if (req.getParameter("do").equals("forward")) { - dispatcher.forward(new ServletRequestWrapper(req),new ServletResponseWrapper(res)); + dispatcher.forward(new HttpServletRequestWrapper(req),new HttpServletResponseWrapper(res)); } - else if (req.getParameter("type").equals("include")) + else if (req.getParameter("do").equals("include")) { - dispatcher.include(new ServletRequestWrapper(req),new ServletResponseWrapper(res)); + dispatcher.include(new HttpServletRequestWrapper(req),new HttpServletResponseWrapper(res)); } else { @@ -333,11 +337,11 @@ public class DispatcherTest } else { - if (req.getParameter("type").equals("forward")) + if (req.getParameter("do").equals("forward")) { dispatcher.forward(req,res); } - else if (req.getParameter("type").equals("include")) + else if (req.getParameter("do").equals("include")) { dispatcher.include(req,res); } From 7ecea5afd05f9927b8f0e45a0355f8ae7bd32f13 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 28 Sep 2011 18:30:20 -0500 Subject: [PATCH 115/134] [Bug 359309] resolve include and forward issues related to resource handler --- .../jetty/server/handler/ResourceHandler.java | 22 +++++++++---------- .../eclipse/jetty/servlet/DispatcherTest.java | 2 -- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 8372e64450c..4f9126c8ad1 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -293,28 +293,28 @@ public class ResourceHandler extends AbstractHandler /* ------------------------------------------------------------ */ protected Resource getResource(HttpServletRequest request) throws MalformedURLException { - String servletPath; String pathInfo; Boolean included = request.getAttribute(Dispatcher.INCLUDE_REQUEST_URI) != null; if (included != null && included.booleanValue()) { - servletPath = (String)request.getAttribute(Dispatcher.INCLUDE_SERVLET_PATH); + /* + On an include there is no servletPath, nor do we want to look for one + as the resource handler is outside of the servlet contexts so there is + no special servlet handler that manages this value. + we expect a null in Dispatcher.INCLUDE_SERVLET_PATH + + String servletPath = (String)request.getAttribute(Dispatcher.INCLUDE_SERVLET_PATH); + assert servletPath == null; + */ pathInfo = (String)request.getAttribute(Dispatcher.INCLUDE_PATH_INFO); - if (servletPath == null) - { - servletPath = request.getServletPath(); - pathInfo = request.getPathInfo(); - } } else { included = Boolean.FALSE; - servletPath = request.getServletPath(); pathInfo = request.getPathInfo(); } - - String pathInContext=URIUtil.addPaths(servletPath,pathInfo); - return getResource(pathInContext); + + return getResource(pathInfo); } diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index 871bd7da6c6..ce5b326ec01 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -204,7 +204,6 @@ public class DispatcherTest } @Test - @Ignore("failing") public void testIncludeToResourceHandler() throws Exception { _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); @@ -230,7 +229,6 @@ public class DispatcherTest } @Test - @Ignore("failing") public void testWrappedIncludeToResourceHandler() throws Exception { _contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*"); From 3dc0120d573816de7d6a83e2d6a97035288bdd4a Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Wed, 28 Sep 2011 18:43:43 -0500 Subject: [PATCH 116/134] [Bug 359309] adjust previous test for servletPath to include pathInfo --- .../jetty/server/handler/ResourceHandler.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 4f9126c8ad1..04a6ff9566e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -293,28 +293,29 @@ public class ResourceHandler extends AbstractHandler /* ------------------------------------------------------------ */ protected Resource getResource(HttpServletRequest request) throws MalformedURLException { + String servletPath; String pathInfo; Boolean included = request.getAttribute(Dispatcher.INCLUDE_REQUEST_URI) != null; if (included != null && included.booleanValue()) { - /* - On an include there is no servletPath, nor do we want to look for one - as the resource handler is outside of the servlet contexts so there is - no special servlet handler that manages this value. - we expect a null in Dispatcher.INCLUDE_SERVLET_PATH - - String servletPath = (String)request.getAttribute(Dispatcher.INCLUDE_SERVLET_PATH); - assert servletPath == null; - */ + servletPath = (String)request.getAttribute(Dispatcher.INCLUDE_SERVLET_PATH); pathInfo = (String)request.getAttribute(Dispatcher.INCLUDE_PATH_INFO); + + if (servletPath == null && pathInfo == null) + { + servletPath = request.getServletPath(); + pathInfo = request.getPathInfo(); + } } else { included = Boolean.FALSE; + servletPath = request.getServletPath(); pathInfo = request.getPathInfo(); } - return getResource(pathInfo); + String pathInContext=URIUtil.addPaths(servletPath,pathInfo); + return getResource(pathInContext); } From d0a2557527ed7d660ee22f10741ec8d245008ede Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 29 Sep 2011 15:50:09 +1000 Subject: [PATCH 117/134] 357240 fixed client connection recycle --- .../eclipse/jetty/client/HttpConnection.java | 16 ++++++++- .../eclipse/jetty/client/HttpDestination.java | 2 +- .../client/AsyncSslHttpExchangeTest.java | 9 ++--- .../jetty/client/HttpExchangeTest.java | 34 ++++++------------- .../org/eclipse/jetty/http/HttpParser.java | 24 +++++++------ .../jetty/io/nio/SelectChannelEndPoint.java | 2 -- .../eclipse/jetty/io/nio/SelectorManager.java | 1 + .../jetty/server/BlockingHttpConnection.java | 3 +- .../eclipse/jetty/server/LocalConnector.java | 9 +++++ .../jetty/server/bio/SocketConnector.java | 7 ++++ 10 files changed, 60 insertions(+), 47 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java index 7fad3b9dcca..d2d2423b003 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java @@ -353,6 +353,20 @@ public class HttpConnection extends AbstractConnection implements Dumpable complete = true; } } + + // if the endpoint is closed, but the parser incomplete + if (!_endp.isOpen() && !(_parser.isComplete()||_parser.isIdle())) + { + // we wont be called again so let the parser see the close + complete=true; + _parser.parseAvailable(); + if (!(_parser.isComplete()||_parser.isIdle())) + { + LOG.warn("Incomplete {} {}",_parser,_endp); + if (_exchange!=null) + _exchange.cancel(); + } + } } /* TODO - is this needed ? @@ -435,7 +449,7 @@ public class HttpConnection extends AbstractConnection implements Dumpable _parser.returnBuffers(); // Do we have more stuff to write? - if (!_generator.isComplete() && _generator.getBytesBuffered()>0 && _endp instanceof AsyncEndPoint) + if (!_generator.isComplete() && _generator.getBytesBuffered()>0 && _endp.isOpen() && _endp instanceof AsyncEndPoint) { // Assume we are write blocked! ((AsyncEndPoint)_endp).scheduleWrite(); 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 6d243383db4..9d7723b2b1b 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 @@ -584,7 +584,7 @@ public class HttpDestination implements Dumpable @Override public synchronized String toString() { - return "HttpDestination@" + hashCode() + "//" + _address.getHost() + ":" + _address.getPort() + "(" + _connections.size() + "," + _idle.size() + "," + _queue.size() + ")"; + return String.format("HttpDestination@%x//%s:%d(%d/%d,%d,%d/%d)%n",hashCode(),_address.getHost(),_address.getPort(),_connections.size(),_maxConnections,_idle.size(),_queue.size(),_maxQueueSize); } public synchronized String toDetailString() diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java index ce9dd9654fc..9cef46582f1 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AsyncSslHttpExchangeTest.java @@ -32,17 +32,12 @@ public class AsyncSslHttpExchangeTest extends SslHttpExchangeTest _port = _server.getConnectors()[0].getLocalPort(); } - @Override - public void testPerf() throws Exception - { - super.testPerf(); - } - @Test public void testPerf1() throws Exception { - sender(1,true); + sender(10,true); } + } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java index e36828c17fc..3b84bfec975 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java @@ -51,7 +51,7 @@ import org.junit.Test; */ public class HttpExchangeTest { - final static boolean verbose=true; + final static boolean verbose=false; protected static int _maxConnectionsPerAddress = 2; protected static String _scheme = "http"; protected static Server _server; @@ -105,6 +105,8 @@ public class HttpExchangeTest { sender(1,false); sender(1,true); + sender(10,false); + sender(10,true); if (Stress.isEnabled()) { @@ -113,11 +115,6 @@ public class HttpExchangeTest sender(10000,false); sender(10000,true); } - else - { - sender(10,false); - sender(10,true); - } } /* ------------------------------------------------------------ */ @@ -130,7 +127,7 @@ public class HttpExchangeTest { _count.set(0); final CountDownLatch complete = new CountDownLatch(nb); - final CountDownLatch latch = new CountDownLatch(nb); + final AtomicInteger allcontent = new AtomicInteger(nb); HttpExchange[] httpExchange = new HttpExchange[nb]; long start = System.currentTimeMillis(); for (int i = 0; i < nb; i++) @@ -201,14 +198,12 @@ public class HttpExchangeTest protected void onResponseComplete() { if (verbose) - System.err.println("] =="); + System.err.println("] == "+len+" "+complete.getCount()+"/"+nb); result = "complete"; if (len == 2009) - latch.countDown(); + allcontent.decrementAndGet(); else - { System.err.println(n + " ONLY " + len+ "/2009"); - } complete.countDown(); } @@ -263,22 +258,13 @@ public class HttpExchangeTest _httpClient.send(httpExchange[n]); } - - Thread.sleep(2000); - System.err.println(_httpClient.dump()); - assertTrue(complete.await(10,TimeUnit.SECONDS)); - - - long elapsed=System.currentTimeMillis()-start; + if (!complete.await(2,TimeUnit.SECONDS)) + System.err.println(_httpClient.dump()); - // make windows-friendly ... System.currentTimeMillis() on windows is dope! - /* - if(elapsed>0) - System.err.println(nb+"/"+_count+" c="+close+" rate="+(nb*1000/elapsed)); - */ + assertTrue(complete.await(20,TimeUnit.SECONDS)); - assertEquals("nb="+nb+" close="+close,0,latch.getCount()); + assertEquals("nb="+nb+" close="+close,0,allcontent.get()); } /* ------------------------------------------------------------ */ diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 9194d6b1242..46c8f30cc80 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -266,7 +266,17 @@ public class HttpParser implements Parser // Fill buffer if we can if (length == 0) { - long filled=fill(); + long filled=-1; + IOException ex=null; + try + { + filled=fill(); + } + catch(IOException e) + { + LOG.debug(this.toString(),e); + ex=e; + } if (filled < 0 || _endp.isInputShutdown()) { @@ -291,6 +301,8 @@ public class HttpParser implements Parser return 1; } + if (ex!=null) + throw ex; return -1; } length=_buffer.length(); @@ -927,15 +939,7 @@ public class HttpParser implements Parser if (_buffer.space() == 0) throw new HttpException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413, "FULL "+(_buffer==_body?"body":"head")); - try - { - return _endp.fill(_buffer); - } - catch(IOException e) - { - LOG.debug(e); - throw (e instanceof EofException) ? e:new EofException(e); - } + return _endp.fill(_buffer); } return -1; diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 5682507cadc..06bd0fd7114 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -539,9 +539,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo cancelIdle(); if (_open) - { _selectSet.destroyEndPoint(this); - } _open=false; _key = null; } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index 56720f4a9d3..507fad0fa8a 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -845,6 +845,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa /* ------------------------------------------------------------ */ public void destroyEndPoint(SelectChannelEndPoint endp) { + LOG.debug("destroyEndPoint {}",endp); _endPoints.remove(endp); endPointClosed(endp); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java index a6e040f77b2..975f942389e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java @@ -76,9 +76,8 @@ public class BlockingHttpConnection extends HttpConnection LOG.debug(e); } _generator.sendError(e.getStatus(), e.getReason(), null, true); - _parser.reset(); - _endp.close(); + _endp.shutdownOutput(); } finally { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java index 401f924ec78..d4849acb122 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java @@ -23,9 +23,12 @@ import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayEndPoint; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.util.StringUtil; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; public class LocalConnector extends AbstractConnector { + private static final Logger LOG = Log.getLogger(LocalConnector.class); private final BlockingQueue _requests = new LinkedBlockingQueue(); public LocalConnector() @@ -135,8 +138,14 @@ public class LocalConnector extends AbstractConnector } } } + catch (IOException x) + { + LOG.debug(x); + leaveOpen = false; + } catch (Exception x) { + LOG.warn(x); leaveOpen = false; } finally diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java index b3b5eec837a..a4f57083e9d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; +import java.net.SocketException; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -251,6 +252,12 @@ public class SocketConnector extends AbstractConnector try{close();} catch(IOException e2){LOG.ignore(e2);} } + catch (SocketException e) + { + LOG.debug("EOF", e); + try{close();} + catch(IOException e2){LOG.ignore(e2);} + } catch (HttpException e) { LOG.debug("BAD", e); From 79e431f330b40ac31bb12b55cc52140debb8b5b9 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 29 Sep 2011 17:36:23 +1000 Subject: [PATCH 118/134] cleanup --- .../main/java/org/eclipse/jetty/http/HttpParser.java | 10 +++++++++- .../java/org/eclipse/jetty/io/nio/ChannelEndPoint.java | 1 - .../eclipse/jetty/io/nio/SelectChannelEndPoint.java | 4 +++- .../java/org/eclipse/jetty/io/nio/SelectorManager.java | 3 ++- .../eclipse/jetty/io/nio/SslSelectChannelEndPoint.java | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 46c8f30cc80..0c18400950b 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -939,7 +939,15 @@ public class HttpParser implements Parser if (_buffer.space() == 0) throw new HttpException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413, "FULL "+(_buffer==_body?"body":"head")); - return _endp.fill(_buffer); + try + { + return _endp.fill(_buffer); + } + catch(IOException e) + { + LOG.debug(e); + throw (e instanceof EofException) ? e:new EofException(e); + } } return -1; diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java index 516e1cc6f75..5ee14242347 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/ChannelEndPoint.java @@ -264,7 +264,6 @@ public class ChannelEndPoint implements EndPoint { throw new IOException("Not Implemented"); } - return len; } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 06bd0fd7114..5bf00235e0c 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -539,8 +539,10 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo cancelIdle(); if (_open) + { + _open=false; _selectSet.destroyEndPoint(this); - _open=false; + } _key = null; } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index 507fad0fa8a..1b8218832a4 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -946,7 +946,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa final CountDownLatch latch = new CountDownLatch(1); - addChange(new ChangeTask(){ + addChange(new ChangeTask() + { public void run() { dumpKeyState(dump); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 7476800bde8..2e1c93f3b7d 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -388,7 +388,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } // return the number of unencrypted bytes filled. int filled=buffer.length()-size; - if (filled==0 && isInputShutdown()) + if (filled==0 && (isInputShutdown() || !isOpen())) return -1; return filled; From 9b9bc9e79cc030e8cde8b6509181761510865eb6 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 29 Sep 2011 15:14:26 -0500 Subject: [PATCH 119/134] Add an additional test using forwarding via filter --- .../eclipse/jetty/servlet/DispatcherTest.java | 114 +++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index ce5b326ec01..c034633d125 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -15,12 +15,16 @@ package org.eclipse.jetty.servlet; import java.io.IOException; import java.io.PrintWriter; +import java.net.HttpRetryException; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; import javax.servlet.GenericServlet; import javax.servlet.RequestDispatcher; import javax.servlet.Servlet; @@ -213,7 +217,6 @@ public class DispatcherTest // from inside the context.txt file Assert.assertNotNull(responses); - System.out.println(responses); assertTrue(responses.contains("content goes here")); } @@ -250,6 +253,26 @@ public class DispatcherTest assertTrue(responses.contains("content goes here")); } + @Test + public void testForwardFilterToRogerServlet() throws Exception + { + _contextHandler.addServlet(RogerThatServlet.class, "/*"); + _contextHandler.addServlet(ReserveEchoServlet.class,"/recho/*"); + _contextHandler.addServlet(EchoServlet.class, "/echo/*"); + _contextHandler.addFilter(ForwardFilter.class, "/*", FilterMapping.REQUEST); + + String rogerResponse = _connector.getResponses("GET /context/ HTTP/1.0\n" + "Host: localhost\n\n"); + + String echoResponse = _connector.getResponses("GET /context/foo?echo=echoText HTTP/1.0\n" + "Host: localhost\n\n"); + + String rechoResponse = _connector.getResponses("GET /context/?echo=echoText HTTP/1.0\n" + "Host: localhost\n\n"); + + assertTrue(rogerResponse.contains("Roger That!")); + assertTrue(echoResponse.contains("echoText")); + assertTrue(rechoResponse.contains("txeTohce")); + } + + public static class ForwardServlet extends HttpServlet implements Servlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException @@ -266,6 +289,59 @@ public class DispatcherTest } } + /* + * Forward filter works with roger, echo and reverse echo servlets to test various + * forwarding bits using filters. + * + * when there is an echo parameter and the path info is / it forwards to the reverse echo + * anything else in the pathInfo and it sends straight to the echo servlet...otherwise its + * all roger servlet + */ + public static class ForwardFilter implements Filter + { + ServletContext servletContext; + + public void init(FilterConfig filterConfig) throws ServletException + { + servletContext = filterConfig.getServletContext().getContext("/context"); + } + + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException + { + + if ( servletContext == null || !(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) + { + chain.doFilter(request,response); + return; + } + + HttpServletRequest req = (HttpServletRequest)request; + HttpServletResponse resp = (HttpServletResponse)response; + + if ( req.getParameter("echo") != null && "/".equals(req.getPathInfo())) + { + RequestDispatcher dispatcher = servletContext.getRequestDispatcher("/recho"); + dispatcher.forward(request,response); + } + else if ( req.getParameter("echo") != null ) + { + RequestDispatcher dispatcher = servletContext.getRequestDispatcher("/echo"); + dispatcher.forward(request,response); + } + else + { + chain.doFilter(request,response); + return; + } + } + + public void destroy() + { + + } + } + + public static class DispatchServletServlet extends HttpServlet implements Servlet { @Override @@ -309,6 +385,42 @@ public class DispatcherTest } } + public static class EchoServlet extends GenericServlet + { + @Override + public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException + { + String echoText = req.getParameter("echo"); + + if ( echoText == null ) + { + throw new ServletException("echo is a required parameter"); + } + else + { + res.getWriter().print(echoText); + } + } + } + + public static class ReserveEchoServlet extends GenericServlet + { + @Override + public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException + { + String echoText = req.getParameter("echo"); + + if ( echoText == null ) + { + throw new ServletException("echo is a required parameter"); + } + else + { + res.getWriter().print(new StringBuffer(echoText).reverse().toString()); + } + } + } + public static class DispatchToResourceServlet extends HttpServlet implements Servlet { @Override From a134664b4ce96b841917ae7b3fb48cd84602a1e2 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 29 Sep 2011 23:01:43 +0200 Subject: [PATCH 120/134] Method close() should really close the underlying channel, not only send the SSL close message. --- .../io/nio/SslSelectChannelEndPoint.java | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index 2e1c93f3b7d..dfc4bfb06ef 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -199,8 +199,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { if (_debug) LOG.debug("{} process closing={} in={} out={}",_session,_closing,inBBuf!=null,outBuf==null?null:outBuf.toDetailString()); - - // If there is no place to put incoming application data, + + // If there is no place to put incoming application data, if (inBBuf==null) { // use ZERO buffer @@ -219,17 +219,15 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint progress=false; // flush output data - { - int len=_outNIOBuffer==null?0:_outNIOBuffer.length(); + int len=_outNIOBuffer==null?0:_outNIOBuffer.length(); - // we must flush it, as the other end might be - // waiting for that outgoing data before sending - // more incoming data - flush(); + // we must flush it, as the other end might be + // waiting for that outgoing data before sending + // more incoming data + flush(); - // If we have written some bytes, then progress has been made. - progress|=(_outNIOBuffer==null?0:_outNIOBuffer.length())0||_result.bytesConsumed()>0; @@ -329,7 +327,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint } if (_debug) LOG.debug("{} received {} sent {}",_session,received,sent); - + freeInBuffer(); return (received<0||sent<0)?-1:(received+sent); } @@ -342,10 +340,18 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { if (_closing) return; - LOG.debug("{} close",_session); + _closing=true; - _engine.closeOutbound(); - process(null,null); + LOG.debug("{} close",_session); + try + { + _engine.closeOutbound(); + process(null,null); + } + finally + { + super.close(); + } } /* ------------------------------------------------------------ */ @@ -390,7 +396,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint int filled=buffer.length()-size; if (filled==0 && (isInputShutdown() || !isOpen())) return -1; - + return filled; } @@ -412,7 +418,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { _debug=LOG.isDebugEnabled(); LOG.debug("{} flush3",_session); - + int len=0; int flushed=0; if (header!=null && header.hasContent()) @@ -428,7 +434,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint else if (flushed==0) flushed=-1; } - + return flushed; } @@ -439,7 +445,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint LOG.debug(_session+" flush"); if (!isOpen()) throw new EofException(); - + if (isBufferingOutput()) { int flushed=super.flush(_outNIOBuffer); @@ -478,7 +484,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint * @return true if progress is made */ private boolean unwrap(ByteBuffer buffer) throws IOException - { + { needInBuffer(); ByteBuffer in_buffer=_inNIOBuffer.getByteBuffer(); @@ -486,9 +492,9 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint int total_filled=0; boolean remoteClosed = false; - + LOG.debug("{} unwrap {} {}",_session,_inNIOBuffer.space()>0,super.isOpen()); - + // loop filling as much encrypted data as we can into the buffer while (_inNIOBuffer.space()>0 && super.isOpen()) { @@ -582,11 +588,11 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint _closing=true; // return true is some bytes somewhere were moved about. return total_filled>0 ||_result.bytesConsumed()>0 || _result.bytesProduced()>0; - + case OK: // return true is some bytes somewhere were moved about. return total_filled>0 ||_result.bytesConsumed()>0 || _result.bytesProduced()>0; - + default: LOG.warn("unwrap default: "+_result); throw new IOException(_result.toString()); @@ -621,7 +627,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint bbuf.position(buffer.getIndex()); bbuf.limit(buffer.putIndex()); out_buffer.position(_outNIOBuffer.putIndex()); - + _result=null; _result=_engine.wrap(bbuf,out_buffer); if (_debug) LOG.debug(_session+" wrap "+_result); @@ -655,7 +661,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { case BUFFER_UNDERFLOW: throw new IllegalStateException(); - + case BUFFER_OVERFLOW: LOG.debug("wrap {}",_result); flush(); @@ -712,7 +718,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint super.scheduleWrite(); } */ - + /* ------------------------------------------------------------ */ @Override public String toString() From 53b9f1cc7e4275e17aa579f46ca20cc4211dced4 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 29 Sep 2011 16:57:30 -0500 Subject: [PATCH 121/134] [Bug 336443] add missing comma in DigestAuthenticator string --- .../jetty/security/authentication/DigestAuthenticator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java index ac4ebe2ea30..5a2ecf412e8 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/DigestAuthenticator.java @@ -191,7 +191,7 @@ public class DigestAuthenticator extends LoginAuthenticator + domain + "\", nonce=\"" + newNonce((Request)request) - + "\", algorithm=MD5, qop=\"auth\"" + + "\", algorithm=MD5, qop=\"auth\"," + " stale=" + stale); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); From 37845a1a4fcedd6f583d0de74d3dfbc629f6b0f2 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Fri, 30 Sep 2011 11:54:35 +0200 Subject: [PATCH 122/134] 357687: Add ShutdownHandler + UnitTest --- jetty-server/pom.xml | 6 + .../jetty/server/handler/ShutdownHandler.java | 125 ++++++++++++++++++ .../server/handler/ShutdownHandlerTest.java | 67 ++++++++++ pom.xml | 5 + 4 files changed, 203 insertions(+) create mode 100644 jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java create mode 100644 jetty-server/src/test/java/org/eclipse/jetty/server/handler/ShutdownHandlerTest.java diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index 13f653d8f21..edd48f040e1 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -107,5 +107,11 @@ ${project.version} true + + org.mockito + mockito-core + 1.8.5 + test + diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java new file mode 100644 index 00000000000..a0edc4041c3 --- /dev/null +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java @@ -0,0 +1,125 @@ +// ======================================================================== +// Copyright (c) 2009-2009 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.server.handler; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; + +/* ------------------------------------------------------------ */ +/** + * A handler that shuts the server down on a valid request. Used to do "soft" restarts from Java. This handler is a contribution from Johannes Brodwall: + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=357687 + * + * Usage: + * + *
    + * Server server = new Server(8080);
    + * HandlerList handlers = new HandlerList();
    + * handlers.setHandlers(new Handler[]
    + * { someOtherHandler, new ShutdownHandler(server,"secret password") });
    + * server.setHandler(handlers);
    + * server.start();
    + * 
    + */ +public class ShutdownHandler extends AbstractHandler +{ + private static final Logger LOG = Log.getLogger(ShutdownHandler.class); + + private final String shutdownToken; + + private final Server jettyServer; + + private boolean exitJvm = false; + + /** + * Creates a listener that lets the server be shut down remotely (but only from localhost). + * + * @param server + * the Jetty instance that should be shut down + * @param shutdownToken + * a secret password to avoid unauthorized shutdown attempts + */ + public ShutdownHandler(Server server, String shutdownToken) + { + this.jettyServer = server; + this.shutdownToken = shutdownToken; + } + + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException + { + if (!target.equals("/shutdown")) + { + return; + } + + if (!request.getMethod().equals("POST")) + { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return; + } + if (!hasCorrectSecurityToken(request)) + { + LOG.warn("Unauthorized shutdown attempt from " + getRemoteAddr(request)); + response.sendError(HttpServletResponse.SC_UNAUTHORIZED); + return; + } + if (!requestFromLocalhost(request)) + { + LOG.warn("Unauthorized shutdown attempt from " + getRemoteAddr(request)); + response.sendError(HttpServletResponse.SC_UNAUTHORIZED); + return; + } + + LOG.info("Shutting down by request from " + getRemoteAddr(request)); + try + { + shutdownServer(); + } + catch (Exception e) + { + throw new RuntimeException("Shutting down server",e); + } + } + + private boolean requestFromLocalhost(HttpServletRequest request) + { + return "127.0.0.1".equals(getRemoteAddr(request)); + } + + protected String getRemoteAddr(HttpServletRequest request) + { + return request.getRemoteAddr(); + } + + private boolean hasCorrectSecurityToken(HttpServletRequest request) + { + return shutdownToken.equals(request.getParameter("token")); + } + + void shutdownServer() throws Exception + { + jettyServer.stop(); + if (exitJvm) + System.exit(0); + } + +} diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ShutdownHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ShutdownHandlerTest.java new file mode 100644 index 00000000000..0f274eca92e --- /dev/null +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ShutdownHandlerTest.java @@ -0,0 +1,67 @@ +package org.eclipse.jetty.server.handler; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.server.Server; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +public class ShutdownHandlerTest +{ + @Mock private HttpServletRequest request; + @Mock private HttpServletResponse response; + + private Server server = new Server(0); + private String shutdownToken = "asdlnsldgnklns"; + + // class under test + private ShutdownHandler shutdownHandler; + + @Before + public void startServer() throws Exception + { + MockitoAnnotations.initMocks(this); + server.start(); + shutdownHandler = new ShutdownHandler(server,shutdownToken); + } + + @Test + public void shutdownServerWithCorrectTokenAndIPTest() throws Exception + { + setDefaultExpectations(); + shutdownHandler.handle("/shutdown",null,request,response); + assertEquals("Server should be stopped","STOPPED",server.getState()); + } + + @Test + public void wrongTokenTest() throws Exception + { + setDefaultExpectations(); + when(request.getParameter("token")).thenReturn("anothertoken"); + shutdownHandler.handle("/shutdown",null,request,response); + assertEquals("Server should be running","STARTED",server.getState()); + } + + @Test + public void shutdownRequestNotFromLocalhostTest() throws Exception + { + setDefaultExpectations(); + when(request.getRemoteAddr()).thenReturn("192.168.3.3"); + shutdownHandler.handle("/shutdown",null,request,response); + assertEquals("Server should be running","STARTED",server.getState()); + } + + private void setDefaultExpectations() + { + when(request.getMethod()).thenReturn("POST"); + when(request.getParameter("token")).thenReturn(shutdownToken); + when(request.getRemoteAddr()).thenReturn("127.0.0.1"); + } + +} diff --git a/pom.xml b/pom.xml index 92439b310e3..e37c2c4229b 100644 --- a/pom.xml +++ b/pom.xml @@ -407,6 +407,11 @@ junit ${junit-version} + + org.mockito + mockito-core + 1.8.5 +