Merge branch 'jetty-9.4.x' of github.com:eclipse/jetty.project into jetty-9.4.x

This commit is contained in:
Joakim Erdfelt 2017-03-08 10:39:54 -07:00
commit 13259d2dc0
11 changed files with 69 additions and 47 deletions

View File

@ -366,8 +366,7 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore
//these candidates will be for our node
BasicDBObject query = new BasicDBObject();
query.append(__ID,new BasicDBObject("$in", candidates));
query.append(__EXPIRY, new BasicDBObject("$gt", 0));
query.append(__EXPIRY, new BasicDBObject("$lt", upperBound));
query.append(__EXPIRY, new BasicDBObject("$gt", 0).append("$lt", upperBound));
DBCursor verifiedExpiredSessions = null;
try

View File

@ -271,7 +271,7 @@ public class HttpInput extends ServletInputStream implements Runnable
}
}
// Caclulate minimum request rate for DOS protection
// Calculate minimum request rate for DOS protection
long minRequestDataRate = _channelState.getHttpChannel().getHttpConfiguration().getMinRequestDataRate();
if (minRequestDataRate > 0 && _firstByteTimeStamp != -1)
{
@ -858,6 +858,7 @@ public class HttpInput extends ServletInputStream implements Runnable
{
if (error != null)
{
// TODO is this necessary to add here?
_channelState.getHttpChannel().getResponse().getHttpFields().add(HttpConnection.CONNECTION_CLOSE);
listener.onError(error);
}

View File

@ -90,7 +90,8 @@ public class SessionHandler extends ScopedHandler
* Session id path parameter name.
* Defaults to <code>jsessionid</code>, but can be set with the
* <code>org.eclipse.jetty.servlet.SessionIdPathParameterName</code> context init parameter.
* If set to null or "none" no URL rewriting will be done.
* If context init param is "none", or setSessionIdPathParameterName is called with null or "none",
* no URL rewriting will be done.
*/
public final static String __SessionIdPathParameterNameProperty = "org.eclipse.jetty.servlet.SessionIdPathParameterName";
public final static String __DefaultSessionIdPathParameterName = "jsessionid";

View File

@ -124,6 +124,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"org.eclipse.jetty.jaas.", // webapp cannot change jaas classes
"org.eclipse.jetty.websocket.", // webapp cannot change / replace websocket classes
"org.eclipse.jetty.util.log.", // webapp should use server log
"org.eclipse.jetty.servlet.StatisticsServlet", // webapp cannot change stats servlet
"org.eclipse.jetty.servlet.DefaultServlet", // webapp cannot change default servlets
"org.eclipse.jetty.jsp.JettyJspServlet", //webapp cannot change jetty jsp servlet
"org.eclipse.jetty.servlets.PushCacheFilter", //must be loaded by container classpath
@ -163,6 +164,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"-org.eclipse.jetty.jndi.", // don't hide naming classes
"-org.eclipse.jetty.jaas.", // don't hide jaas classes
"-org.eclipse.jetty.servlets.", // don't hide jetty servlets
"-org.eclipse.jetty.servlet.StatisticsServlet", // don't hide stats servlet
"-org.eclipse.jetty.servlet.DefaultServlet", // don't hide default servlet
"-org.eclipse.jetty.servlet.NoJspServlet", // don't hide noJspServlet servlet
"-org.eclipse.jetty.jsp.", //don't hide jsp servlet

View File

@ -50,10 +50,5 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
{
return FileTestHelper.newSessionDataStoreFactory();
}
@Test
public void testNewSession() throws Exception
{
super.testNewSession();
}
}

View File

@ -50,10 +50,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
return GCloudSessionTestSupport.newSessionDataStoreFactory(GCloudTestSuite.__testSupport.getDatastore());
}
@Test
public void testNewSession() throws Exception
{
super.testNewSession();
}
}

View File

@ -59,12 +59,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
factory.setCache(__testSupport.getCache());
return factory;
}
@Override
public void testNewSession() throws Exception
{
super.testNewSession();
}
}

View File

@ -59,13 +59,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
factory.setCache(__testSupport.getCache());
return factory;
}
@Override
public void testNewSession() throws Exception
{
super.testNewSession();
}
}

View File

@ -35,13 +35,7 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
{
return JdbcTestHelper.newSessionDataStoreFactory();
}
@Test
public void testNewSession() throws Exception
{
super.testNewSession();
}
@After
public void tearDown() throws Exception

View File

@ -22,7 +22,6 @@ import org.eclipse.jetty.server.session.AbstractNonClusteredSessionScavengingTes
import org.eclipse.jetty.server.session.SessionDataStoreFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* NonClusteredSessionScavengingTest
@ -51,10 +50,4 @@ public class NonClusteredSessionScavengingTest extends AbstractNonClusteredSessi
{
return MongoTestHelper.newSessionDataStoreFactory();
}
@Test
public void testNewSession() throws Exception
{
super.testNewSession();
}
}

View File

@ -111,8 +111,62 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
{
server.stop();
}
}
@Test
public void testImmortalSession() throws Exception
{
String servletMapping = "/server";
int scavengePeriod = 3;
int maxInactivePeriod = 0;
DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory();
cacheFactory.setEvictionPolicy(SessionCache.NEVER_EVICT);
SessionDataStoreFactory storeFactory = createSessionDataStoreFactory();
((AbstractSessionDataStoreFactory)storeFactory).setGracePeriodSec(scavengePeriod);
TestServer server = new TestServer(0, maxInactivePeriod, scavengePeriod,
cacheFactory, storeFactory);
ServletContextHandler context = server.addContext("/");
context.addServlet(TestServlet.class, servletMapping);
String contextPath = "";
try
{
server.start();
int port=server.getPort();
HttpClient client = new HttpClient();
client.start();
try
{
//create an immortal session
ContentResponse response = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create");
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
// Let's wait for the scavenger to run
pause(2*scavengePeriod);
// Test that the session is still there
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=old-test");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
}
finally
{
client.stop();
}
}
finally
{
server.stop();
}
}
public static class TestServlet extends HttpServlet
{
String id;
@ -135,6 +189,12 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
assertNotNull(s);
assertFalse(s.getId().equals(id));
}
else if ("old-test".equals(action))
{
HttpSession s = request.getSession(false);
assertNotNull(s);
assertTrue(s.getId().equals(id));
}
else
{
assertTrue(false);