tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1187826 - in /tomcat/trunk: java/org/apache/tomcat/util/net/ modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/ modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/ test/org/apache/catalina/comet/ test/org/apache/catali...
Date Sat, 22 Oct 2011 23:24:32 GMT
Author: markt
Date: Sat Oct 22 23:24:31 2011
New Revision: 1187826

URL: http://svn.apache.org/viewvc?rev=1187826&view=rev
Log:
Fix some low-hanging FindBugs fruit

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
    tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java
    tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java
    tomcat/trunk/test/org/apache/catalina/comet/TestCometProcessor.java
    tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1187826&r1=1187825&r2=1187826&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Sat Oct 22 23:24:31 2011
@@ -1565,7 +1565,7 @@ public class NioEndpoint extends Abstrac
                                     if (ka!=null) ka.setComet(false);
                                     socket.getPoller().cancelledKey(key, SocketStatus.ERROR,
false);
                                 }
-                                if (socket!=null) nioChannels.offer(socket);
+                                nioChannels.offer(socket);
                                 socket = null;
                                 if ( ka!=null ) keyCache.offer(ka);
                                 ka = null;
@@ -1579,7 +1579,7 @@ public class NioEndpoint extends Abstrac
                             ka = (KeyAttachment) key.attachment();
                             socket.getPoller().cancelledKey(key, SocketStatus.DISCONNECT,
false);
                         }
-                        if (socket!=null) nioChannels.offer(socket);
+                        nioChannels.offer(socket);
                         socket = null;
                         if ( ka!=null ) keyCache.offer(ka);
                         ka = null;

Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java?rev=1187826&r1=1187825&r2=1187826&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java
Sat Oct 22 23:24:31 2011
@@ -128,7 +128,7 @@ public class GenericNamingResourcesFacto
                         // Try a setFoo ( boolean )
                     } else if ("java.lang.Boolean".equals(paramType.getName())
                             || "boolean".equals(paramType.getName())) {
-                        params[0] = new Boolean(value);
+                        params[0] = Boolean.valueOf(value);
 
                         // Try a setFoo ( InetAddress )
                     } else if ("java.net.InetAddress".equals(paramType

Modified: tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java?rev=1187826&r1=1187825&r2=1187826&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java
Sat Oct 22 23:24:31 2011
@@ -34,8 +34,8 @@ public class TestConcurrency extends Def
     }
 
     @Override
-    public void setUp() {
-        // TODO Auto-generated method stub
+    public void setUp() throws Exception {
+        super.setUp();
         ds = createDefaultDataSource();
         ds.getPoolProperties().setDriverClassName(Driver.class.getName());
         ds.getPoolProperties().setUrl(Driver.url);

Modified: tomcat/trunk/test/org/apache/catalina/comet/TestCometProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/comet/TestCometProcessor.java?rev=1187826&r1=1187825&r2=1187826&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/comet/TestCometProcessor.java (original)
+++ tomcat/trunk/test/org/apache/catalina/comet/TestCometProcessor.java Sat Oct 22 23:24:31
2011
@@ -214,7 +214,7 @@ public class TestCometProcessor extends 
             // Failure expected only expected for the fail on begin
             // Failure at any later stage and the reponse headers (including the
             // 200 response code will already have been sent to the client
-            if (initParam == SimpleCometServlet.FAIL_ON_BEGIN) {
+            if (SimpleCometServlet.FAIL_ON_BEGIN.equals(initParam)) {
                 assertEquals("HTTP/1.1 500 Internal Server Error", response[0]);
                 alv.validateAccessLog(1, 500, 0, 1000);
             } else {

Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java?rev=1187826&r1=1187825&r2=1187826&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
Sat Oct 22 23:24:31 2011
@@ -28,17 +28,18 @@ import org.apache.catalina.tribes.group.
 
 public class TestNonBlockingCoordinator {
 
+    private static final int CHANNEL_COUNT = 10;
+
     private GroupChannel[] channels = null;
     private NonBlockingCoordinator[] coordinators = null;
-    private final int channelCount = 10;
 
     @Before
     public void setUp() throws Exception {
         System.out.println("Setup");
-        channels = new GroupChannel[channelCount];
-        coordinators = new NonBlockingCoordinator[channelCount];
-        Thread[] threads = new Thread[channelCount];
-        for ( int i=0; i<channelCount; i++ ) {
+        channels = new GroupChannel[CHANNEL_COUNT];
+        coordinators = new NonBlockingCoordinator[CHANNEL_COUNT];
+        Thread[] threads = new Thread[CHANNEL_COUNT];
+        for ( int i=0; i<CHANNEL_COUNT; i++ ) {
             channels[i] = new GroupChannel();
             coordinators[i] = new NonBlockingCoordinator();
             channels[i].addInterceptor(coordinators[i]);
@@ -56,10 +57,10 @@ public class TestNonBlockingCoordinator 
                 }
             };
         }
-        for (int i = 0; i < channelCount; i++) {
+        for (int i = 0; i < CHANNEL_COUNT; i++) {
             threads[i].start();
         }
-        for (int i = 0; i < channelCount; i++) {
+        for (int i = 0; i < CHANNEL_COUNT; i++) {
             threads[i].join();
         }
         Thread.sleep(1000);
@@ -68,7 +69,7 @@ public class TestNonBlockingCoordinator 
     @Test
     public void testCoord1() throws Exception {
         int expectedCount = channels[0].getMembers().length;
-        for (int i = 1; i < channelCount; i++) {
+        for (int i = 1; i < CHANNEL_COUNT; i++) {
             assertEquals("Message count expected to be equal.", expectedCount,
                     channels[i].getMembers().length);
         }
@@ -82,7 +83,7 @@ public class TestNonBlockingCoordinator 
                 /* Ignore */
             }
         }
-        for (int i = 0; i < channelCount; i++) {
+        for (int i = 0; i < CHANNEL_COUNT; i++) {
             assertEquals(member, coordinators[i].getCoordinator());
         }
         System.out.println("Coordinator[1] is:" + member);
@@ -93,7 +94,7 @@ public class TestNonBlockingCoordinator 
         Member member = coordinators[1].getCoordinator();
         System.out.println("Coordinator[2a] is:" + member);
         int index = -1;
-        for ( int i=0; i<channelCount; i++ ) {
+        for ( int i=0; i<CHANNEL_COUNT; i++ ) {
             if ( channels[i].getLocalMember(false).equals(member) ) {
                 System.out.println("Shutting down:" + channels[i].getLocalMember(true).toString());
                 channels[i].stop(Channel.DEFAULT);
@@ -109,7 +110,7 @@ public class TestNonBlockingCoordinator 
         }
         System.out.println("Member count:"+channels[index].getMembers().length);
         member = coordinators[index].getCoordinator();
-        for (int i = 1; i < channelCount; i++) {
+        for (int i = 1; i < CHANNEL_COUNT; i++) {
             if (i != dead) {
                 assertEquals(member, coordinators[i].getCoordinator());
             }
@@ -120,7 +121,7 @@ public class TestNonBlockingCoordinator 
     @After
     public void tearDown() throws Exception {
         System.out.println("tearDown");
-        for ( int i=0; i<channelCount; i++ ) {
+        for ( int i=0; i<CHANNEL_COUNT; i++ ) {
             channels[i].stop(Channel.DEFAULT);
         }
     }



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


Mime
View raw message