From e9e7a72b08b9e235bcedcf30b110547ac8180300 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 30 Mar 2011 13:23:41 +0000 Subject: [PATCH] Avoided division by zero on single CPU boxes. git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2934 7e9141cc-0065-0410-87d8-b60c137991c4 --- .../java/org/eclipse/jetty/server/StressTest.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 c53a86ba5cc..32a6ae7b908 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 @@ -13,16 +13,12 @@ package org.eclipse.jetty.server; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.net.Socket; import java.util.Queue; import java.util.Random; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicInteger; - import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -39,6 +35,9 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class StressTest { private static QueuedThreadPool _threads; @@ -86,7 +85,7 @@ public class StressTest _server.setThreadPool(_threads); _connector = new SelectChannelConnector(); - _connector.setAcceptors(Runtime.getRuntime().availableProcessors()/2); + _connector.setAcceptors(Math.max(1, Runtime.getRuntime().availableProcessors() / 2)); _connector.setAcceptQueueSize(5000); _connector.setMaxIdleTime(30000); _server.addConnector(_connector); @@ -244,7 +243,7 @@ public class StressTest final int other[] = new int[_latencies.length]; long total=0; - + for (int i=0;i<_latencies.length;i++) { Queue latencies=_latencies[i]; @@ -264,7 +263,7 @@ public class StressTest } } other[i]++; - + } }