Author: craigmcc Date: Thu Apr 14 22:32:30 2005 New Revision: 161390 URL: http://svn.apache.org/viewcvs?view=rev&rev=161390 Log: Add a new "findbugs" target to build.xml to run the FindBugs tool <http://findbugs.sourceforge.net>. Cool tool!
Clean up several issues reported by findbugs -- including a real functionality bug in TokenProcessor due to a botched copy-n-paste exercise. The remaining nine warnings are all related to the fact that the org.apache.commons.chain.impl.ContextBase class "extends HashMap" instead of "extends AbstractMap", and therefore inherits the "implements Serializable" characteristic of HashMap. It's pretty dubious whether Context implementations should be *required* to be Serializable, but this needs to be discussed on the Commons Dev list. Modified: struts/shale/trunk/core-library/build.properties.sample struts/shale/trunk/core-library/build.xml struts/shale/trunk/core-library/src/java/org/apache/shale/remote/ContextAttributes.java struts/shale/trunk/core-library/src/java/org/apache/shale/remote/RequestAttributes.java struts/shale/trunk/core-library/src/java/org/apache/shale/remote/SessionAttributes.java struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java Modified: struts/shale/trunk/core-library/build.properties.sample URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/build.properties.sample?view=diff&r1=161389&r2=161390 ============================================================================== --- struts/shale/trunk/core-library/build.properties.sample (original) +++ struts/shale/trunk/core-library/build.properties.sample Thu Apr 14 22:32:30 2005 @@ -37,6 +37,10 @@ # Jakarta Commons Digester library digester.home = /usr/local/commons-digester-1.6 +# (Optional) The absolute or relative pathname of the directory containing +# the "findbugs" tool (http://findbugs.sourceforge/net/) +findbugs.home = /usr/local/findbugs-0.8.6 + # The absolute or relative pathname of the JavaServer Faces # implementation jsf.home = /usr/local/jsf-1_1_01 Modified: struts/shale/trunk/core-library/build.xml URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/build.xml?view=diff&r1=161389&r2=161390 ============================================================================== --- struts/shale/trunk/core-library/build.xml (original) +++ struts/shale/trunk/core-library/build.xml Thu Apr 14 22:32:30 2005 @@ -19,7 +19,7 @@ --> -<project name="Struts 2.X 'Shale' Proposal" default="library" basedir="."> +<project name="Shale Core Library" default="library" basedir="."> <!-- ===================== Initialize Property Values ==================== --> @@ -36,6 +36,7 @@ <property name="beanutils.home" value="/usr/local/commons-beanutils-1.7.0"/> <property name="chain.home" value="/usr/local/commons-chain-1.0"/> <property name="digester.home" value="/usr/local/commons-digester-1.6"/> + <property name="findbugs.home" value="/usr/local/findbugs-0.8.6"/> <property name="jsf.home" value="/usr/local/jsf-1_1_01"/> <property name="junit.home" value="/usr/local/junit-3.8.1"/> <property name="logging.home" value="/usr/local/commons-logging-1.0.4"/> @@ -87,6 +88,10 @@ <property name="compile.optimize" value="true"/> + <!-- Findbugs Defaults --> + <property name="findbugs.outputFile" value="${basedir}/core-library-fb.html"/> + + <!-- Unit Test Defaults --> <property name="test.haltonerror" value="true"/> <property name="test.haltonfailure" value="true"/> @@ -116,6 +121,23 @@ </path> + <!-- Findbugs Classpath --> + <path id="findbugs.classpath"> + <pathelement location="${commons-beanutils.jar}"/> + <pathelement location="${commons-chain.jar}"/> + <pathelement location="${commons-digester.jar}"/> + <pathelement location="${commons-logging.jar}"/> + <pathelement location="${findbugs.home}/lib/findbugs-ant.jar"/> + <pathelement location="${jsf-api.jar}"/> + <pathelement location="${jsp-api.jar}"/> + <pathelement location="${servlet-api.jar}"/> + <pathelement location="${spring-beans.jar}"/> + <pathelement location="${spring-context.jar}"/> + <pathelement location="${spring-core.jar}"/> + <pathelement location="${spring-web.jar}"/> + </path> + + <!-- Test Classpath --> <path id="test.classpath"> <pathelement location="${commons-beanutils.jar}"/> @@ -331,6 +353,29 @@ <fileset dir="src" excludes="**/.svn/**"/> </copy> + </target> + + + <!-- =========================== Find Bugs =============================== --> + + + <target name="findbugs" depends="library"> + + <taskdef name="findbugs" + classname="edu.umd.cs.findbugs.anttask.FindBugsTask" + classpathref="findbugs.classpath"/> + + <findbugs home="${findbugs.home}" + output="html" + outputFile="${findbugs.outputFile}" + reportLevel="low" + workHard="true"> + <auxClasspath + refid="findbugs.classpath"/> + <sourcePath path="${basedir}/src/java"/> + <class location="${basedir}/target/lib/shale.jar"/> + <class location="${basedir}/target/lib/shale-spring.jar"/> + </findbugs> </target> Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/remote/ContextAttributes.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/remote/ContextAttributes.java?view=diff&r1=161389&r2=161390 ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/remote/ContextAttributes.java (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/remote/ContextAttributes.java Thu Apr 14 22:32:30 2005 @@ -127,10 +127,10 @@ public void putAll(Map map) { - Iterator keys = map.keySet().iterator(); - while (keys.hasNext()) { - String key = (String) keys.next(); - context.setAttribute(key, map.get(key)); + Iterator entries = map.entrySet().iterator(); + while (entries.hasNext()) { + Map.Entry entry = (Map.Entry) entries.next(); + context.setAttribute((String) entry.getKey(), entry.getValue()); } } Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/remote/RequestAttributes.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/remote/RequestAttributes.java?view=diff&r1=161389&r2=161390 ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/remote/RequestAttributes.java (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/remote/RequestAttributes.java Thu Apr 14 22:32:30 2005 @@ -127,10 +127,10 @@ public void putAll(Map map) { - Iterator keys = map.keySet().iterator(); - while (keys.hasNext()) { - String key = (String) keys.next(); - request.setAttribute(key, map.get(key)); + Iterator entries = map.entrySet().iterator(); + while (entries.hasNext()) { + Map.Entry entry = (Map.Entry) entries.next(); + request.setAttribute((String) entry.getKey(), entry.getValue()); } } Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/remote/SessionAttributes.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/remote/SessionAttributes.java?view=diff&r1=161389&r2=161390 ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/remote/SessionAttributes.java (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/remote/SessionAttributes.java Thu Apr 14 22:32:30 2005 @@ -127,10 +127,10 @@ public void putAll(Map map) { - Iterator keys = map.keySet().iterator(); - while (keys.hasNext()) { - String key = (String) keys.next(); - session.setAttribute(key, map.get(key)); + Iterator entries = map.entrySet().iterator(); + while (entries.hasNext()) { + Map.Entry entry = (Map.Entry) entries.next(); + session.setAttribute((String) entry.getKey(), entry.getValue()); } } Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java?view=diff&r1=161389&r2=161390 ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/util/TokenProcessor.java Thu Apr 14 22:32:30 2005 @@ -65,7 +65,9 @@ if (current == previous) { current++; } - byte now[] = new Long(current).toString().getBytes(); + previous = current; + // byte now[] = new Long(current).toString().getBytes(); + byte now[] = Long.toString(current).getBytes(); // Calculate the new transaction token value String token = null; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]