[jboss-cvs] JBossAS SVN: r95037 - in projects/annotations/trunk: core/src/main/java/org/jboss/papaki/impl and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 16 09:57:21 EDT 2009


Author: jesper.pedersen
Date: 2009-10-16 09:57:21 -0400 (Fri, 16 Oct 2009)
New Revision: 95037

Modified:
   projects/annotations/trunk/build.xml
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AbstractAnnotationScanner.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistinputstream/JavassistInputStream.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/util/ClassScanner.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/util/JarScanner.java
   projects/annotations/trunk/indexer/src/main/java/org/jboss/papaki/indexer/FileUtil.java
   projects/annotations/trunk/tools/findbugs/filter.xml
Log:
[JBANN-39] Set Findbugs report level to low

Modified: projects/annotations/trunk/build.xml
===================================================================
--- projects/annotations/trunk/build.xml	2009-10-16 13:37:48 UTC (rev 95036)
+++ projects/annotations/trunk/build.xml	2009-10-16 13:57:21 UTC (rev 95037)
@@ -218,7 +218,8 @@
     <findbugs home="${basedir}/tools/findbugs/lib/"
               output="html"
               outputFile="${reports.dir}/findbugs/findbugs.html" 
-              excludeFilter="${basedir}/tools/findbugs/filter.xml">
+              excludeFilter="${basedir}/tools/findbugs/filter.xml"
+              reportLevel="low">
       <auxClasspath>
         <fileset dir="${lib.dir}/core">
           <include name="*.jar"/>
@@ -231,7 +232,8 @@
     <findbugs home="${basedir}/tools/findbugs/lib/"
               output="xml:withMessages"
               outputFile="${reports.dir}/findbugs/findbugs.xml" 
-              excludeFilter="${basedir}/tools/findbugs/filter.xml">
+              excludeFilter="${basedir}/tools/findbugs/filter.xml"
+              reportLevel="low">
       <auxClasspath>
         <fileset dir="${lib.dir}/core">
           <include name="*.jar"/>

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AbstractAnnotationScanner.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AbstractAnnotationScanner.java	2009-10-16 13:37:48 UTC (rev 95036)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AbstractAnnotationScanner.java	2009-10-16 13:57:21 UTC (rev 95037)
@@ -37,6 +37,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Modifier;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -134,7 +135,7 @@
                log.warning("Protocol not supported: " + url);
             }
          }
-         catch (Exception e)
+         catch (URISyntaxException use)
          {
             // Nothing we can do
          }

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistinputstream/JavassistInputStream.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistinputstream/JavassistInputStream.java	2009-10-16 13:37:48 UTC (rev 95036)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistinputstream/JavassistInputStream.java	2009-10-16 13:57:21 UTC (rev 95037)
@@ -129,7 +129,6 @@
                   while ((isJava5 == null || isJava5.booleanValue()) && entries.hasMoreElements())
                   {
                      JarEntry je = entries.nextElement();
-                     String name = je.getName();
 
                      if (je.getName().endsWith(".class"))
                      {
@@ -166,25 +165,41 @@
                      {
                         String className = classes.get(i);
                         File clz = new File(jarFile, className.replace('.', '/') + ".class");
-                        InputStream is = new BufferedInputStream(new FileInputStream(clz));
-                        CtClass ctClass = cp.makeClass(is);
-                        is.close();
+                        InputStream is = null;
 
-                        if (isJava5 == null)
+                        try
                         {
-                           if (ctClass.getClassFile2().getMajorVersion() >= ClassFile.JAVA_5)
+                           is = new BufferedInputStream(new FileInputStream(clz));
+                           CtClass ctClass = cp.makeClass(is);
+
+                           if (isJava5 == null)
                            {
-                              isJava5 = Boolean.TRUE;
+                              if (ctClass.getClassFile2().getMajorVersion() >= ClassFile.JAVA_5)
+                              {
+                                 isJava5 = Boolean.TRUE;
+                              }
+                              else
+                              {
+                                 isJava5 = Boolean.FALSE;
+                              }
                            }
-                           else
+
+                           if (isJava5.booleanValue() && !ctClass.isAnnotation())
                            {
-                              isJava5 = Boolean.FALSE;
+                              processClass(ctClass, ari, annotationToClasses, classInfo);
                            }
                         }
-
-                        if (isJava5.booleanValue() && !ctClass.isAnnotation())
+                        finally
                         {
-                           processClass(ctClass, ari, annotationToClasses, classInfo);
+                           try
+                           {
+                              if (is != null)
+                                 is.close();
+                           }
+                           catch (IOException ignore)
+                           {
+                              // Ignore
+                           }
                         }
                      }
                   }

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/util/ClassScanner.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/util/ClassScanner.java	2009-10-16 13:37:48 UTC (rev 95036)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/util/ClassScanner.java	2009-10-16 13:57:21 UTC (rev 95037)
@@ -65,31 +65,24 @@
          {
             for (File classFile : classFiles)
             {
-               try
-               {
-                  String className = classFile.getCanonicalPath();
+               String className = classFile.getCanonicalPath();
                   
-                  if (className.startsWith(rootPath))
-                  {
-                     className = className.substring(rootPath.length() + 1);
-                  }
-
-                  if (className.endsWith(".class"))
-                  {
-                     className = className.substring(0, className.lastIndexOf(".class"));
-                  }
-
-                  className = className.replace(File.separatorChar, '.');
-                  
-                  if (trace)
-                     log.finest("Class=" + className);
-
-                  result.add(className);
+               if (className.startsWith(rootPath))
+               {
+                  className = className.substring(rootPath.length() + 1);
                }
-               catch (Exception e)
+
+               if (className.endsWith(".class"))
                {
-                  // Nothing we can do
+                  className = className.substring(0, className.lastIndexOf(".class"));
                }
+
+               className = className.replace(File.separatorChar, '.');
+               
+               if (trace)
+                  log.finest("Class=" + className);
+
+               result.add(className);
             }
          }
       } 

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/util/JarScanner.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/util/JarScanner.java	2009-10-16 13:37:48 UTC (rev 95036)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/util/JarScanner.java	2009-10-16 13:57:21 UTC (rev 95037)
@@ -23,6 +23,7 @@
 package org.jboss.papaki.util;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
@@ -56,58 +57,62 @@
    {
       List<String> result = new ArrayList<String>();
 
-      try
+      log.fine("Scanning " + root);
+
+      List<File> jarFiles = null;
+      if (root.isFile())
       {
-         log.fine("Scanning " + root);
-
-         List<File> jarFiles = null;
-         if (root.isFile())
+         jarFiles = new ArrayList<File>();
+         jarFiles.add(root);
+      }
+      else
+      {
+         jarFiles = ExtensionScanner.scan(root, ".jar");
+      }
+      
+      for (File jarFile : jarFiles)
+      {
+         JarFile jar = null;
+         try
          {
-            jarFiles = new ArrayList<File>();
-            jarFiles.add(root);
-         }
-         else
-         {
-            jarFiles = ExtensionScanner.scan(root, ".jar");
-         }
+            jar = new JarFile(jarFile);
+            Enumeration<JarEntry> entries = jar.entries();
 
-         for (File jarFile : jarFiles)
-         {
-            try
+            while (entries.hasMoreElements())
             {
-               JarFile jar = new JarFile(jarFile);
-               Enumeration<JarEntry> entries = jar.entries();
+               JarEntry je = entries.nextElement();
+               String name = je.getName();
 
-               while (entries.hasMoreElements())
+               if (name.endsWith(".class"))
                {
-                  JarEntry je = entries.nextElement();
-                  String name = je.getName();
+                  name = name.replace('/', '.');
+                  name = name.substring(0, name.lastIndexOf(".class"));
 
-                  if (name.endsWith(".class"))
-                  {
-                     name = name.replace('/', '.');
-                     name = name.substring(0, name.lastIndexOf(".class"));
+                  if (trace)
+                     log.finest("Class=" + name);
 
-                     if (trace)
-                        log.finest("Class=" + name);
-
-                     result.add(name);
-                  }
+                  result.add(name);
                }
-
-               jar.close();
             }
-            catch (Exception e)
+         }
+         catch (Exception e)
+         {
+            log.log(Level.SEVERE, e.getMessage(), e);
+         }
+         finally
+         {
+            try
             {
-               // Nothing we can do
+               if (jar != null)
+                  jar.close();
             }
+            catch (IOException ignore)
+            {
+               // Ignore
+            }
          }
       }
-      catch (Exception e)
-      {
-         log.log(Level.SEVERE, e.getMessage(), e);
-      }
-    
+
       return result;
    }
 }

Modified: projects/annotations/trunk/indexer/src/main/java/org/jboss/papaki/indexer/FileUtil.java
===================================================================
--- projects/annotations/trunk/indexer/src/main/java/org/jboss/papaki/indexer/FileUtil.java	2009-10-16 13:37:48 UTC (rev 95036)
+++ projects/annotations/trunk/indexer/src/main/java/org/jboss/papaki/indexer/FileUtil.java	2009-10-16 13:57:21 UTC (rev 95037)
@@ -77,9 +77,24 @@
       File manifestFile = new File(directory, "META-INF/MANIFEST.MF");
       if (manifestFile.exists())
       {
-         FileInputStream fis = new FileInputStream(manifestFile);
-         manifest = new Manifest(fis);
-         fis.close();
+         FileInputStream fis = null;
+         try
+         {
+            fis = new FileInputStream(manifestFile);
+            manifest = new Manifest(fis);
+         }
+         finally
+         {
+            try
+            {
+               if (fis != null)
+                  fis.close();
+            }
+            catch (IOException ignore)
+            {
+               // Ignore
+            }
+         }
       }
       else
       {
@@ -87,50 +102,66 @@
          manifest = new Manifest();
       }
 
-      FileOutputStream fos = new FileOutputStream(target);
-      JarOutputStream jos = new JarOutputStream(fos, manifest);
+      JarOutputStream jos = null;
 
-      int bytesRead;
-      byte[] buffer = new byte[4096];
+      try
+      {
+         FileOutputStream fos = new FileOutputStream(target);
+         jos = new JarOutputStream(fos, manifest);
 
-      List<File> entries = findEntries(directory);
+         int bytesRead;
+         byte[] buffer = new byte[4096];
 
-      if (entries != null)
-      {
-         entries.remove(new File("META-INF/MANIFEST.MF"));
+         List<File> entries = findEntries(directory);
 
-         for (File file : entries)
+         if (entries != null)
          {
-            File f = new File(directory, file.getPath());
-            JarEntry entry = new JarEntry(file.getPath());
-            jos.putNextEntry(entry);
+            entries.remove(new File("META-INF/MANIFEST.MF"));
 
-            FileInputStream in = null;
-            try
+            for (File file : entries)
             {
-               in = new FileInputStream(f);
-               while ((bytesRead = in.read(buffer)) != -1)
-                  jos.write(buffer, 0, bytesRead);
-            }
-            finally
-            {
-               if (in != null)
+               File f = new File(directory, file.getPath());
+               JarEntry entry = new JarEntry(file.getPath());
+               jos.putNextEntry(entry);
+
+               FileInputStream in = null;
+               try
                {
-                  try
+                  in = new FileInputStream(f);
+                  while ((bytesRead = in.read(buffer)) != -1)
+                     jos.write(buffer, 0, bytesRead);
+               }
+               finally
+               {
+                  if (in != null)
                   {
-                     in.close(); 
+                     try
+                     {
+                        in.close(); 
+                     }
+                     catch (IOException ioe)
+                     {
+                        // Ignore
+                     }
                   }
-                  catch (IOException ioe)
-                  {
-                     // Ignore
-                  }
                }
             }
          }
+
+         jos.flush();
       }
-
-      jos.flush();
-      jos.close();
+      finally
+      {
+         try
+         {
+            if (jos != null)
+               jos.close();
+         }
+         catch (IOException ignore)
+         {
+            // Ignore
+         }
+      }
    }
 
    /**
@@ -166,21 +197,47 @@
 
          if (!je.isDirectory())
          {
-            InputStream in = new BufferedInputStream(jar.getInputStream(je));
-            OutputStream out = new BufferedOutputStream(new FileOutputStream(copy));
+            InputStream in = null;
+            OutputStream out = null;
 
-            byte[] buffer = new byte[4096];
-            for (;;)
+            try
             {
-               int nBytes = in.read(buffer);
-               if (nBytes <= 0)
-                  break;
+               in = new BufferedInputStream(jar.getInputStream(je));
+               out = new BufferedOutputStream(new FileOutputStream(copy));
 
-               out.write(buffer, 0, nBytes);
+               byte[] buffer = new byte[4096];
+               for (;;)
+               {
+                  int nBytes = in.read(buffer);
+                  if (nBytes <= 0)
+                     break;
+
+                  out.write(buffer, 0, nBytes);
+               }
+               out.flush();
             }
-            out.flush();
-            out.close();
-            in.close();
+            finally
+            {
+               try
+               {
+                  if (out != null)
+                     out.close();
+               }
+               catch (IOException ignore)
+               {
+                  // Ignore
+               }
+
+               try
+               {
+                  if (in != null)
+                     in.close();
+               }
+               catch (IOException ignore)
+               {
+                  // Ignore
+               }
+            }
          }
          else
          {
@@ -199,7 +256,7 @@
     */
    public static void recursiveDelete(File f) throws IOException
    {
-      if (f.exists())
+      if (f != null && f.exists())
       {
          File[] files = f.listFiles();
          if (files != null)

Modified: projects/annotations/trunk/tools/findbugs/filter.xml
===================================================================
--- projects/annotations/trunk/tools/findbugs/filter.xml	2009-10-16 13:37:48 UTC (rev 95036)
+++ projects/annotations/trunk/tools/findbugs/filter.xml	2009-10-16 13:57:21 UTC (rev 95037)
@@ -1,3 +1,13 @@
 <FindBugsFilter>
 
+  <Match>
+    <Class name="org.jboss.papaki.Annotation"/>
+    <Bug code="PZLA"/>
+  </Match>
+
+  <Match>
+    <Class name="org.jboss.papaki.impl.ClassInfo"/>
+    <Bug code="Se"/>
+  </Match>
+
 </FindBugsFilter>




More information about the jboss-cvs-commits mailing list