From 8a1ea2f69c912e7b8d7bf6966ff85ec4a2ad18df Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 16 May 2013 12:18:04 +1000 Subject: [PATCH 1/3] 407976 JDBCSessionIdManager potentially leaves server in bad state after startup --- .../server/session/JDBCSessionIdManager.java | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) 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 a72c0702b09..1a10ba6852b 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 @@ -516,24 +516,18 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager */ @Override public void doStart() - { - try - { - initializeDatabase(); - prepareTables(); - cleanExpiredSessions(); - super.doStart(); - if (LOG.isDebugEnabled()) - LOG.debug("Scavenging interval = "+getScavengeInterval()+" sec"); - _timer=new Timer("JDBCSessionScavenger", true); - setScavengeInterval(getScavengeInterval()); - } - catch (Exception e) - { - LOG.warn("Problem initialising JettySessionIds table", e); - } + throws Exception + { + initializeDatabase(); + prepareTables(); + cleanExpiredSessions(); + super.doStart(); + if (LOG.isDebugEnabled()) + LOG.debug("Scavenging interval = "+getScavengeInterval()+" sec"); + _timer=new Timer("JDBCSessionScavenger", true); + setScavengeInterval(getScavengeInterval()); } - + /** * Stop the scavenger. */ From 51c1017b3dc60fa2a2242d73753734b9a0c2cc31 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 16 May 2013 15:39:50 +1000 Subject: [PATCH 2/3] 408077 HashSessionManager leaves file handles open after being stopped --- .../server/session/HashSessionManager.java | 55 +++++++++++-------- .../jetty/server/session/HashedSession.java | 19 +++---- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java index b6866a0dbef..4e643a15c71 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/HashSessionManager.java @@ -37,6 +37,7 @@ import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.eclipse.jetty.server.handler.ContextHandler; +import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.log.Logger; @@ -520,8 +521,7 @@ public class HashSessionManager extends AbstractSessionManager } finally { - if (in != null) - try {in.close();} catch (Exception x) {__log.ignore(x);} + if (in != null) IO.close(in); if (error != null) { @@ -568,30 +568,41 @@ public class HashSessionManager extends AbstractSessionManager * defaultReadObject */ DataInputStream in = new DataInputStream(is); - String clusterId = in.readUTF(); - in.readUTF(); // nodeId - long created = in.readLong(); - long accessed = in.readLong(); - int requests = in.readInt(); - - if (session == null) - session = (HashedSession)newSession(created, accessed, clusterId); - session.setRequests(requests); - int size = in.readInt(); - if (size>0) + try { - ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(in); - for (int i=0; i0) { - String key = ois.readUTF(); - Object value = ois.readObject(); - session.setAttribute(key,value); + ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(in); + try + { + for (int i=0; i Date: Mon, 20 May 2013 15:45:53 +1000 Subject: [PATCH 3/3] 408446 Multipart parsing issue with boundry and charset in ContentType header --- .../jetty/servlets/MultiPartFilter.java | 9 +++-- .../jetty/servlets/MultipartFilterTest.java | 33 ++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java index fea6d370497..c872e936faa 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java @@ -125,8 +125,13 @@ public class MultiPartFilter implements Filter // TODO - handle encodings String contentTypeBoundary = ""; - if (content_type.indexOf("boundary=") >= 0) - contentTypeBoundary = QuotedStringTokenizer.unquote(value(content_type.substring(content_type.indexOf("boundary="))).trim()); + int bstart = content_type.indexOf("boundary="); + if (bstart >= 0) + { + int bend = content_type.indexOf(";", bstart); + bend = (bend < 0? content_type.length(): bend); + contentTypeBoundary = QuotedStringTokenizer.unquote(value(content_type.substring(bstart,bend)).trim()); + } String boundary="--"+contentTypeBoundary; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java index d41228a150d..5f12d70442c 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java @@ -164,7 +164,38 @@ public class MultipartFilterTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); assertTrue(response.getContent().indexOf("brown cow")>=0); } - + + + @Test + public void testContentTypeWithCharset() throws Exception + { + // generated and parsed test + HttpTester request = new HttpTester(); + HttpTester response = new HttpTester(); + + // test GET + request.setMethod("POST"); + request.setVersion("HTTP/1.0"); + request.setHeader("Host","tester"); + request.setURI("/context/dump"); + + String boundary="XyXyXy"; + request.setHeader("Content-Type","multipart/form-data; boundary=\""+boundary+"\"; charset=ISO-8859-1"); + + + String content = "--" + boundary + "\r\n"+ + "Content-Disposition: form-data; name=\"fileup\"; filename=\"test.upload\"\r\n"+ + "Content-Type: application/octet-stream\r\n\r\n"+ + "How now brown cow."+ + "\r\n--" + boundary + "--\r\n\r\n"; + + request.setContent(content); + + response.parse(tester.getResponses(request.generate())); + assertTrue(response.getMethod()==null); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); + assertTrue(response.getContent().indexOf("brown cow")>=0); + } @Test public void testEncodedPost() throws Exception