various sonar/findbug code cleanups
This commit is contained in:
parent
107d3a4492
commit
5e83df20c8
|
@ -16,8 +16,6 @@ package org.eclipse.jetty.annotations;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
/**
|
||||
* AnnotationIntrospector
|
||||
*
|
||||
|
@ -35,7 +33,7 @@ public class AnnotationIntrospector
|
|||
*/
|
||||
public interface IntrospectableAnnotationHandler
|
||||
{
|
||||
public void handle(Class clazz);
|
||||
public void handle(Class<?> clazz);
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,7 +48,7 @@ public class AnnotationIntrospector
|
|||
{
|
||||
private boolean _introspectAncestors;
|
||||
|
||||
public abstract void doHandle(Class clazz);
|
||||
public abstract void doHandle(Class<?> clazz);
|
||||
|
||||
|
||||
public AbstractIntrospectableAnnotationHandler(boolean introspectAncestors)
|
||||
|
@ -58,9 +56,9 @@ public class AnnotationIntrospector
|
|||
_introspectAncestors = introspectAncestors;
|
||||
}
|
||||
|
||||
public void handle(Class clazz)
|
||||
public void handle(Class<?> clazz)
|
||||
{
|
||||
Class c = clazz;
|
||||
Class<?> c = clazz;
|
||||
|
||||
//process the whole inheritance hierarchy for the class
|
||||
while (c!=null && (!c.equals(Object.class)))
|
||||
|
@ -79,7 +77,7 @@ public class AnnotationIntrospector
|
|||
_handlers.add(handler);
|
||||
}
|
||||
|
||||
public void introspect (Class clazz)
|
||||
public void introspect (Class<?> clazz)
|
||||
{
|
||||
if (_handlers == null)
|
||||
return;
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
|||
* environment that will be looked up at runtime. They do
|
||||
* not specify an injection.
|
||||
*/
|
||||
public void doHandle(Class clazz)
|
||||
public void doHandle(Class<?> clazz)
|
||||
{
|
||||
if (Util.isServletType(clazz))
|
||||
{
|
||||
|
@ -65,16 +65,13 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
|||
}
|
||||
}
|
||||
|
||||
public void handleClass (Class clazz)
|
||||
public void handleClass (Class<?> clazz)
|
||||
{
|
||||
Resource resource = (Resource)clazz.getAnnotation(Resource.class);
|
||||
if (resource != null)
|
||||
{
|
||||
String name = resource.name();
|
||||
String mappedName = resource.mappedName();
|
||||
Resource.AuthenticationType auth = resource.authenticationType();
|
||||
Class type = resource.type();
|
||||
boolean shareable = resource.shareable();
|
||||
|
||||
if (name==null || name.trim().equals(""))
|
||||
throw new IllegalStateException ("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)");
|
||||
|
@ -92,7 +89,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
|||
}
|
||||
}
|
||||
|
||||
public void handleField(Class clazz, Field field)
|
||||
public void handleField(Class<?> clazz, Field field)
|
||||
{
|
||||
Resource resource = (Resource)field.getAnnotation(Resource.class);
|
||||
if (resource != null)
|
||||
|
@ -118,7 +115,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
|||
name = (resource.name()!=null && !resource.name().trim().equals("")? resource.name(): name);
|
||||
String mappedName = (resource.mappedName()!=null && !resource.mappedName().trim().equals("")?resource.mappedName():null);
|
||||
//get the type of the Field
|
||||
Class type = field.getType();
|
||||
Class<?> type = field.getType();
|
||||
|
||||
//Servlet Spec 3.0 p. 76
|
||||
//If a descriptor has specified at least 1 injection target for this
|
||||
|
@ -207,7 +204,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
|||
* This will generate a JNDI entry, and an Injection to be
|
||||
* processed when an instance of the class is created.
|
||||
*/
|
||||
public void handleMethod(Class clazz, Method method)
|
||||
public void handleMethod(Class<?> clazz, Method method)
|
||||
{
|
||||
|
||||
Resource resource = (Resource)method.getAnnotation(Resource.class);
|
||||
|
@ -265,9 +262,9 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
|
|||
|
||||
name = (resource.name()!=null && !resource.name().trim().equals("")? resource.name(): name);
|
||||
String mappedName = (resource.mappedName()!=null && !resource.mappedName().trim().equals("")?resource.mappedName():null);
|
||||
Class paramType = method.getParameterTypes()[0];
|
||||
Class<?> paramType = method.getParameterTypes()[0];
|
||||
|
||||
Class resourceType = resource.type();
|
||||
Class<?> resourceType = resource.type();
|
||||
|
||||
//Servlet Spec 3.0 p. 76
|
||||
//If a descriptor has specified at least 1 injection target for this
|
||||
|
|
|
@ -35,7 +35,7 @@ public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotation
|
|||
_wac = wac;
|
||||
}
|
||||
|
||||
public void doHandle (Class clazz)
|
||||
public void doHandle (Class<?> clazz)
|
||||
{
|
||||
Resources resources = (Resources)clazz.getAnnotation(Resources.class);
|
||||
if (resources != null)
|
||||
|
@ -49,12 +49,8 @@ public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotation
|
|||
|
||||
for (int j=0;j<resArray.length;j++)
|
||||
{
|
||||
|
||||
String name = resArray[j].name();
|
||||
String mappedName = resArray[j].mappedName();
|
||||
Resource.AuthenticationType auth = resArray[j].authenticationType();
|
||||
Class type = resArray[j].type();
|
||||
boolean shareable = resArray[j].shareable();
|
||||
|
||||
if (name==null || name.trim().equals(""))
|
||||
throw new IllegalStateException ("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)");
|
||||
|
|
|
@ -125,7 +125,6 @@ public class HttpURI
|
|||
int i=offset;
|
||||
int e=offset+length;
|
||||
int state=AUTH;
|
||||
int m=offset;
|
||||
_end=offset+length;
|
||||
_scheme=offset;
|
||||
_authority=offset;
|
||||
|
|
|
@ -561,7 +561,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
if (wait>0)
|
||||
{
|
||||
long before=now;
|
||||
selected=selector.select(wait);
|
||||
selector.select(wait);
|
||||
now = System.currentTimeMillis();
|
||||
_timeout.setNow(now);
|
||||
|
||||
|
|
|
@ -354,6 +354,7 @@ public class DataSourceLoginService extends MappedLoginService
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
InitialContext ic = new InitialContext();
|
||||
assert ic!=null;
|
||||
|
||||
//TODO webapp scope?
|
||||
|
||||
|
|
|
@ -139,11 +139,9 @@ public class IntrospectionUtil
|
|||
|
||||
public static boolean checkParams (Class<?>[] formalParams, Class<?>[] actualParams, boolean strict)
|
||||
{
|
||||
if (formalParams==null && actualParams==null)
|
||||
return true;
|
||||
if (formalParams==null && actualParams!=null)
|
||||
return false;
|
||||
if (formalParams!=null && actualParams==null)
|
||||
if (formalParams==null)
|
||||
return actualParams==null;
|
||||
if (actualParams==null)
|
||||
return false;
|
||||
|
||||
if (formalParams.length!=actualParams.length)
|
||||
|
@ -195,13 +193,11 @@ public class IntrospectionUtil
|
|||
|
||||
public static boolean isTypeCompatible (Class<?> formalType, Class<?> actualType, boolean strict)
|
||||
{
|
||||
if (formalType==null && actualType != null)
|
||||
if (formalType==null)
|
||||
return actualType==null;
|
||||
if (actualType==null)
|
||||
return false;
|
||||
if (formalType!=null && actualType==null)
|
||||
return false;
|
||||
if (formalType==null && actualType==null)
|
||||
return true;
|
||||
|
||||
|
||||
if (strict)
|
||||
return formalType.equals(actualType);
|
||||
else
|
||||
|
|
|
@ -290,25 +290,26 @@ public class URLResource extends Resource
|
|||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return _url.hashCode();
|
||||
return _urlString.hashCode();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public boolean equals( Object o)
|
||||
{
|
||||
return o instanceof URLResource &&
|
||||
_url.equals(((URLResource)o)._url);
|
||||
return o instanceof URLResource && _urlString.equals(((URLResource)o)._urlString);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean getUseCaches ()
|
||||
{
|
||||
return _useCaches;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public boolean isContainedIn (Resource containingResource) throws MalformedURLException
|
||||
{
|
||||
return false; //TODO gregw check this!
|
||||
return false; //TODO check this!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,8 @@ public class TagLibConfiguration extends AbstractConfiguration
|
|||
//Get the system classpath tlds and tell jasper about them, if jasper is on the classpath
|
||||
try
|
||||
{
|
||||
Class clazz = getClass().getClassLoader().loadClass("org.apache.jasper.compiler.TldLocationsCache");
|
||||
Class<?> clazz = getClass().getClassLoader().loadClass("org.apache.jasper.compiler.TldLocationsCache");
|
||||
assert clazz!=null;
|
||||
Collection<Resource> tld_resources = (Collection<Resource>)_context.getAttribute(TLD_RESOURCES);
|
||||
|
||||
Map<URI, List<String>> tldMap = new HashMap<URI, List<String>>();
|
||||
|
|
Loading…
Reference in New Issue