Clear remainder of current FindBugs issues in unit tests
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 1 Mar 2011 09:33:57 +0000 (09:33 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 1 Mar 2011 09:33:57 +0000 (09:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1075742 13f79535-47bb-0310-9956-ffa450edef68

res/findbugs/filter-false-positives.xml
test/org/apache/catalina/tribes/demos/CoordinationDemo.java
test/org/apache/tomcat/util/net/TesterSupport.java

index 886ff61..92b4e41 100644 (file)
     <Bug code="ST" />
   </Match>
   <Match>
+    <Class name="org.apache.catalina.startup.TestTomcatClassLoader$ClassLoaderReport"/>
+    <Bug code="Se"/>
+  </Match>
+  <Match>
+    <Class name="org.apache.catalina.tribes.demos.EchoRpcTest" />
+    <Method name="run"/>
+    <Bug code="REC" />
+  </Match>
+  <Match>
     <Class name="org.apache.catalina.tribes.demos.EchoRpcTest$SystemExit" />
     <Bug code="Dm" />
   </Match>
     <Bug code="NP" />
   </Match>
   <Match>
+    <Class name="org.apache.catalina.tribes.demos.LoadTest" />
+    <Method name="memberAdded"/>
+    <Bug code="NN" />
+  </Match>
+  <Match>
+    <Class name="org.apache.catalina.tribes.demos.LoadTest" />
+    <Method name="run"/>
+    <Or>
+      <Bug code="REC" />
+      <Bug code="UW" />
+    </Or>
+  </Match>
+  <Match>
+    <Class name="org.apache.catalina.tribes.demos.LoadTest$SystemExit" />
+    <Bug code="Dm" />
+  </Match>
+  <Match>
     <Class name="org.apache.catalina.tribes.demos.MapDemo$SystemExit" />
     <Bug code="Dm" />
   </Match>
index 0bc00e1..504c0e1 100644 (file)
@@ -113,7 +113,12 @@ public class CoordinationDemo {
         for ( int i=0; i<status.length; i++ ) status[i] = new Status(this);
         printScreen();
         String l = reader.readLine();
-        String[] args = tokenize(l);
+        String[] args;
+        if (l == null) {
+            args = new String[] {};
+        } else {
+            args = tokenize(l);
+        }
         while ( args.length >= 1 && (!"quit".equalsIgnoreCase(args[0]))) {
             if ("start".equalsIgnoreCase(args[0])) {
                 cmdStart(args);
@@ -123,7 +128,9 @@ public class CoordinationDemo {
             }
             printScreen();
             l = reader.readLine();
-            args = tokenize(l);
+            if (l != null) {
+                args = tokenize(l);
+            }
         }
         for ( int i=0; i<status.length; i++ ) status[i].stop();
     }
@@ -275,8 +282,10 @@ public class CoordinationDemo {
                 Member lm = channel.getLocalMember(false);
                 local = lm!=null?lm.getName():"";
                 coord = interceptor!=null && interceptor.getCoordinator()!=null?interceptor.getCoordinator().getName():"";
-                viewId = getByteString(interceptor.getViewId()!=null?interceptor.getViewId().getBytes():new byte[0]);
-                count = String.valueOf(interceptor.getView().length);
+                if (interceptor != null) {
+                    viewId = getByteString(interceptor.getViewId()!=null?interceptor.getViewId().getBytes():new byte[0]);
+                    count = String.valueOf(interceptor.getView().length);
+                }
             }
             buf.append(leftfill(local,30," "));
             buf.append(leftfill(startstatus, 10, " "));
index db373db..1e19478 100644 (file)
@@ -18,6 +18,7 @@ package org.apache.tomcat.util.net;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.security.KeyManagementException;
 import java.security.KeyStore;
@@ -102,9 +103,20 @@ public final class TesterSupport {
 
     private static KeyStore getKeyStore(String keystore) throws Exception {
         File keystoreFile = new File(keystore);
-        InputStream is = new FileInputStream(keystoreFile);
         KeyStore ks = KeyStore.getInstance("JKS");
-        ks.load(is, "changeit".toCharArray());
+        InputStream is = null;
+        try {
+            is = new FileInputStream(keystoreFile);
+            ks.load(is, "changeit".toCharArray());
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException ioe) {
+                    // Ignore
+                }
+            }
+        }
         return ks;
     }
 }