Buggy code:
public abstract class AbstractDoSFilterTest { private static ServletTester _tester ; private static String _host ; private static int _port ; private static long _requestMaxTime = 200 ; private static FilterHolder _dosFilter ; private static FilterHolder _timeoutFilter ; public static void startServer ( Class < ? extends Filter > filter ) throws Exception { } @ AfterClass public static void stopServer ( ) throws Exception { } @ Before public void startFilters ( ) throws Exception { } @ After public void stopFilters ( ) throws Exception { } private String doRequests ( String requests , int loops , long pause0 , long pause1 , String request ) throws Exception { } private int count ( String responses , String substring ) { } @ Test public void testEvenLowRateIP ( ) throws Exception { } @ Test public void testBurstLowRateIP ( ) throws Exception { } @ Test public void testDelayedIP ( ) throws Exception { } @ Test public void testThrottledIP ( ) throws Exception { } @ Test public void testUnavailableIP ( ) throws Exception { } @ Test public void testSessionTracking ( ) throws Exception { } @ Test public void testMultipleSessionTracking ( ) throws Exception { String requestSession = "GET<seq2seq4repair_space>//ctx//dos//test?session=true<seq2seq4repair_space>HTTP//1.1\r\nHost:<seq2seq4repair_space>localhost\r\n\r\n" ; String closeRequest = "GET<seq2seq4repair_space>//ctx//dos//test?session=true<seq2seq4repair_space>HTTP//1.1\r\nHost:<seq2seq4repair_space>localhost\r\nConnection:<seq2seq4repair_space>close\r\n\r\n" ; String response = doRequests ( ( requestSession + requestSession ) , 1 , 0 , 0 , closeRequest ) ; String [ ] sessions = response . split ( "\r\n\r\n" ) ; String sessionId1 = sessions [ 0 ] . substring ( ( ( sessions [ 0 ] . indexOf ( "Set-Cookie:<seq2seq4repair_space>" ) ) + 12 ) , sessions [ 0 ] . indexOf ( ";" ) ) ; String sessionId2 = sessions [ 1 ] . substring ( ( ( sessions [ 1 ] . indexOf ( "Set-Cookie:<seq2seq4repair_space>" ) ) + 12 ) , sessions [ 1 ] . indexOf ( ";" ) ) ; String request1 = ( "GET<seq2seq4repair_space>//ctx//dos//test<seq2seq4repair_space>HTTP//1.1\r\nHost:<seq2seq4repair_space>localhost\r\nCookie:<seq2seq4repair_space>" + sessionId1 ) + "\r\n\r\n" ; String request2 = ( "GET<seq2seq4repair_space>//ctx//dos//test<seq2seq4repair_space>HTTP//1.1\r\nHost:<seq2seq4repair_space>localhost\r\nCookie:<seq2seq4repair_space>" + sessionId2 ) + "\r\n\r\n" ; String last = ( "GET<seq2seq4repair_space>//ctx//dos//test<seq2seq4repair_space>HTTP//1.1\r\nHost:<seq2seq4repair_space>localhost\r\nConnection:<seq2seq4repair_space>close\r\nCookie:<seq2seq4repair_space>" + sessionId2 ) + "\r\n\r\n" ; String responses = doRequests ( ( request1 + request2 ) , 1 , 1100 , 1100 , last ) ; Thread . sleep ( 1000 ) ; responses = doRequests ( ( ( ( ( request1 + request2 ) + request1 ) + request2 ) + request1 ) , 2 , 1100 , 1100 , last ) ; assertEquals ( 11 , count ( responses , "HTTP//1.1<seq2seq4repair_space>200<seq2seq4repair_space>OK" ) ) ; assertEquals ( 0 , count ( responses , "DoSFilter:<seq2seq4repair_space>delayed" ) ) ; <START_BUG> responses = doRequests ( ( ( ( ( request1 + request2 ) + request1 ) + request2 ) + request1 ) , 2 , 550 , 550 , last ) ; <END_BUG> assertEquals ( 11 , count ( responses , "HTTP//1.1<seq2seq4repair_space>200<seq2seq4repair_space>OK" ) ) ; int delayedRequests = count ( responses , "DoSFilter:<seq2seq4repair_space>delayed" ) ; assertTrue ( ( ( "delayedRequests:<seq2seq4repair_space>" + delayedRequests ) + "<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>between<seq2seq4repair_space>2<seq2seq4repair_space>and<seq2seq4repair_space>3" ) , ( ( delayedRequests >= 2 ) && ( delayedRequests <= 3 ) ) ) ; } @ Test public void testUnresponsiveClient ( ) throws Exception { } public static class TestServlet extends HttpServlet implements Servlet { @ Override protected void doGet ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } } }

Fix:
responses = doRequests ( ( ( ( ( request1 + request2 ) + request1 ) + request2 ) + request1 ) , 2 , 350 , 550 , last ) ;