Skip to content
Permalink
Browse files
checkstyle/findbugs/pmd
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/proxy/trunk@1582033 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mbenson committed Mar 26, 2014
1 parent 247c8c3 commit 7ae273711f8ac16e10cc594500c3b9d4a4893209
Showing 108 changed files with 1,780 additions and 1,406 deletions.
@@ -57,4 +57,34 @@
<scope>test</scope>
</dependency>
</dependencies>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<!--rulesets>
<ruleset>/org/apache/commons/proxy2/pmd.xml</ruleset>
</rulesets-->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<configLocation>org/apache/commons/proxy2/checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>/org/apache/commons/proxy2/findbugs-exclude-filter.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
@@ -22,6 +22,8 @@
import java.lang.reflect.UndeclaredThrowableException;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.proxy2.Interceptor;
import org.apache.commons.proxy2.Invocation;
import org.apache.commons.proxy2.Invoker;
@@ -423,8 +425,7 @@ protected static boolean isEqualsMethod(Method method)
&& method.getParameterTypes().length == 1 && Object.class.equals(method.getParameterTypes()[0]);
}

@SuppressWarnings("serial")
private static class ReflectionInvocation implements Invocation, Serializable
private static class ReflectionInvocation implements Invocation
{
private final Method method;
private final Object[] arguments;
@@ -435,7 +436,7 @@ public ReflectionInvocation(final Object target, final Object proxy, final Metho
final Object[] arguments)
{
this.method = method;
this.arguments = (arguments == null ? ProxyUtils.EMPTY_ARGUMENTS : arguments);
this.arguments = ObjectUtils.defaultIfNull(ArrayUtils.clone(arguments), ProxyUtils.EMPTY_ARGUMENTS);
this.proxy = proxy;
this.target = target;
}
@@ -20,7 +20,7 @@

public class TestAsm4ProxyFactory extends AbstractSubclassingProxyFactoryTestCase
{
//**********************************************************************************************************************
// Constructors
//**********************************************************************************************************************
//**********************************************************************************************************************
// Constructors
//**********************************************************************************************************************
}
@@ -22,24 +22,19 @@

<!-- commons proxy2 customization of default Checkstyle behavior -->
<module name="Checker">
<property name="localeLanguage" value="en"/>

<module name="Header">
<property name="headerFile" value="${checkstyle.header.file}"/>
</module>
<property name="localeLanguage" value="en" />

<!-- no tabs allowed in files -->
<module name="FileTabCharacter"/>
<module name="FileTabCharacter" />

<module name="TreeWalker">
<!-- Verify that EVERY source file has the appropriate license -->
<!-- check sane import statements -->
<module name="AvoidStarImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="AvoidStarImport" />
<module name="RedundantImport" />
<module name="UnusedImports" />

<module name="LineLength">
<property name="max" value="120"/>
<property name="max" value="120" />
</module>
</module>
</module>
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!--
This file contains some false positive bugs detected by findbugs. Their
false positive nature has been analyzed individually and they have been
put here to instruct findbugs it must ignore them.
-->
<FindBugsFilter>

<!-- Reason: invocation arguments intentionally modifiable -->
<Match>
<Class name="org.apache.commons.proxy2.javassist.JavassistInvocation" />
<Bug pattern="EI_EXPOSE_REP" />
</Match>

</FindBugsFilter>

This file was deleted.

@@ -55,4 +55,33 @@
</dependency>
</dependencies>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<!--rulesets>
<ruleset>/org/apache/commons/proxy2/pmd.xml</ruleset>
</rulesets-->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<configLocation>org/apache/commons/proxy2/checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>/org/apache/commons/proxy2/findbugs-exclude-filter.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
@@ -17,42 +17,54 @@

package org.apache.commons.proxy2.cglib;

import net.sf.cglib.proxy.*;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.proxy2.*;
import org.apache.commons.proxy2.impl.AbstractSubclassingProxyFactory;

import java.io.Serializable;
import java.lang.reflect.Method;

import net.sf.cglib.proxy.Callback;
import net.sf.cglib.proxy.CallbackFilter;
import net.sf.cglib.proxy.Dispatcher;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.proxy2.Interceptor;
import org.apache.commons.proxy2.Invocation;
import org.apache.commons.proxy2.Invoker;
import org.apache.commons.proxy2.ObjectProvider;
import org.apache.commons.proxy2.ProxyUtils;
import org.apache.commons.proxy2.impl.AbstractSubclassingProxyFactory;

/**
* Cglib-based {@link ProxyFactory} implementation.
*/
public class CglibProxyFactory extends AbstractSubclassingProxyFactory
{
//**********************************************************************************************************************
// Fields
//**********************************************************************************************************************
//******************************************************************************************************************
// Fields
//******************************************************************************************************************

private static CallbackFilter callbackFilter = new CglibProxyFactoryCallbackFilter();

//**********************************************************************************************************************
// ProxyFactory Implementation
//**********************************************************************************************************************
//******************************************************************************************************************
// ProxyFactory Implementation
//******************************************************************************************************************

/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public <T> T createDelegatorProxy(ClassLoader classLoader, ObjectProvider<?> targetProvider,
Class<?>... proxyClasses)
Class<?>... proxyClasses)
{
final Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(classLoader);
enhancer.setInterfaces(toInterfaces(proxyClasses));
enhancer.setSuperclass(getSuperclass(proxyClasses));
enhancer.setCallbackFilter(callbackFilter);
enhancer.setCallbacks(new Callback[]{new ObjectProviderDispatcher(targetProvider), new EqualsHandler(), new HashCodeHandler()});
enhancer.setCallbacks(new Callback[] { new ObjectProviderDispatcher(targetProvider), new EqualsHandler(),
new HashCodeHandler() });
return (T) enhancer.create();
}

@@ -61,36 +73,37 @@ public <T> T createDelegatorProxy(ClassLoader classLoader, ObjectProvider<?> tar
*/
@SuppressWarnings("unchecked")
public <T> T createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor interceptor,
Class<?>... proxyClasses)
Class<?>... proxyClasses)
{
final Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(classLoader);
enhancer.setInterfaces(toInterfaces(proxyClasses));
enhancer.setSuperclass(getSuperclass(proxyClasses));
enhancer.setCallbackFilter(callbackFilter);
enhancer.setCallbacks(new Callback[]{new InterceptorBridge(target, interceptor), new EqualsHandler(), new HashCodeHandler()});
enhancer.setCallbacks(new Callback[] { new InterceptorBridge(target, interceptor), new EqualsHandler(),
new HashCodeHandler() });
return (T) enhancer.create();
}

/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker,
Class<?>... proxyClasses)
public <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker, Class<?>... proxyClasses)
{
final Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(classLoader);
enhancer.setInterfaces(toInterfaces(proxyClasses));
enhancer.setSuperclass(getSuperclass(proxyClasses));
enhancer.setCallbackFilter(callbackFilter);
enhancer.setCallbacks(new Callback[]{new InvokerBridge(invoker), new EqualsHandler(), new HashCodeHandler()});
enhancer.setCallbacks(
new Callback[] { new InvokerBridge(invoker), new EqualsHandler(), new HashCodeHandler() });
return (T) enhancer.create();
}

//**********************************************************************************************************************
// Inner Classes
//**********************************************************************************************************************
//******************************************************************************************************************
// Inner Classes
//******************************************************************************************************************

private static class CglibProxyFactoryCallbackFilter implements CallbackFilter
{
@@ -133,7 +146,7 @@ public Object intercept(Object o, Method method, Object[] objects, MethodProxy m
}
}

private static class InterceptorBridge implements net.sf.cglib.proxy.MethodInterceptor, Serializable
private static class InterceptorBridge implements MethodInterceptor, Serializable
{
/** Serialization version */
private static final long serialVersionUID = 1L;
@@ -171,11 +184,8 @@ public Object invoke(Object object, Method method, Object[] objects) throws Thro
}
}

private static class MethodProxyInvocation implements Invocation, Serializable
private static class MethodProxyInvocation implements Invocation
{
/** Serialization version */
private static final long serialVersionUID = 1L;

private final Object proxy;
private final Object target;
private final Method method;
@@ -188,7 +198,7 @@ public MethodProxyInvocation(Object proxy, Object target, Method method, Object[
this.target = target;
this.method = method;
this.methodProxy = methodProxy;
this.args = ArrayUtils.clone(args);
this.args = ObjectUtils.defaultIfNull(ArrayUtils.clone(args), ProxyUtils.EMPTY_ARGUMENTS);
}

public Method getMethod()
@@ -21,9 +21,9 @@

public class CglibProxyFactoryTest extends AbstractSubclassingProxyFactoryTestCase
{
//**********************************************************************************************************************
// Constructors
//**********************************************************************************************************************
//**********************************************************************************************************************
// Constructors
//**********************************************************************************************************************

public CglibProxyFactoryTest()
{
@@ -59,4 +59,33 @@
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<configLocation>org/apache/commons/proxy2/checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<!--rulesets>
<ruleset>/org/apache/commons/proxy2/pmd.xml</ruleset>
</rulesets-->
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>/org/apache/commons/proxy2/findbugs-exclude-filter.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

0 comments on commit 7ae2737

Please sign in to comment.