You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2014/03/03 07:49:21 UTC
svn commit: r1573458 - in /commons/proper/weaver/trunk: ./ ant/lib/
build-tools/src/main/resources/org/apache/commons/weaver/ maven-plugin/
modules/normalizer/weaver/ modules/privilizer/weaver/ processor/
processor/src/main/java/org/apache/commons/weav...
Author: mbenson
Date: Mon Mar 3 06:49:20 2014
New Revision: 1573458
URL: http://svn.apache.org/r1573458
Log:
findbugs
Added:
commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml
- copied, changed from r1561720, commons/proper/lang/trunk/findbugs-exclude-filter.xml
Modified:
commons/proper/weaver/trunk/ant/lib/pom.xml
commons/proper/weaver/trunk/maven-plugin/pom.xml
commons/proper/weaver/trunk/modules/normalizer/weaver/pom.xml
commons/proper/weaver/trunk/modules/privilizer/weaver/pom.xml
commons/proper/weaver/trunk/pom.xml
commons/proper/weaver/trunk/processor/pom.xml
commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/Finder.java
commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java
commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java
Modified: commons/proper/weaver/trunk/ant/lib/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/ant/lib/pom.xml?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/ant/lib/pom.xml (original)
+++ commons/proper/weaver/trunk/ant/lib/pom.xml Mon Mar 3 06:49:20 2014
@@ -166,6 +166,14 @@ under the License.
<headerLocation>org/apache/commons/weaver/license-header.txt</headerLocation>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <excludeFilterFile>/org/apache/commons/weaver/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
</project>
Copied: commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml (from r1561720, commons/proper/lang/trunk/findbugs-exclude-filter.xml)
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml?p2=commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml&p1=commons/proper/lang/trunk/findbugs-exclude-filter.xml&r1=1561720&r2=1573458&rev=1573458&view=diff
==============================================================================
--- commons/proper/lang/trunk/findbugs-exclude-filter.xml (original)
+++ commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml Mon Mar 3 06:49:20 2014
@@ -23,122 +23,26 @@
-->
<FindBugsFilter>
- <!-- Reason: Optimization to use == -->
+ <!-- Reason: require that code execution hierarchy invoking CleanProcessor
+ has privileges directly assigned
+ -->
<Match>
- <Class name="org.apache.commons.lang3.BooleanUtils" />
- <Or>
- <Method name="toBoolean" />
- <Method name="toBooleanObject" />
- </Or>
- <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ" />
- </Match>
- <Match>
- <Class name="org.apache.commons.lang3.BooleanUtils" />
- <Method name="toBoolean" />
- <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN" />
- </Match>
-
- <!-- Reason: Behavior documented in javadoc -->
- <Match>
- <Class name="org.apache.commons.lang3.BooleanUtils" />
- <Or>
- <Method name="negate" />
- <Method name="toBooleanObject" />
- </Or>
- <Bug pattern="NP_BOOLEAN_RETURN_NULL" />
- </Match>
-
- <!-- Reason: base class cannot be changed and field is properly checked against null so behavior is OK -->
- <Match>
- <Class name="org.apache.commons.lang3.text.ExtendedMessageFormat" />
- <Method name="applyPattern" />
- <Bug pattern="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR" />
- </Match>
-
- <!-- Reason: Optimization to use == -->
- <Match>
- <Class name="org.apache.commons.lang3.StringUtils" />
- <Method name="indexOfDifference"/>
- <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ" />
+ <Class name="org.apache.commons.weaver.CleanProcessor" />
+ <Method name="clean" />
+ <Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED" />
</Match>
- <!-- Reason: Very much intended to do a fall through on the switch -->
+ <!-- Reason: require that code execution hierarchy invoking WeaveProcessor
+ has privileges directly assigned
+ -->
<Match>
- <Class name="org.apache.commons.lang3.math.NumberUtils" />
- <Method name="createNumber"/>
- <Bug pattern="SF_SWITCH_FALLTHROUGH" />
+ <Class name="org.apache.commons.weaver.WeaveProcessor" />
+ <Method name="weave" />
+ <Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED" />
</Match>
- <!-- Reason: Very much intended to do a fall through on the switch -->
- <Match>
- <Class name="org.apache.commons.lang3.time.DateUtils" />
- <Method name="getFragment"/>
- <Bug pattern="SF_SWITCH_FALLTHROUGH" />
- </Match>
-
- <!-- Reason: hashCode is lazily loaded in Range classes -->
- <!-- TODO: Work out why regex didn't work here -->
- <Match>
- <Class name="org.apache.commons.lang3.math.DoubleRange" />
- <Field name="hashCode" />
- <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
- </Match>
- <Match>
- <Class name="org.apache.commons.lang3.math.FloatRange" />
- <Field name="hashCode" />
- <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
- </Match>
- <Match>
- <Class name="org.apache.commons.lang3.math.IntRange" />
- <Field name="hashCode" />
- <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
- </Match>
+ <!-- Reason: generated code -->
<Match>
- <Class name="org.apache.commons.lang3.math.LongRange" />
- <Field name="hashCode" />
- <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
+ <Class name="org.apache.commons.weaver.maven.HelpMojo" />
</Match>
- <Match>
- <Class name="org.apache.commons.lang3.math.NumberRange" />
- <Field name="hashCode" />
- <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
- </Match>
-
- <!-- Reason: toProperString is lazily loaded -->
- <Match>
- <Class name="org.apache.commons.lang3.math.Fraction" />
- <Field name="toProperString" />
- <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
- </Match>
-
- <!-- Reason: It does call super.clone(), but via a subsequent method -->
- <Match>
- <Class name="org.apache.commons.lang3.text.StrTokenizer" />
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL" />
- </Match>
-
- <!-- Reason: Testing shows that new Integer(...) etc is quicker than Integer.valueOf -->
- <Match>
- <Bug pattern="DM_NUMBER_CTOR" />
- </Match>
-
- <!-- Reason: FindBugs 2.0.2 used in maven-findbugs-plugin 2.5.2 seems to have problems with detection of default cases
- in switch statements. All the excluded methods have switch statements that conatin a default case. -->
- <Match>
- <Class name="org.apache.commons.lang3.math.NumberUtils"/>
- <Method name="createNumber" />
- <Bug pattern="SF_SWITCH_NO_DEFAULT" />
- </Match>
- <Match>
- <Class name="org.apache.commons.lang3.text.ExtendedMessageFormat"/>
- <Method name="insertFormats" />
- <Bug pattern="SF_SWITCH_NO_DEFAULT" />
- </Match>
- <Match>
- <Class name="org.apache.commons.lang3.time.FastDateParser"/>
- <Method name="getStrategy" />
- <Bug pattern="SF_SWITCH_NO_DEFAULT" />
- </Match>
-
</FindBugsFilter>
Modified: commons/proper/weaver/trunk/maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/maven-plugin/pom.xml?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/maven-plugin/pom.xml (original)
+++ commons/proper/weaver/trunk/maven-plugin/pom.xml Mon Mar 3 06:49:20 2014
@@ -143,6 +143,14 @@ under the License.
<headerLocation>org/apache/commons/weaver/license-header.txt</headerLocation>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <excludeFilterFile>/org/apache/commons/weaver/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
Modified: commons/proper/weaver/trunk/modules/normalizer/weaver/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/modules/normalizer/weaver/pom.xml?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/modules/normalizer/weaver/pom.xml (original)
+++ commons/proper/weaver/trunk/modules/normalizer/weaver/pom.xml Mon Mar 3 06:49:20 2014
@@ -184,6 +184,14 @@ under the License.
<headerLocation>org/apache/commons/weaver/license-header.txt</headerLocation>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <excludeFilterFile>/org/apache/commons/weaver/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
</project>
Modified: commons/proper/weaver/trunk/modules/privilizer/weaver/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/modules/privilizer/weaver/pom.xml?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/modules/privilizer/weaver/pom.xml (original)
+++ commons/proper/weaver/trunk/modules/privilizer/weaver/pom.xml Mon Mar 3 06:49:20 2014
@@ -213,6 +213,14 @@ under the License.
<headerLocation>org/apache/commons/weaver/license-header.txt</headerLocation>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <excludeFilterFile>/org/apache/commons/weaver/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
</project>
Modified: commons/proper/weaver/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/pom.xml?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/pom.xml (original)
+++ commons/proper/weaver/trunk/pom.xml Mon Mar 3 06:49:20 2014
@@ -269,6 +269,11 @@ under the License.
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>2.5.3</version>
+ </plugin>
</plugins>
</pluginManagement>
<plugins>
@@ -541,6 +546,20 @@ under the License.
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>commons-weaver-build-tools</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <excludeFilterFile>/org/apache/commons/weaver/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
</plugins>
</build>
Modified: commons/proper/weaver/trunk/processor/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/processor/pom.xml?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/processor/pom.xml (original)
+++ commons/proper/weaver/trunk/processor/pom.xml Mon Mar 3 06:49:20 2014
@@ -74,6 +74,14 @@ under the License.
<headerLocation>org/apache/commons/weaver/license-header.txt</headerLocation>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <excludeFilterFile>/org/apache/commons/weaver/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
</project>
Modified: commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/Finder.java
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/Finder.java?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/Finder.java (original)
+++ commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/Finder.java Mon Mar 3 06:49:20 2014
@@ -670,6 +670,7 @@ class Finder extends AnnotationFinder im
interest.annotationType)) {
result.getWeavable(pkg.get()).addAnnotations(pkg.getAnnotations());
}
+ break;
case TYPE:
for (final Annotated<Class<?>> type : this.withAnnotations().findAnnotatedClasses(
interest.annotationType)) {
Modified: commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java (original)
+++ commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/Weavable.java Mon Mar 3 06:49:20 2014
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.Set;
import org.apache.commons.lang3.Validate;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* {@link Weavable} extends {@link AnnotatedElement} to include
@@ -75,12 +76,15 @@ public abstract class Weavable<SELF exte
if (annotations == null) {
annotations = new LinkedHashSet<Annotation>();
}
+ boolean result = false;
+ for (final Annotation ann : toAdd) {
+ if (ann == null) {
+ continue;
+ }
+ result = annotations.add(ann) || result;
+ }
+ return result;
}
- boolean result = false;
- for (final Annotation ann : toAdd) {
- result = ann != null && annotations.add(ann) || result;
- }
- return result;
}
/**
@@ -96,11 +100,9 @@ public abstract class Weavable<SELF exte
* @return {@link Annotation}[]
*/
@Override
- public final Annotation[] getAnnotations() {
- synchronized (this) {
- if (annotations == null) {
- return EMPTY_ANNOTATION_ARRAY; //NOPMD - no problem sharing zero-length array
- }
+ public final synchronized Annotation[] getAnnotations() {
+ if (annotations == null) {
+ return EMPTY_ANNOTATION_ARRAY; //NOPMD - no problem sharing zero-length array
}
return annotations.toArray(new Annotation[annotations.size()]);
}
@@ -153,4 +155,26 @@ public abstract class Weavable<SELF exte
public String toString() {
return "Weavable " + getTarget().toString();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!getClass().isInstance(obj)) {
+ return false;
+ }
+ return getTarget().equals(((Weavable<?, ?>) obj).getTarget());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(getTarget()).toHashCode();
+ }
}
Modified: commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java
URL: http://svn.apache.org/viewvc/commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java?rev=1573458&r1=1573457&r2=1573458&view=diff
==============================================================================
--- commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java (original)
+++ commons/proper/weaver/trunk/processor/src/main/java/org/apache/commons/weaver/model/WeavablePackage.java Mon Mar 3 06:49:20 2014
@@ -74,4 +74,5 @@ public class WeavablePackage extends Wea
public int compareTo(final WeavablePackage arg0) {
return getTarget().getName().compareTo(arg0.getTarget().getName());
}
+
}