Author: markt
Date: Sat Jan 12 21:20:27 2013
New Revision: 1432517
URL: http://svn.apache.org/viewvc?rev=1432517&view=rev
Log:
Fix threading issue reported by FindBugs
Modified:
tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java
Modified:
tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java?rev=1432517&r1=1432516&r2=1432517&view=diff
==============================================================================
---
tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java
(original)
+++
tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java
Sat Jan 12 21:20:27 2013
@@ -23,6 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.management.AttributeChangeNotification;
import javax.management.Notification;
@@ -122,7 +123,7 @@ public class TestSlowQueryReport extends
st.close();
}
System.out.println("Stats:"+stats);
- assertEquals("Expecting to have received "+(2*count)+"
notifications.",2*count, listener.notificationCount);
+ assertEquals("Expecting to have received "+(2*count)+"
notifications.",2*count, listener.notificationCount.get());
con.close();
tearDown();
//make sure we actually did clean up when the pool closed
@@ -184,11 +185,11 @@ public class TestSlowQueryReport extends
public class ClientListener implements NotificationListener {
- volatile int notificationCount = 0;
+ AtomicInteger notificationCount = new AtomicInteger(0);
@Override
public void handleNotification(Notification notification,
Object handback) {
- notificationCount++;
+ notificationCount.incrementAndGet();
System.out.println("\nReceived notification:");
System.out.println("\tClassName: " +
notification.getClass().getName());
System.out.println("\tSource: " + notification.getSource());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]