From ff8eeae9821f54e7747a07f63aed3ae214c004ab Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 24 Apr 2015 14:28:57 +1000 Subject: [PATCH 1/9] 465359 Resource.newResource(String res, boolean useCache) does not use useCache argument --- .../src/main/java/org/eclipse/jetty/util/resource/Resource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java index 99050d86e21..6fa97109a6a 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java @@ -193,7 +193,7 @@ public abstract class Resource implements ResourceFactory, Closeable } } - return newResource(url); + return newResource(url, useCaches); } /* ------------------------------------------------------------ */ From 6ebfd8832389a85d926b6fb60b86fe343204e657 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 24 Apr 2015 14:51:29 +1000 Subject: [PATCH 2/9] 465360 URLResource.addPath should use _useCaches setting to create new Resource --- .../main/java/org/eclipse/jetty/util/resource/URLResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java index a2a438c9871..2d5fd872ee0 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java @@ -301,7 +301,7 @@ public class URLResource extends Resource path = URIUtil.canonicalPath(path); - return newResource(URIUtil.addPaths(_url.toExternalForm(),path)); + return newResource(URIUtil.addPaths(_url.toExternalForm(),path), _useCaches); } /* ------------------------------------------------------------ */ From d5c95a1302230ba8e20d1fd56dc99b7a3302a256 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 29 Apr 2015 14:01:20 +1000 Subject: [PATCH 3/9] 465747 - Jetty is failing to process all HTTP OPTIONS requests. The Server handleOptions method was handling all OPTIONS * requests with a blank 200 response. This has been fixed so that this method only checks that * URI is only applied to OPTIONS method. --- .../org/eclipse/jetty/http/HttpMethod.java | 2 +- .../java/org/eclipse/jetty/server/Server.java | 10 ++--- .../jetty/server/HttpServerTestBase.java | 39 +++++++++++++++++++ .../jetty/server/HttpServerTestFixture.java | 15 +++++++ .../test/support/TestableJettyServer.java | 2 +- .../src/test/resources/BIOHttp.xml | 22 ----------- .../src/test/resources/BIOHttps.xml | 29 -------------- .../src/test/resources/NIOHttp.xml | 2 +- .../src/test/resources/NIOHttps.xml | 2 +- 9 files changed, 61 insertions(+), 62 deletions(-) delete mode 100644 tests/test-integration/src/test/resources/BIOHttp.xml delete mode 100644 tests/test-integration/src/test/resources/BIOHttps.xml diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpMethod.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpMethod.java index 0dd075328f2..7904932637b 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpMethod.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpMethod.java @@ -76,7 +76,7 @@ public enum HttpMethod return HEAD; break; case 'O': - if (bytes[position+1]=='O' && bytes[position+2]=='T' && bytes[position+3]=='I' && length>=8 && + if (bytes[position+1]=='P' && bytes[position+2]=='T' && bytes[position+3]=='I' && length>=8 && bytes[position+4]=='O' && bytes[position+5]=='N' && bytes[position+6]=='S' && bytes[position+7]==' ' ) return OPTIONS; break; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java index fe6f847410f..96d10b64b6d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java @@ -487,8 +487,10 @@ public class Server extends HandlerWrapper implements Attributes if (LOG.isDebugEnabled()) LOG.debug(request.getDispatcherType()+" "+request.getMethod()+" "+target+" on "+connection); - if ("*".equals(target)) + if (HttpMethod.OPTIONS.is(request.getMethod()) || "*".equals(target)) { + if (!HttpMethod.OPTIONS.is(request.getMethod())) + response.sendError(HttpStatus.BAD_REQUEST_400); handleOptions(request,response); if (!request.isHandled()) handle(target, request, request, response); @@ -505,12 +507,6 @@ public class Server extends HandlerWrapper implements Attributes */ protected void handleOptions(Request request,Response response) throws IOException { - if (!HttpMethod.OPTIONS.is(request.getMethod())) - response.sendError(HttpStatus.BAD_REQUEST_400); - request.setHandled(true); - response.setStatus(200); - response.setContentLength(0); - response.closeOutput(); } /* ------------------------------------------------------------ */ 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 5875c526a85..9d0dad20be8 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 @@ -131,6 +131,45 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture } } + @Test + public void testOPTIONS() throws Exception + { + configureServer(new OptionsHandler()); + + try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort())) + { + OutputStream os = client.getOutputStream(); + + os.write(("OPTIONS * HTTP/1.1\r\n" + + "Host: "+_serverURI.getHost()+"\r\n" + + "Connection: close\r\n" + + "\r\n").getBytes(StandardCharsets.ISO_8859_1)); + os.flush(); + + // Read the response. + String response = readResponse(client); + + Assert.assertThat(response, Matchers.containsString("HTTP/1.1 200 OK")); + Assert.assertThat(response, Matchers.containsString("Allow: GET")); + } + + try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort())) + { + OutputStream os = client.getOutputStream(); + + os.write(("GET * HTTP/1.1\r\n" + + "Host: "+_serverURI.getHost()+"\r\n" + + "Connection: close\r\n" + + "\r\n").getBytes(StandardCharsets.ISO_8859_1)); + os.flush(); + + // Read the response. + String response = readResponse(client); + + Assert.assertThat(response, Matchers.containsString("HTTP/1.1 400 ")); + Assert.assertThat(response, Matchers.not(Matchers.containsString("Allow: "))); + } + } /* * Feed a full header method diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java index 82fff8f4a9c..c06034279c6 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java @@ -150,6 +150,21 @@ public class HttpServerTestFixture } } + protected static class OptionsHandler extends AbstractHandler + { + @Override + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException + { + baseRequest.setHandled(true); + if (request.getMethod().equals("OPTIONS")) + response.setStatus(200); + else + response.setStatus(500); + + response.setHeader("Allow", "GET"); + } + } + protected static class HelloWorldHandler extends AbstractHandler { @Override diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java index 5c589d1dd6a..43876e8f4bd 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java @@ -177,7 +177,7 @@ public class TestableJettyServer _server.start(); // Find the active server port. - this._serverPort = ((NetworkConnector)_server.getConnectors()[0]).getPort(); + this._serverPort = ((NetworkConnector)_server.getConnectors()[0]).getLocalPort(); System.err.println("Server Port="+_serverPort); Assert.assertTrue("Server Port is between 1 and 65535. Actually <" + _serverPort + ">",(1 <= this._serverPort) && (this._serverPort <= 65535)); } diff --git a/tests/test-integration/src/test/resources/BIOHttp.xml b/tests/test-integration/src/test/resources/BIOHttp.xml deleted file mode 100644 index 751a3c2cd0a..00000000000 --- a/tests/test-integration/src/test/resources/BIOHttp.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - 300000 - 2 - false - - - - - diff --git a/tests/test-integration/src/test/resources/BIOHttps.xml b/tests/test-integration/src/test/resources/BIOHttps.xml deleted file mode 100644 index d845957d142..00000000000 --- a/tests/test-integration/src/test/resources/BIOHttps.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - 300000 - 2 - false - /keystore - OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 - OBF:1u2u1wml1z7s1z7a1wnl1u2g - - - - - - diff --git a/tests/test-integration/src/test/resources/NIOHttp.xml b/tests/test-integration/src/test/resources/NIOHttp.xml index 793da7a94d1..c766d105966 100644 --- a/tests/test-integration/src/test/resources/NIOHttp.xml +++ b/tests/test-integration/src/test/resources/NIOHttp.xml @@ -21,7 +21,7 @@ - + 0 diff --git a/tests/test-integration/src/test/resources/NIOHttps.xml b/tests/test-integration/src/test/resources/NIOHttps.xml index ff42c725fa6..5e90fdbd0d6 100644 --- a/tests/test-integration/src/test/resources/NIOHttps.xml +++ b/tests/test-integration/src/test/resources/NIOHttps.xml @@ -26,7 +26,7 @@ - + 0 30000 From 2c65b66f9c24f2cad43dd8d65729921be6767246 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 29 Apr 2015 15:18:48 +1000 Subject: [PATCH 4/9] 465734 DosFilter whitelist bit pattern fix --- .../org/eclipse/jetty/servlets/DoSFilter.java | 16 ++++++++++++++ .../eclipse/jetty/servlets/DoSFilterTest.java | 21 ++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java index 43ce257f0f4..ad758b18bf5 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java @@ -723,6 +723,10 @@ public class DoSFilter implements Filter prefix -= 8; ++index; } + + if (index == result.length) + return result; + // Sets the _prefix_ most significant bits to 1 result[index] = (byte)~((1 << (8 - prefix)) - 1); return result; @@ -1038,6 +1042,18 @@ public class DoSFilter implements Filter _whitelist.addAll(result); LOG.debug("Whitelisted IP addresses: {}", result); } + + /** + * Set a list of IP addresses that will not be rate limited. + * + * @param values whitelist + */ + public void setWhitelist(List values) + { + clearWhitelist(); + _whitelist.addAll(values); + LOG.debug("Whitelisted IP addresses: {}", values); + } /** * Clears the list of whitelisted IP addresses diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java index b55e26905d4..93177e90250 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java @@ -78,19 +78,20 @@ public class DoSFilterTest extends AbstractDoSFilterTest { DoSFilter filter = new DoSFilter(); List whitelist = new ArrayList(); - whitelist.add("192.168.0.1"); + whitelist.add("192.168.0.1/32"); whitelist.add("10.0.0.0/8"); whitelist.add("4d8:0:a:1234:ABc:1F:b18:17"); whitelist.add("4d8:0:a:1234:ABc:1F:0:0/96"); - Assert.assertTrue(filter.checkWhitelist(whitelist, "192.168.0.1")); - Assert.assertFalse(filter.checkWhitelist(whitelist, "192.168.0.2")); - Assert.assertFalse(filter.checkWhitelist(whitelist, "11.12.13.14")); - Assert.assertTrue(filter.checkWhitelist(whitelist, "10.11.12.13")); - Assert.assertTrue(filter.checkWhitelist(whitelist, "10.0.0.0")); - Assert.assertFalse(filter.checkWhitelist(whitelist, "0.0.0.0")); - Assert.assertTrue(filter.checkWhitelist(whitelist, "4d8:0:a:1234:ABc:1F:b18:17")); - Assert.assertTrue(filter.checkWhitelist(whitelist, "4d8:0:a:1234:ABc:1F:b18:0")); - Assert.assertFalse(filter.checkWhitelist(whitelist, "4d8:0:a:1234:ABc:1D:0:0")); + filter.setWhitelist(whitelist); + Assert.assertTrue(filter.checkWhitelist("192.168.0.1")); + Assert.assertFalse(filter.checkWhitelist("192.168.0.2")); + Assert.assertFalse(filter.checkWhitelist("11.12.13.14")); + Assert.assertTrue(filter.checkWhitelist("10.11.12.13")); + Assert.assertTrue(filter.checkWhitelist("10.0.0.0")); + Assert.assertFalse(filter.checkWhitelist("0.0.0.0")); + Assert.assertTrue(filter.checkWhitelist("4d8:0:a:1234:ABc:1F:b18:17")); + Assert.assertTrue(filter.checkWhitelist("4d8:0:a:1234:ABc:1F:b18:0")); + Assert.assertFalse(filter.checkWhitelist("4d8:0:a:1234:ABc:1D:0:0")); } private boolean hitRateTracker(DoSFilter doSFilter, int sleep) throws InterruptedException From d7de34af764e61de6e3b87ef626e5a27880d8d16 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 29 Apr 2015 17:58:10 +1000 Subject: [PATCH 5/9] 465202 Forked Mojo does not extract war overlays/dependencies --- .../maven/plugin/JettyEffectiveWebXml.java | 3 +- .../maven/plugin/JettyRunForkedMojo.java | 62 +++++++++++-------- .../plugin/MavenQuickStartConfiguration.java | 40 ++++++++++++ .../plugin/MavenWebInfConfiguration.java | 24 ++----- .../eclipse/jetty/maven/plugin/Starter.java | 18 +++--- 5 files changed, 94 insertions(+), 53 deletions(-) diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java index 120293749e6..b837722db35 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyEffectiveWebXml.java @@ -71,8 +71,7 @@ public class JettyEffectiveWebXml extends JettyRunMojo @Override public void startJetty() throws MojoExecutionException { - //Only do enough setup to be able to produce a quickstart-web.xml file to - //pass onto the forked process to run + //Only do enough setup to be able to produce a quickstart-web.xml file //if the user didn't nominate a file to generate into, pick the name and //make sure that it is deleted on exit diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java index e7ec20f52e2..b1d267efc7e 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java @@ -162,6 +162,7 @@ public class JettyRunForkedMojo extends JettyRunMojo private Resource originalBaseResource; + private boolean originalPersistTemp; /** @@ -267,6 +268,9 @@ public class JettyRunForkedMojo extends JettyRunMojo //copy the base resource as configured by the plugin originalBaseResource = webApp.getBaseResource(); + //get the original persistance setting + originalPersistTemp = webApp.isPersistTempDirectory(); + //set the webapp up to do very little other than generate the quickstart-web.xml webApp.setCopyWebDir(false); webApp.setCopyWebInf(false); @@ -289,8 +293,11 @@ public class JettyRunForkedMojo extends JettyRunMojo tpool.start(); else webApp.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE.toString()); + + //leave everything unpacked for the forked process to use + webApp.setPersistTempDirectory(true); - webApp.start(); //just enough to generate the quickstart + webApp.start(); //just enough to generate the quickstart //save config of the webapp BEFORE we stop File props = prepareConfiguration(); @@ -498,31 +505,23 @@ public class JettyRunForkedMojo extends JettyRunMojo //tmp dir props.put("tmp.dir", webApp.getTempDirectory().getAbsolutePath()); - props.put("tmp.dir.persist", Boolean.toString(webApp.isPersistTempDirectory())); + props.put("tmp.dir.persist", Boolean.toString(originalPersistTemp)); + + //send over the original base resources before any overlays were added + if (originalBaseResource instanceof ResourceCollection) + props.put("base.dirs.orig", toCSV(((ResourceCollection)originalBaseResource).getResources())); + else + props.put("base.dirs.orig", originalBaseResource.toString()); + + //send over the calculated resource bases that includes unpacked overlays, but none of the + //meta-inf resources + Resource postOverlayResources = (Resource)webApp.getAttribute(MavenWebInfConfiguration.RESOURCE_BASES_POST_OVERLAY); + if (postOverlayResources instanceof ResourceCollection) + props.put("base.dirs", toCSV(((ResourceCollection)postOverlayResources).getResources())); + else + props.put("base.dirs", postOverlayResources.toString()); + - //resource bases - these are what has been configured BEFORE the webapp started and - //potentially reordered them and included any resources from META-INF - if (originalBaseResource != null) - { - StringBuffer rb = new StringBuffer(); - if (originalBaseResource instanceof ResourceCollection) - { - ResourceCollection resources = ((ResourceCollection)originalBaseResource); - for (Resource r:resources.getResources()) - { - if (rb.length() > 0) rb.append(","); - rb.append(r.toString()); - } - } - else - rb.append(originalBaseResource.toString()); - - props.put("base.dirs", rb.toString()); - } - - //sort out the resource base directories of the webapp - props.put("base.first", Boolean.toString(webApp.getBaseAppFirst())); - //web-inf classes if (webApp.getClasses() != null) { @@ -838,4 +837,17 @@ public class JettyRunForkedMojo extends JettyRunMojo } return strbuff.toString(); } + + private String toCSV (Resource[] resources) + { + StringBuffer rb = new StringBuffer(); + + for (Resource r:resources) + { + if (rb.length() > 0) rb.append(","); + rb.append(r.toString()); + } + + return rb.toString(); + } } diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java index 5375b515af8..c0212dc293a 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenQuickStartConfiguration.java @@ -23,9 +23,11 @@ import java.io.File; import java.util.Iterator; import org.eclipse.jetty.quickstart.QuickStartConfiguration; +import org.eclipse.jetty.util.IO; 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.resource.ResourceCollection; import org.eclipse.jetty.webapp.WebAppClassLoader; import org.eclipse.jetty.webapp.WebAppContext; @@ -54,6 +56,20 @@ public class MavenQuickStartConfiguration extends QuickStartConfiguration return _quickStartWebXml; } + @Override + public void preConfigure(WebAppContext context) throws Exception + { + //check that webapp is suitable for quick start + if (context.getBaseResource() == null) + throw new IllegalStateException ("No location for webapp"); + + + //look for quickstart-web.xml in WEB-INF of webapp + Resource quickStartWebXml = getQuickStartWebXml(context); + LOG.debug("quickStartWebXml={}",quickStartWebXml); + + context.getMetaData().setWebXml(quickStartWebXml); + } @Override @@ -89,4 +105,28 @@ public class MavenQuickStartConfiguration extends QuickStartConfiguration context.setServerClasses( newServerClasses ); } + @Override + public void deconfigure(WebAppContext context) throws Exception + { + //if we're not persisting the temp dir, get rid of any overlays + if (!context.isPersistTempDirectory()) + { + Resource originalBases = (Resource)context.getAttribute("org.eclipse.jetty.resources.originalBases"); + String originalBaseStr = originalBases.toString(); + + //Iterate over all of the resource bases and ignore any that were original bases, just + //deleting the overlays + Resource res = context.getBaseResource(); + if (res instanceof ResourceCollection) + { + for (Resource r:((ResourceCollection)res).getResources()) + { + if (originalBaseStr.contains(r.toString())) + continue; + IO.delete(r.getFile()); + } + } + } + } + } diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java index c1336520dfa..909402b0e7a 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java @@ -25,7 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; -import org.eclipse.jetty.util.IO; + import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.resource.Resource; @@ -47,7 +47,7 @@ public class MavenWebInfConfiguration extends WebInfConfiguration { private static final Logger LOG = Log.getLogger(MavenWebInfConfiguration.class); - + public static final String RESOURCE_BASES_POST_OVERLAY = "org.eclipse.jetty.resource.postOverlay"; protected static int COUNTER = 0; protected Resource _originalResourceBase; protected List _unpackedOverlayResources; @@ -119,24 +119,11 @@ public class MavenWebInfConfiguration extends WebInfConfiguration */ public void deconfigure(WebAppContext context) throws Exception { - //remove the unpacked wars - if (_unpackedOverlayResources != null && !_unpackedOverlayResources.isEmpty()) - { - try - { - for (Resource r:_unpackedOverlayResources) - { - IO.delete(r.getFile()); - } - } - catch (IOException e) - { - LOG.ignore(e); - } - } super.deconfigure(context); //restore whatever the base resource was before we might have included overlaid wars context.setBaseResource(_originalResourceBase); + //undo the setting of the overlayed resources + context.removeAttribute(RESOURCE_BASES_POST_OVERLAY); } @@ -194,9 +181,10 @@ public class MavenWebInfConfiguration extends WebInfConfiguration resourceBaseCollection.add(_originalResourceBase); } } - jwac.setBaseResource(new ResourceCollection(resourceBaseCollection.toArray(new Resource[resourceBaseCollection.size()]))); } + + jwac.setAttribute(RESOURCE_BASES_POST_OVERLAY, jwac.getBaseResource()); } diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java index 83979f57781..72404490b46 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java @@ -221,21 +221,23 @@ public class Starter str = (String)props.getProperty("tmp.dir.persist"); if (str != null) webApp.setPersistTempDirectory(Boolean.valueOf(str)); - - // - the base directories + + //Get the calculated base dirs which includes the overlays str = (String)props.getProperty("base.dirs"); if (str != null && !"".equals(str.trim())) { ResourceCollection bases = new ResourceCollection(str.split(",")); - webApp.setWar(bases.getResources()[0].toString()); + webApp.setWar(null); webApp.setBaseResource(bases); } - - // - put virtual webapp base resource first on resource path or not - str = (String)props.getProperty("base.first"); + + //Get the original base dirs without the overlays + str = (String)props.get("base.dirs.orig"); if (str != null && !"".equals(str.trim())) - webApp.setBaseAppFirst(Boolean.valueOf(str)); - + { + ResourceCollection bases = new ResourceCollection(str.split(",")); + webApp.setAttribute ("org.eclipse.jetty.resources.originalBases", bases); + } //For overlays str = (String)props.getProperty("maven.war.includes"); From 4b28a5f7fb9833ada34640d2a3464620ac2e9985 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 29 Apr 2015 14:10:46 -0700 Subject: [PATCH 6/9] Disabling PathWatcherTest temporarily --- .../src/test/java/org/eclipse/jetty/util/PathWatcherTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java index 484c96b886d..b58decea09a 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java @@ -43,9 +43,11 @@ import org.eclipse.jetty.util.PathWatcher.PathWatchEvent; import org.eclipse.jetty.util.PathWatcher.PathWatchEventType; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; +@Ignore public class PathWatcherTest { public static class PathWatchEventCapture implements PathWatcher.Listener From 15eb1081e90c10267a8c9cdac1756e8ddeca98bf Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 30 Apr 2015 08:57:34 +1000 Subject: [PATCH 7/9] test commit --- VERSION.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/VERSION.txt b/VERSION.txt index aab62769741..faf87fbf5b7 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,5 +1,6 @@ jetty-9.3.0-SNAPSHOT + jetty-9.2.11.M0 - 25 March 2015 + 454934 WebSocketClient / connectToServer can block indefinitely during upgrade failure From 25474ff7ab41a93d3c89de7ddc3f04b384c51762 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 30 Apr 2015 09:06:01 +1000 Subject: [PATCH 8/9] 465700 NullPointerException in ResourceHandler with welcome files --- .../org/eclipse/jetty/server/handler/ResourceHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 2c49641362c..3e7e5a078e9 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 @@ -447,7 +447,9 @@ public class ResourceHandler extends HandlerWrapper // handle directories if (resource.isDirectory()) { - if (!request.getPathInfo().endsWith(URIUtil.SLASH)) + String pathInfo = request.getPathInfo(); + boolean endsWithSlash=(pathInfo==null?request.getServletPath():pathInfo).endsWith(URIUtil.SLASH); + if (!endsWithSlash) { response.sendRedirect(response.encodeRedirectURL(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH))); return; From d5e868b645d6af1a9a9fccbc36c69d0592d55d0b Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 30 Apr 2015 10:58:01 +1000 Subject: [PATCH 9/9] less verbose unit tests --- .../main/java/org/eclipse/jetty/server/ResponseWriter.java | 7 ++++--- .../java/org/eclipse/jetty/servlet/ServletHandler.java | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ResponseWriter.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ResponseWriter.java index c4c52573c26..a9f4e1dcd1a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ResponseWriter.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ResponseWriter.java @@ -26,13 +26,14 @@ import java.util.Locale; import javax.servlet.ServletResponse; +import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; /* ------------------------------------------------------------ */ -/** +/** Specialized PrintWriter for servlet Responses *

An instance of ResponseWriter is the {@link PrintWriter} subclass returned by {@link Response#getWriter()}. * It differs from the standard {@link PrintWriter} in that:

    *
  • It does not support autoflush
  • @@ -42,7 +43,7 @@ import org.eclipse.jetty.util.log.Logger; *
* */ -class ResponseWriter extends PrintWriter +public class ResponseWriter extends PrintWriter { private static final Logger LOG = Log.getLogger(ResponseWriter.class); private final static String __lineSeparator = System.getProperty("line.separator"); @@ -132,7 +133,7 @@ class ResponseWriter extends PrintWriter throw new RuntimeIOException(_ioException); if (_isClosed) - throw new IOException("Stream closed"); + throw new EofException("Stream closed"); } @Override 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 28e3286aa30..24ebf488ec1 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 @@ -589,6 +589,11 @@ public class ServletHandler extends ScopedHandler } catch(RuntimeIOException e) { + if (e.getCause() instanceof IOException) + { + LOG.debug(e); + throw (IOException)e.getCause(); + } throw e; } catch(Exception e)