Merge remote-tracking branch 'origin/jetty-9.3.x'
Conflicts: jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSession.java jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionManager.java jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java
This commit is contained in:
commit
21fdaf500e
|
@ -530,6 +530,34 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
return getConnectionFactory(_defaultProtocol);
|
||||
}
|
||||
|
||||
protected boolean handleAcceptFailure(Throwable previous, Throwable current)
|
||||
{
|
||||
if (isAccepting())
|
||||
{
|
||||
if (previous == null)
|
||||
LOG.warn(current);
|
||||
else
|
||||
LOG.debug(current);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG.ignore(current);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Arbitrary sleep to avoid spin looping.
|
||||
// Subclasses may decide for a different
|
||||
// sleep policy or closing the connector.
|
||||
Thread.sleep(1000);
|
||||
return true;
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class Acceptor implements Runnable
|
||||
{
|
||||
private final int _id;
|
||||
|
@ -559,18 +587,20 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
|
||||
try
|
||||
{
|
||||
Throwable exception = null;
|
||||
while (isAccepting())
|
||||
{
|
||||
try
|
||||
{
|
||||
accept(_id);
|
||||
exception = null;
|
||||
}
|
||||
catch (Throwable e)
|
||||
catch (Throwable x)
|
||||
{
|
||||
if (isAccepting())
|
||||
LOG.warn(e);
|
||||
if (handleAcceptFailure(exception, x))
|
||||
exception = x;
|
||||
else
|
||||
LOG.ignore(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -49,6 +50,7 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
|
|||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ServerConnectorTest
|
||||
|
@ -235,4 +237,32 @@ public class ServerConnectorTest
|
|||
assertEquals(2, connector.getBeans(ConnectionFactory.class).size());
|
||||
assertEquals(proxy.getProtocol(), connector.getDefaultProtocol());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionWhileAccepting() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
AtomicLong spins = new AtomicLong();
|
||||
ServerConnector connector = new ServerConnector(server)
|
||||
{
|
||||
@Override
|
||||
public void accept(int acceptorID) throws IOException
|
||||
{
|
||||
spins.incrementAndGet();
|
||||
throw new IOException("explicitly_thrown_by_test");
|
||||
}
|
||||
};
|
||||
server.addConnector(connector);
|
||||
server.start();
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(1000);
|
||||
assertThat(spins.get(), Matchers.lessThan(5L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue