tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1142111 - /tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
Date Fri, 01 Jul 2011 22:44:05 GMT
Author: markt
Date: Fri Jul  1 22:44:04 2011
New Revision: 1142111

URL: http://svn.apache.org/viewvc?rev=1142111&view=rev
Log:
Prevent test failures when two objects get generated with the same hashCode

Modified:
    tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java

Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java?rev=1142111&r1=1142110&r2=1142111&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java Fri Jul  1 22:44:04
2011
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
@@ -335,6 +336,7 @@ public class TestStandardWrapper extends
     public static final int BUG51445_THREAD_COUNT = 5;
     
     public static CountDownLatch latch = null;
+    public static AtomicInteger counter = new AtomicInteger(0);
 
     public void testBug51445AddServlet() throws Exception {
 
@@ -459,6 +461,14 @@ public class TestStandardWrapper extends
         private static final long LATCH_TIMEOUT = 60;
 
         private int data = 0;
+        private int counter;
+        
+        public Bug51445Servlet() {
+            // Use this rather than hashCode since in some environments,
+            // multiple instances of this object were created with the same
+            // hashCode
+            counter = TestStandardWrapper.counter.incrementAndGet();
+        }
 
         @Override
         protected void doGet(HttpServletRequest req, HttpServletResponse resp)
@@ -481,7 +491,7 @@ public class TestStandardWrapper extends
                 resp.getWriter().print("Latch await failed");
             }
             resp.getWriter().print(",");
-            resp.getWriter().print(hashCode());
+            resp.getWriter().print(counter);
         }
 
         @Override



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message