From: markt Date: Sat, 27 Dec 2008 17:48:13 +0000 (+0000) Subject: Generics changes for o.a.c.core X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9bfd605a86047b2c570ba1336c5fedb9d75080d1;p=tomcat7.0 Generics changes for o.a.c.core Fix various Eclipse warnings (unused code, unnecessary casts, etc) git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@729650 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java index f6c759bb3..67f9b1fcb 100644 --- a/java/org/apache/catalina/core/ApplicationContext.java +++ b/java/org/apache/catalina/core/ApplicationContext.java @@ -111,7 +111,7 @@ public class ApplicationContext * Empty collection to serve as the basis for empty enumerations. * DO NOT ADD ANY ELEMENTS TO THIS COLLECTION! */ - private static final ArrayList empty = new ArrayList(); + private static final ArrayList empty = new ArrayList(); /** @@ -123,7 +123,7 @@ public class ApplicationContext /** * The merged context initialization parameters for this Context. */ - private Map parameters = null; + private Map parameters = null; /** @@ -183,7 +183,7 @@ public class ApplicationContext */ public Enumeration getAttributeNames() { - return new Enumerator(attributes.keySet(), true); + return new Enumerator(attributes.keySet(), true); } @@ -254,7 +254,7 @@ public class ApplicationContext public String getInitParameter(final String name) { mergeParameters(); - return ((String) parameters.get(name)); + return parameters.get(name); } @@ -266,7 +266,7 @@ public class ApplicationContext public Enumeration getInitParameterNames() { mergeParameters(); - return (new Enumerator(parameters.keySet())); + return (new Enumerator(parameters.keySet())); } @@ -478,7 +478,7 @@ public class ApplicationContext jarFile = new File(context.getWorkPath(), path); } if (jarFile.exists()) { - return jarFile.toURL(); + return jarFile.toURI().toURL(); } else { return null; } @@ -572,9 +572,10 @@ public class ApplicationContext * @param resources Directory context to search * @param path Collection path */ - private Set getResourcePathsInternal(DirContext resources, String path) { + private Set getResourcePathsInternal(DirContext resources, + String path) { - ResourceSet set = new ResourceSet(); + ResourceSet set = new ResourceSet(); try { listCollectionPaths(set, resources, path); } catch (NamingException e) { @@ -620,7 +621,7 @@ public class ApplicationContext * @deprecated As of Java Servlet API 2.1, with no direct replacement. */ public Enumeration getServletNames() { - return (new Enumerator(empty)); + return (new Enumerator(empty)); } @@ -628,7 +629,7 @@ public class ApplicationContext * @deprecated As of Java Servlet API 2.1, with no direct replacement. */ public Enumeration getServlets() { - return (new Enumerator(empty)); + return (new Enumerator(empty)); } @@ -809,7 +810,7 @@ public class ApplicationContext return this.context; } - protected Map getReadonlyAttributes() { + protected Map getReadonlyAttributes() { return this.readOnlyAttributes; } /** @@ -818,17 +819,17 @@ public class ApplicationContext protected void clearAttributes() { // Create list of attributes to be removed - ArrayList list = new ArrayList(); - Iterator iter = attributes.keySet().iterator(); + ArrayList list = new ArrayList(); + Iterator iter = attributes.keySet().iterator(); while (iter.hasNext()) { list.add(iter.next()); } // Remove application originated attributes // (read only attributes will be left in place) - Iterator keys = list.iterator(); + Iterator keys = list.iterator(); while (keys.hasNext()) { - String key = (String) keys.next(); + String key = keys.next(); removeAttribute(key); } @@ -908,7 +909,7 @@ public class ApplicationContext if (parameters != null) return; - Map results = new ConcurrentHashMap(); + Map results = new ConcurrentHashMap(); String names[] = context.findParameters(); for (int i = 0; i < names.length; i++) results.put(names[i], context.findParameter(names[i])); @@ -931,13 +932,12 @@ public class ApplicationContext * List resource paths (recursively), and store all of them in the given * Set. */ - private static void listCollectionPaths - (Set set, DirContext resources, String path) - throws NamingException { + private static void listCollectionPaths(Set set, + DirContext resources, String path) throws NamingException { - Enumeration childPaths = resources.listBindings(path); + Enumeration childPaths = resources.listBindings(path); while (childPaths.hasMoreElements()) { - Binding binding = (Binding) childPaths.nextElement(); + Binding binding = childPaths.nextElement(); String name = binding.getName(); StringBuffer childPath = new StringBuffer(path); if (!"/".equals(path) && !path.endsWith("/")) diff --git a/java/org/apache/catalina/core/ApplicationContextFacade.java b/java/org/apache/catalina/core/ApplicationContextFacade.java index d1373c038..2f6588816 100644 --- a/java/org/apache/catalina/core/ApplicationContextFacade.java +++ b/java/org/apache/catalina/core/ApplicationContextFacade.java @@ -56,13 +56,13 @@ public final class ApplicationContextFacade /** * Cache Class object used for reflection. */ - private HashMap classCache; + private HashMap[]> classCache; /** * Cache method object. */ - private HashMap objectCache; + private HashMap objectCache; // ----------------------------------------------------------- Constructors @@ -78,14 +78,14 @@ public final class ApplicationContextFacade super(); this.context = context; - classCache = new HashMap(); - objectCache = new HashMap(); + classCache = new HashMap[]>(); + objectCache = new HashMap(); initClassCache(); } private void initClassCache(){ - Class[] clazz = new Class[]{String.class}; + Class[] clazz = new Class[]{String.class}; classCache.put("getContext", clazz); classCache.put("getMimeType", clazz); classCache.put("getResourcePaths", clazz); @@ -367,26 +367,6 @@ public final class ApplicationContextFacade /** * Use reflection to invoke the requested method. Cache the method object * to speed up the process - * @param appContext The AppliationContext object on which the method - * will be invoked - * @param methodName The method to call. - * @param params The arguments passed to the called method. - */ - private Object doPrivileged(ApplicationContext appContext, - final String methodName, - final Object[] params) { - try{ - return invokeMethod(appContext, methodName, params ); - } catch (Throwable t){ - throw new RuntimeException(t.getMessage()); - } - - } - - - /** - * Use reflection to invoke the requested method. Cache the method object - * to speed up the process * will be invoked * @param methodName The method to call. * @param params The arguments passed to the called method. @@ -414,16 +394,16 @@ public final class ApplicationContextFacade throws Throwable{ try{ - Method method = (Method)objectCache.get(methodName); + Method method = objectCache.get(methodName); if (method == null){ method = appContext.getClass() - .getMethod(methodName, (Class[])classCache.get(methodName)); + .getMethod(methodName, classCache.get(methodName)); objectCache.put(methodName, method); } return executeMethod(method,appContext,params); } catch (Exception ex){ - handleException(ex, methodName); + handleException(ex); return null; } finally { params = null; @@ -438,16 +418,15 @@ public final class ApplicationContextFacade * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, - final Class[] clazz, + final Class[] clazz, Object[] params){ try{ - Method method = context.getClass() - .getMethod(methodName, (Class[])clazz); + Method method = context.getClass().getMethod(methodName, clazz); return executeMethod(method,context,params); } catch (Exception ex){ try{ - handleException(ex, methodName); + handleException(ex); }catch (Throwable t){ throw new RuntimeException(t.getMessage()); } @@ -473,7 +452,7 @@ public final class ApplicationContextFacade InvocationTargetException { if (SecurityUtil.isPackageProtectionEnabled()){ - return AccessController.doPrivileged(new PrivilegedExceptionAction(){ + return AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws IllegalAccessException, InvocationTargetException{ return method.invoke(context, params); } @@ -489,7 +468,7 @@ public final class ApplicationContextFacade * Throw the real exception. * @param ex The current exception */ - private void handleException(Exception ex, String methodName) + private void handleException(Exception ex) throws Throwable { Throwable realException; diff --git a/java/org/apache/catalina/core/ApplicationDispatcher.java b/java/org/apache/catalina/core/ApplicationDispatcher.java index 89e926165..6ed03f9bc 100644 --- a/java/org/apache/catalina/core/ApplicationDispatcher.java +++ b/java/org/apache/catalina/core/ApplicationDispatcher.java @@ -66,7 +66,8 @@ final class ApplicationDispatcher implements RequestDispatcher { - protected class PrivilegedForward implements PrivilegedExceptionAction { + protected class PrivilegedForward + implements PrivilegedExceptionAction { private ServletRequest request; private ServletResponse response; @@ -76,13 +77,14 @@ final class ApplicationDispatcher this.response = response; } - public Object run() throws java.lang.Exception { + public Void run() throws java.lang.Exception { doForward(request,response); return null; } } - protected class PrivilegedInclude implements PrivilegedExceptionAction { + protected class PrivilegedInclude implements + PrivilegedExceptionAction { private ServletRequest request; private ServletResponse response; @@ -92,7 +94,7 @@ final class ApplicationDispatcher this.response = response; } - public Object run() throws ServletException, IOException { + public Void run() throws ServletException, IOException { doInclude(request,response); return null; } @@ -397,12 +399,12 @@ final class ApplicationDispatcher ServletOutputStream stream = response.getOutputStream(); stream.close(); } catch (IllegalStateException f) { - ; + // Ignore } catch (IOException f) { - ; + // Ignore } } catch (IOException e) { - ; + // Ignore } } diff --git a/java/org/apache/catalina/core/ApplicationFilterChain.java b/java/org/apache/catalina/core/ApplicationFilterChain.java index ff35f0679..b227338d0 100644 --- a/java/org/apache/catalina/core/ApplicationFilterChain.java +++ b/java/org/apache/catalina/core/ApplicationFilterChain.java @@ -56,13 +56,13 @@ import org.apache.catalina.util.StringManager; final class ApplicationFilterChain implements FilterChain, CometFilterChain { // Used to enforce requirements of SRV.8.2 / SRV.14.2.5.1 - private final static ThreadLocal lastServicedRequest; - private final static ThreadLocal lastServicedResponse; + private final static ThreadLocal lastServicedRequest; + private final static ThreadLocal lastServicedResponse; static { if (Globals.STRICT_SERVLET_COMPLIANCE) { - lastServicedRequest = new ThreadLocal(); - lastServicedResponse = new ThreadLocal(); + lastServicedRequest = new ThreadLocal(); + lastServicedResponse = new ThreadLocal(); } else { lastServicedRequest = null; lastServicedResponse = null; @@ -135,15 +135,15 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { * Static class array used when the SecurityManager is turned on and * doFilter is invoked. */ - private static Class[] classType = new Class[]{ServletRequest.class, - ServletResponse.class, - FilterChain.class}; + private static Class[] classType = new Class[]{ServletRequest.class, + ServletResponse.class, + FilterChain.class}; /** * Static class array used when the SecurityManager is turned on and * service is invoked. */ - private static Class[] classTypeUsedInService = new Class[]{ + private static Class[] classTypeUsedInService = new Class[]{ ServletRequest.class, ServletResponse.class}; @@ -151,14 +151,14 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { * Static class array used when the SecurityManager is turned on and * doFilterEvent is invoked. */ - private static Class[] cometClassType = + private static Class[] cometClassType = new Class[]{ CometEvent.class, CometFilterChain.class}; /** * Static class array used when the SecurityManager is turned on and * event is invoked. */ - private static Class[] classTypeUsedInEvent = + private static Class[] classTypeUsedInEvent = new Class[] { CometEvent.class }; // ---------------------------------------------------- FilterChain Methods @@ -183,8 +183,8 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { final ServletResponse res = response; try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() + new java.security.PrivilegedExceptionAction() { + public Void run() throws ServletException, IOException { internalDoFilter(req,res); return null; @@ -287,8 +287,7 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { principal); args = null; } else { - servlet.service((HttpServletRequest) request, - (HttpServletResponse) response); + servlet.service(request, response); } } else { servlet.service(request, response); @@ -340,8 +339,8 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { final CometEvent ev = event; try { java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() + new java.security.PrivilegedExceptionAction() { + public Void run() throws ServletException, IOException { internalDoFilterEvent(ev); return null; @@ -372,7 +371,7 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { * @return The last request to be serviced. */ public static ServletRequest getLastServicedRequest() { - return (ServletRequest) lastServicedRequest.get(); + return lastServicedRequest.get(); } @@ -383,7 +382,7 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { * @return The last response to be serviced. */ public static ServletResponse getLastServicedResponse() { - return (ServletResponse) lastServicedResponse.get(); + return lastServicedResponse.get(); } diff --git a/java/org/apache/catalina/core/ApplicationFilterConfig.java b/java/org/apache/catalina/core/ApplicationFilterConfig.java index 7e3f500cb..4cb4b9e6c 100644 --- a/java/org/apache/catalina/core/ApplicationFilterConfig.java +++ b/java/org/apache/catalina/core/ApplicationFilterConfig.java @@ -140,11 +140,11 @@ final class ApplicationFilterConfig implements FilterConfig, Serializable { */ public String getInitParameter(String name) { - Map map = filterDef.getParameterMap(); + Map map = filterDef.getParameterMap(); if (map == null) return (null); else - return ((String) map.get(name)); + return map.get(name); } @@ -155,11 +155,11 @@ final class ApplicationFilterConfig implements FilterConfig, Serializable { */ public Enumeration getInitParameterNames() { - Map map = filterDef.getParameterMap(); + Map map = filterDef.getParameterMap(); if (map == null) - return (new Enumerator(new ArrayList())); + return (new Enumerator(new ArrayList())); else - return (new Enumerator(map.keySet())); + return (new Enumerator(map.keySet())); } @@ -329,7 +329,7 @@ final class ApplicationFilterConfig implements FilterConfig, Serializable { } else { // Allocate a new filter instance - Filter filter = getFilter(); + getFilter(); } diff --git a/java/org/apache/catalina/core/ApplicationFilterFactory.java b/java/org/apache/catalina/core/ApplicationFilterFactory.java index f0bfef50c..ea3e1ecb2 100644 --- a/java/org/apache/catalina/core/ApplicationFilterFactory.java +++ b/java/org/apache/catalina/core/ApplicationFilterFactory.java @@ -21,7 +21,6 @@ package org.apache.catalina.core; import javax.servlet.Servlet; import javax.servlet.ServletRequest; -import javax.servlet.http.HttpServletRequest; import org.apache.catalina.CometFilter; import org.apache.catalina.Globals; @@ -58,7 +57,7 @@ public final class ApplicationFilterFactory { public static final String DISPATCHER_REQUEST_PATH_ATTR = Globals.DISPATCHER_REQUEST_PATH_ATTR; - private static ApplicationFilterFactory factory = null;; + private static ApplicationFilterFactory factory = null; // ----------------------------------------------------------- Constructors @@ -110,9 +109,6 @@ public final class ApplicationFilterFactory { requestPath = attribute.toString(); } - HttpServletRequest hreq = null; - if (request instanceof HttpServletRequest) - hreq = (HttpServletRequest)request; // If there is no servlet to execute, return null if (servlet == null) return (null); @@ -168,7 +164,7 @@ public final class ApplicationFilterFactory { ApplicationFilterConfig filterConfig = (ApplicationFilterConfig) context.findFilterConfig(filterMaps[i].getFilterName()); if (filterConfig == null) { - ; // FIXME - log configuration problem + // FIXME - log configuration problem continue; } boolean isCometFilter = false; @@ -198,7 +194,7 @@ public final class ApplicationFilterFactory { ApplicationFilterConfig filterConfig = (ApplicationFilterConfig) context.findFilterConfig(filterMaps[i].getFilterName()); if (filterConfig == null) { - ; // FIXME - log configuration problem + // FIXME - log configuration problem continue; } boolean isCometFilter = false; diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index eb273db29..4d7712e4d 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -140,7 +140,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * The request parameters for this request. This is initialized from the * wrapped request, but updates are allowed. */ - protected Map parameters = null; + protected Map parameters = null; /** @@ -369,7 +369,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * Override the getParameterMap() method of the * wrapped request. */ - public Map getParameterMap() { + public Map getParameterMap() { parseParameters(); return (parameters); @@ -381,10 +381,10 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * Override the getParameterNames() method of the * wrapped request. */ - public Enumeration getParameterNames() { + public Enumeration getParameterNames() { parseParameters(); - return (new Enumerator(parameters.keySet())); + return (new Enumerator(parameters.keySet())); } @@ -400,7 +400,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { parseParameters(); Object value = parameters.get(name); if (value == null) - return ((String[]) null); + return null; else if (value instanceof String[]) return ((String[]) value); else if (value instanceof String) { @@ -613,14 +613,14 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * * @param orig Origin Map to be copied */ - Map copyMap(Map orig) { + Map copyMap(Map orig) { if (orig == null) - return (new HashMap()); - HashMap dest = new HashMap(); - Iterator keys = orig.keySet().iterator(); + return (new HashMap()); + HashMap dest = new HashMap(); + Iterator keys = orig.keySet().iterator(); while (keys.hasNext()) { - String key = (String) keys.next(); + String key = keys.next(); dest.put(key, orig.get(key)); } return (dest); @@ -724,7 +724,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { return; } - parameters = new HashMap(); + parameters = new HashMap(); parameters = copyMap(getRequest().getParameterMap()); mergeParameters(); parsedParams = true; @@ -818,7 +818,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { */ protected String[] mergeValues(Object values1, Object values2) { - ArrayList results = new ArrayList(); + ArrayList results = new ArrayList(); if (values1 == null) ; @@ -843,7 +843,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { results.add(values2.toString()); String values[] = new String[results.size()]; - return ((String[]) results.toArray(values)); + return results.toArray(values); } @@ -862,7 +862,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { if ((queryParamString == null) || (queryParamString.length() < 1)) return; - HashMap queryParameters = new HashMap(); + HashMap queryParameters = new HashMap(); String encoding = getCharacterEncoding(); if (encoding == null) encoding = "ISO-8859-1"; @@ -870,11 +870,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { RequestUtil.parseParameters (queryParameters, queryParamString, encoding); } catch (Exception e) { - ; + // Ignore } - Iterator keys = parameters.keySet().iterator(); + Iterator keys = parameters.keySet().iterator(); while (keys.hasNext()) { - String key = (String) keys.next(); + String key = keys.next(); Object value = queryParameters.get(key); if (value == null) { queryParameters.put(key, parameters.get(key)); @@ -895,11 +895,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * Utility class used to expose the special attributes as being available * as request attributes. */ - protected class AttributeNamesEnumerator implements Enumeration { + protected class AttributeNamesEnumerator implements Enumeration { protected int pos = -1; protected int last = -1; - protected Enumeration parentEnumeration = null; + protected Enumeration parentEnumeration = null; protected String next = null; public AttributeNamesEnumerator() { @@ -916,7 +916,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { || ((next = findNext()) != null)); } - public Object nextElement() { + public String nextElement() { if (pos != last) { for (int i = pos + 1; i <= last; i++) { if (getAttribute(specials[i]) != null) { @@ -937,7 +937,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { protected String findNext() { String result = null; while ((result == null) && (parentEnumeration.hasMoreElements())) { - String current = (String) parentEnumeration.nextElement(); + String current = parentEnumeration.nextElement(); if (!isSpecial(current)) { result = current; } diff --git a/java/org/apache/catalina/core/ApplicationRequest.java b/java/org/apache/catalina/core/ApplicationRequest.java index 5bf0144de..7f23bb899 100644 --- a/java/org/apache/catalina/core/ApplicationRequest.java +++ b/java/org/apache/catalina/core/ApplicationRequest.java @@ -86,7 +86,8 @@ class ApplicationRequest extends ServletRequestWrapper { * The request attributes for this request. This is initialized from the * wrapped request, but updates are allowed. */ - protected HashMap attributes = new HashMap(); + protected HashMap attributes = + new HashMap(); /** @@ -117,10 +118,10 @@ class ApplicationRequest extends ServletRequestWrapper { * Override the getAttributeNames() method of the wrapped * request. */ - public Enumeration getAttributeNames() { + public Enumeration getAttributeNames() { synchronized (attributes) { - return (new Enumerator(attributes.keySet())); + return (new Enumerator(attributes.keySet())); } } @@ -176,9 +177,9 @@ class ApplicationRequest extends ServletRequestWrapper { // Initialize the attributes for this request synchronized (attributes) { attributes.clear(); - Enumeration names = request.getAttributeNames(); + Enumeration names = request.getAttributeNames(); while (names.hasMoreElements()) { - String name = (String) names.nextElement(); + String name = names.nextElement(); Object value = request.getAttribute(name); attributes.put(name, value); } diff --git a/java/org/apache/catalina/core/AprLifecycleListener.java b/java/org/apache/catalina/core/AprLifecycleListener.java index 4305807a4..5f001c198 100644 --- a/java/org/apache/catalina/core/AprLifecycleListener.java +++ b/java/org/apache/catalina/core/AprLifecycleListener.java @@ -127,11 +127,11 @@ public class AprLifecycleListener } try { String methodName = "initialize"; - Class paramTypes[] = new Class[1]; + Class paramTypes[] = new Class[1]; paramTypes[0] = String.class; Object paramValues[] = new Object[1]; paramValues[0] = null; - Class clazz = Class.forName("org.apache.tomcat.jni.Library"); + Class clazz = Class.forName("org.apache.tomcat.jni.Library"); Method method = clazz.getMethod(methodName, paramTypes); method.invoke(null, paramValues); major = clazz.getField("TCN_MAJOR_VERSION").getInt(null); @@ -188,8 +188,11 @@ public class AprLifecycleListener + minor + "." + patch)); } // Log APR flags - log.info(sm.getString("aprListener.flags", Library.APR_HAVE_IPV6, Library.APR_HAS_SENDFILE, - Library.APR_HAS_SO_ACCEPTFILTER, Library.APR_HAS_RANDOM)); + log.info(sm.getString("aprListener.flags", + Boolean.valueOf(Library.APR_HAVE_IPV6), + Boolean.valueOf(Library.APR_HAS_SENDFILE), + Boolean.valueOf(Library.APR_HAS_SO_ACCEPTFILTER), + Boolean.valueOf(Library.APR_HAS_RANDOM))); return true; } @@ -206,11 +209,11 @@ public class AprLifecycleListener return; } String methodName = "randSet"; - Class paramTypes[] = new Class[1]; + Class paramTypes[] = new Class[1]; paramTypes[0] = String.class; Object paramValues[] = new Object[1]; paramValues[0] = SSLRandomSeed; - Class clazz = Class.forName("org.apache.tomcat.jni.SSL"); + Class clazz = Class.forName("org.apache.tomcat.jni.SSL"); Method method = clazz.getMethod(methodName, paramTypes); method.invoke(null, paramValues); @@ -228,7 +231,7 @@ public class AprLifecycleListener } public void setSSLEngine(String SSLEngine) { - this.SSLEngine = SSLEngine; + AprLifecycleListener.SSLEngine = SSLEngine; } public String getSSLRandomSeed() { @@ -236,6 +239,6 @@ public class AprLifecycleListener } public void setSSLRandomSeed(String SSLRandomSeed) { - this.SSLRandomSeed = SSLRandomSeed; + AprLifecycleListener.SSLRandomSeed = SSLRandomSeed; } } diff --git a/java/org/apache/catalina/core/ContainerBase.java b/java/org/apache/catalina/core/ContainerBase.java index eae2d8eac..a8377b997 100644 --- a/java/org/apache/catalina/core/ContainerBase.java +++ b/java/org/apache/catalina/core/ContainerBase.java @@ -133,7 +133,7 @@ public abstract class ContainerBase * Tomcat. */ protected class PrivilegedAddChild - implements PrivilegedAction { + implements PrivilegedAction { private Container child; @@ -141,7 +141,7 @@ public abstract class ContainerBase this.child = child; } - public Object run() { + public Void run() { addChildInternal(child); return null; } @@ -155,7 +155,8 @@ public abstract class ContainerBase /** * The child Containers belonging to this Container, keyed by name. */ - protected HashMap children = new HashMap(); + protected HashMap children = + new HashMap(); /** @@ -173,7 +174,7 @@ public abstract class ContainerBase /** * The container event listeners for this Container. */ - protected ArrayList listeners = new ArrayList(); + protected ArrayList listeners = new ArrayList(); /** @@ -731,7 +732,7 @@ public abstract class ContainerBase DirContext oldResources = this.resources; if (oldResources == resources) return; - Hashtable env = new Hashtable(); + Hashtable env = new Hashtable(); if (getParent() != null) env.put(ProxyDirContext.HOST, getParent().getName()); env.put(ProxyDirContext.CONTEXT, getName()); @@ -764,7 +765,7 @@ public abstract class ContainerBase */ public void addChild(Container child) { if (Globals.IS_SECURITY_ENABLED) { - PrivilegedAction dp = + PrivilegedAction dp = new PrivilegedAddChild(child); AccessController.doPrivileged(dp); } else { @@ -844,7 +845,7 @@ public abstract class ContainerBase if (name == null) return (null); synchronized (children) { // Required by post-start changes - return ((Container) children.get(name)); + return children.get(name); } } @@ -858,7 +859,7 @@ public abstract class ContainerBase synchronized (children) { Container results[] = new Container[children.size()]; - return ((Container[]) children.values().toArray(results)); + return children.values().toArray(results); } } @@ -874,7 +875,7 @@ public abstract class ContainerBase synchronized (listeners) { ContainerListener[] results = new ContainerListener[listeners.size()]; - return ((ContainerListener[]) listeners.toArray(results)); + return listeners.toArray(results); } } @@ -1356,10 +1357,10 @@ public abstract class ContainerBase ContainerEvent event = new ContainerEvent(this, type, data); ContainerListener list[] = new ContainerListener[0]; synchronized (listeners) { - list = (ContainerListener[]) listeners.toArray(list); + list = listeners.toArray(list); } for (int i = 0; i < list.length; i++) - ((ContainerListener) list[i]).containerEvent(event); + list[i].containerEvent(event); } @@ -1471,7 +1472,7 @@ public abstract class ContainerBase public ObjectName[] getChildren() { ObjectName result[]=new ObjectName[children.size()]; - Iterator it=children.values().iterator(); + Iterator it=children.values().iterator(); int i=0; while( it.hasNext() ) { Object next=it.next(); @@ -1556,7 +1557,7 @@ public abstract class ContainerBase try { thread.join(); } catch (InterruptedException e) { - ; + // Ignore } thread = null; @@ -1578,7 +1579,7 @@ public abstract class ContainerBase try { Thread.sleep(backgroundProcessorDelay * 1000L); } catch (InterruptedException e) { - ; + // Ignore } if (!threadDone) { Container parent = (Container) getMappingObject(); diff --git a/java/org/apache/catalina/core/DummyRequest.java b/java/org/apache/catalina/core/DummyRequest.java index 2b6efcef7..b70ae56d3 100644 --- a/java/org/apache/catalina/core/DummyRequest.java +++ b/java/org/apache/catalina/core/DummyRequest.java @@ -77,7 +77,7 @@ public class DummyRequest protected FilterChain filterChain = null; - private static Enumeration dummyEnum = new Enumeration(){ + private static Enumeration dummyEnum = new Enumeration(){ public boolean hasMoreElements(){ return false; } @@ -179,7 +179,7 @@ public class DummyRequest } public void finishRequest() throws IOException {} public Object getNote(String name) { return null; } - public Iterator getNoteNames() { return null; } + public Iterator getNoteNames() { return null; } public void removeNote(String name) {} public void setContentType(String type) {} public void setNote(String name, Object value) {} diff --git a/java/org/apache/catalina/core/NamingContextListener.java b/java/org/apache/catalina/core/NamingContextListener.java index f75ededec..271df8c7e 100644 --- a/java/org/apache/catalina/core/NamingContextListener.java +++ b/java/org/apache/catalina/core/NamingContextListener.java @@ -39,13 +39,11 @@ import org.apache.catalina.Container; import org.apache.catalina.ContainerEvent; import org.apache.catalina.ContainerListener; import org.apache.catalina.Context; -import org.apache.catalina.Engine; import org.apache.catalina.Host; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; import org.apache.catalina.Server; -import org.apache.catalina.Service; import org.apache.catalina.deploy.ContextEjb; import org.apache.catalina.deploy.ContextEnvironment; import org.apache.catalina.deploy.ContextHandler; @@ -137,7 +135,8 @@ public class NamingContextListener /** * Objectnames hashtable. */ - protected HashMap objectNames = new HashMap(); + protected HashMap objectNames = + new HashMap(); /** @@ -218,7 +217,7 @@ public class NamingContextListener if (initialized) return; - Hashtable contextEnv = new Hashtable(); + Hashtable contextEnv = new Hashtable(); try { namingContext = new NamingContext(contextEnv, getName()); } catch (NamingException e) { @@ -665,9 +664,9 @@ public class NamingContextListener compCtx.bind("UserTransaction", ref); ContextTransaction transaction = namingResources.getTransaction(); if (transaction != null) { - Iterator params = transaction.listProperties(); + Iterator params = transaction.listProperties(); while (params.hasNext()) { - String paramName = (String) params.next(); + String paramName = params.next(); String paramValue = (String) transaction.getProperty(paramName); StringRefAddr refAddr = new StringRefAddr(paramName, paramValue); ref.add(refAddr); @@ -726,8 +725,6 @@ public class NamingContextListener if (path.length() < 1) path = "/"; Host host = (Host) ((Context)container).getParent(); - Engine engine = (Engine) host.getParent(); - Service service = engine.getService(); name = new ObjectName(domain + ":type=DataSource" + ",path=" + path + ",host=" + host.getName() + @@ -749,9 +746,9 @@ public class NamingContextListener Reference ref = new EjbRef (ejb.getType(), ejb.getHome(), ejb.getRemote(), ejb.getLink()); // Adding the additional parameters, if any - Iterator params = ejb.listProperties(); + Iterator params = ejb.listProperties(); while (params.hasNext()) { - String paramName = (String) params.next(); + String paramName = params.next(); String paramValue = (String) ejb.getProperty(paramName); StringRefAddr refAddr = new StringRefAddr(paramName, paramValue); ref.add(refAddr); @@ -938,31 +935,31 @@ public class NamingContextListener (service.getName(), service.getType(), service.getServiceqname(), service.getWsdlfile(), service.getJaxrpcmappingfile()); // Adding the additional port-component-ref, if any - Iterator portcomponent = service.getServiceendpoints(); + Iterator portcomponent = service.getServiceendpoints(); while (portcomponent.hasNext()) { - String serviceendpoint = (String) portcomponent.next(); + String serviceendpoint = portcomponent.next(); StringRefAddr refAddr = new StringRefAddr(ServiceRef.SERVICEENDPOINTINTERFACE, serviceendpoint); ref.add(refAddr); - String portlink = (String) service.getPortlink(serviceendpoint); + String portlink = service.getPortlink(serviceendpoint); refAddr = new StringRefAddr(ServiceRef.PORTCOMPONENTLINK, portlink); ref.add(refAddr); } // Adding the additional parameters, if any - Iterator handlers = service.getHandlers(); + Iterator handlers = service.getHandlers(); while (handlers.hasNext()) { - String handlername = (String) handlers.next(); - ContextHandler handler = (ContextHandler) service.getHandler(handlername); + String handlername = handlers.next(); + ContextHandler handler = service.getHandler(handlername); HandlerRef handlerRef = new HandlerRef(handlername, handler.getHandlerclass()); - Iterator localParts = handler.getLocalparts(); + Iterator localParts = handler.getLocalparts(); while (localParts.hasNext()) { - String localPart = (String) localParts.next(); - String namespaceURI = (String) handler.getNamespaceuri(localPart); + String localPart = localParts.next(); + String namespaceURI = handler.getNamespaceuri(localPart); handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_LOCALPART, localPart)); handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_NAMESPACE, namespaceURI)); } - Iterator params = handler.listProperties(); + Iterator params = handler.listProperties(); while (params.hasNext()) { - String paramName = (String) params.next(); + String paramName = params.next(); String paramValue = (String) handler.getProperty(paramName); handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PARAMNAME, paramName)); handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PARAMVALUE, paramValue)); @@ -1000,9 +997,9 @@ public class NamingContextListener (resource.getType(), resource.getDescription(), resource.getScope(), resource.getAuth()); // Adding the additional parameters, if any - Iterator params = resource.listProperties(); + Iterator params = resource.listProperties(); while (params.hasNext()) { - String paramName = (String) params.next(); + String paramName = params.next(); String paramValue = (String) resource.getProperty(paramName); StringRefAddr refAddr = new StringRefAddr(paramName, paramValue); ref.add(refAddr); @@ -1040,9 +1037,9 @@ public class NamingContextListener // Create a reference to the resource env. Reference ref = new ResourceEnvRef(resourceEnvRef.getType()); // Adding the additional parameters, if any - Iterator params = resourceEnvRef.listProperties(); + Iterator params = resourceEnvRef.listProperties(); while (params.hasNext()) { - String paramName = (String) params.next(); + String paramName = params.next(); String paramValue = (String) resourceEnvRef.getProperty(paramName); StringRefAddr refAddr = new StringRefAddr(paramName, paramValue); ref.add(refAddr); @@ -1149,7 +1146,7 @@ public class NamingContextListener logger.error(sm.getString("naming.unbindFailed", e)); } - ObjectName on = (ObjectName) objectNames.get(name); + ObjectName on = objectNames.get(name); if (on != null) { Registry.getRegistry(null, null).unregisterComponent(on); } diff --git a/java/org/apache/catalina/core/StandardContextValve.java b/java/org/apache/catalina/core/StandardContextValve.java index dd4483619..4a72c0e94 100644 --- a/java/org/apache/catalina/core/StandardContextValve.java +++ b/java/org/apache/catalina/core/StandardContextValve.java @@ -131,7 +131,7 @@ final class StandardContextValve try { Thread.sleep(1000); } catch (InterruptedException e) { - ; + // Ignore } } @@ -309,9 +309,9 @@ final class StandardContextValve try { response.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (IllegalStateException e) { - ; + // Ignore } catch (IOException e) { - ; + // Ignore } } diff --git a/java/org/apache/catalina/core/StandardHost.java b/java/org/apache/catalina/core/StandardHost.java index 7456fb19d..73762e6e3 100644 --- a/java/org/apache/catalina/core/StandardHost.java +++ b/java/org/apache/catalina/core/StandardHost.java @@ -134,12 +134,6 @@ public class StandardHost /** - * The live deploy flag for this Host. - */ - private boolean liveDeploy = true; - - - /** * Unpack WARs property. */ private boolean unpackWARs = true; diff --git a/java/org/apache/catalina/core/StandardPipeline.java b/java/org/apache/catalina/core/StandardPipeline.java index f67b523c3..e1c7203d8 100644 --- a/java/org/apache/catalina/core/StandardPipeline.java +++ b/java/org/apache/catalina/core/StandardPipeline.java @@ -375,7 +375,7 @@ public class StandardPipeline try { ((Contained) oldBasic).setContainer(null); } catch (Throwable t) { - ; + // Ignore } } } @@ -474,7 +474,7 @@ public class StandardPipeline */ public Valve[] getValves() { - ArrayList valveList = new ArrayList(); + ArrayList valveList = new ArrayList(); Valve current = first; if (current == null) { current = basic; @@ -484,13 +484,13 @@ public class StandardPipeline current = current.getNext(); } - return ((Valve[]) valveList.toArray(new Valve[0])); + return valveList.toArray(new Valve[0]); } public ObjectName[] getValveObjectNames() { - ArrayList valveList = new ArrayList(); + ArrayList valveList = new ArrayList(); Valve current = first; if (current == null) { current = basic; @@ -502,7 +502,7 @@ public class StandardPipeline current = current.getNext(); } - return ((ObjectName[]) valveList.toArray(new ObjectName[0])); + return valveList.toArray(new ObjectName[0]); } diff --git a/java/org/apache/catalina/core/StandardServer.java b/java/org/apache/catalina/core/StandardServer.java index 3548d6a0a..3c7099c77 100644 --- a/java/org/apache/catalina/core/StandardServer.java +++ b/java/org/apache/catalina/core/StandardServer.java @@ -64,16 +64,6 @@ public final class StandardServer private static Log log = LogFactory.getLog(StandardServer.class); - // -------------------------------------------------------------- Constants - - - /** - * ServerLifecycleListener classname. - */ - private static String SERVER_LISTENER_CLASS_NAME = - "org.apache.catalina.mbeans.ServerLifecycleListener"; - - // ------------------------------------------------------------ Constructor @@ -358,7 +348,7 @@ public final class StandardServer try { ((Lifecycle) service).start(); } catch (LifecycleException e) { - ; + // Ignore } } @@ -451,7 +441,7 @@ public final class StandardServer try { socket.close(); } catch (IOException e) { - ; + // Ignore } // Match against our command string @@ -468,7 +458,7 @@ public final class StandardServer try { serverSocket.close(); } catch (IOException e) { - ; + // Ignore } } @@ -540,7 +530,7 @@ public final class StandardServer try { ((Lifecycle) services[j]).stop(); } catch (LifecycleException e) { - ; + // Ignore } } int k = 0; diff --git a/java/org/apache/catalina/core/StandardService.java b/java/org/apache/catalina/core/StandardService.java index 42ac3cc1c..a1c770aa5 100644 --- a/java/org/apache/catalina/core/StandardService.java +++ b/java/org/apache/catalina/core/StandardService.java @@ -158,7 +158,7 @@ public class StandardService try { ((Lifecycle) this.container).start(); } catch (LifecycleException e) { - ; + // Ignore } } synchronized (connectors) { @@ -170,7 +170,7 @@ public class StandardService try { ((Lifecycle) oldContainer).stop(); } catch (LifecycleException e) { - ; + // Ignore } } @@ -270,7 +270,7 @@ public class StandardService } } - if (started && (connector instanceof Lifecycle)) { + if (started) { try { ((Lifecycle) connector).start(); } catch (LifecycleException e) { @@ -334,7 +334,7 @@ public class StandardService } if (j < 0) return; - if (started && (connectors[j] instanceof Lifecycle)) { + if (started) { try { ((Lifecycle) connectors[j]).stop(); } catch (LifecycleException e) { @@ -527,8 +527,7 @@ public class StandardService // Start our defined Connectors second synchronized (connectors) { for (int i = 0; i < connectors.length; i++) { - if (connectors[i] instanceof Lifecycle) - ((Lifecycle) connectors[i]).start(); + ((Lifecycle) connectors[i]).start(); } } @@ -589,8 +588,7 @@ public class StandardService // Stop our defined Connectors first synchronized (connectors) { for (int i = 0; i < connectors.length; i++) { - if (connectors[i] instanceof Lifecycle) - ((Lifecycle) connectors[i]).stop(); + ((Lifecycle) connectors[i]).stop(); } } diff --git a/java/org/apache/catalina/core/StandardThreadExecutor.java b/java/org/apache/catalina/core/StandardThreadExecutor.java index 6f853df08..9e7d1426e 100644 --- a/java/org/apache/catalina/core/StandardThreadExecutor.java +++ b/java/org/apache/catalina/core/StandardThreadExecutor.java @@ -91,7 +91,7 @@ public class StandardThreadExecutor implements Executor { TaskThreadFactory tf = new TaskThreadFactory(namePrefix,daemon,getThreadPriority()); lifecycle.fireLifecycleEvent(START_EVENT, null); executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf); - taskqueue.setParent( (ThreadPoolExecutor) executor); + taskqueue.setParent(executor); lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null); } diff --git a/java/org/apache/catalina/core/StandardWrapper.java b/java/org/apache/catalina/core/StandardWrapper.java index 41c5b730f..dfc9ad1c1 100644 --- a/java/org/apache/catalina/core/StandardWrapper.java +++ b/java/org/apache/catalina/core/StandardWrapper.java @@ -160,14 +160,14 @@ public class StandardWrapper /** * Mappings associated with the wrapper. */ - protected ArrayList mappings = new ArrayList(); + protected ArrayList mappings = new ArrayList(); /** * The initialization parameters for this servlet, keyed by * parameter name. */ - protected HashMap parameters = new HashMap(); + protected HashMap parameters = new HashMap(); /** @@ -175,7 +175,7 @@ public class StandardWrapper * used in the servlet. The corresponding value is the role name of * the web application itself. */ - protected HashMap references = new HashMap(); + protected HashMap references = new HashMap(); /** @@ -221,7 +221,7 @@ public class StandardWrapper /** * Stack containing the STM instances. */ - protected Stack instancePool = null; + protected Stack instancePool = null; /** @@ -256,14 +256,14 @@ public class StandardWrapper * Static class array used when the SecurityManager is turned on and * Servlet.init is invoked. */ - protected static Class[] classType = new Class[]{ServletConfig.class}; + protected static Class[] classType = new Class[]{ServletConfig.class}; /** * Static class array used when the SecurityManager is turned on and * Servlet.service is invoked. */ - protected static Class[] classTypeUsedInService = new Class[]{ + protected static Class[] classTypeUsedInService = new Class[]{ ServletRequest.class, ServletResponse.class}; @@ -558,7 +558,7 @@ public class StandardWrapper try { loadServlet(); } catch (Throwable t) { - ; + // Ignore } return (singleThreadModel); @@ -593,13 +593,13 @@ public class StandardWrapper */ public String[] getServletMethods() throws ServletException { - Class servletClazz = loadServlet().getClass(); + Class servletClazz = loadServlet().getClass(); if (!javax.servlet.http.HttpServlet.class.isAssignableFrom( servletClazz)) { return DEFAULT_SERVLET_METHODS; } - HashSet allow = new HashSet(); + HashSet allow = new HashSet(); allow.add("TRACE"); allow.add("OPTIONS"); @@ -620,7 +620,7 @@ public class StandardWrapper } String[] methodNames = new String[allow.size()]; - return (String[]) allow.toArray(methodNames); + return allow.toArray(methodNames); } @@ -827,14 +827,14 @@ public class StandardWrapper try { instancePool.wait(); } catch (InterruptedException e) { - ; + // Ignore } } } if (log.isTraceEnabled()) log.trace(" Returning allocated STM instance"); countAllocated.incrementAndGet(); - return (Servlet) instancePool.pop(); + return instancePool.pop(); } @@ -877,7 +877,7 @@ public class StandardWrapper public String findInitParameter(String name) { synchronized (parameters) { - return ((String) parameters.get(name)); + return parameters.get(name); } } @@ -891,7 +891,7 @@ public class StandardWrapper synchronized (parameters) { String results[] = new String[parameters.size()]; - return ((String[]) parameters.keySet().toArray(results)); + return parameters.keySet().toArray(results); } } @@ -903,7 +903,7 @@ public class StandardWrapper public String[] findMappings() { synchronized (mappings) { - return (String[]) mappings.toArray(new String[mappings.size()]); + return mappings.toArray(new String[mappings.size()]); } } @@ -918,7 +918,7 @@ public class StandardWrapper public String findSecurityReference(String name) { synchronized (references) { - return ((String) references.get(name)); + return references.get(name); } } @@ -932,7 +932,7 @@ public class StandardWrapper synchronized (references) { String results[] = new String[references.size()]; - return ((String[]) references.keySet().toArray(results)); + return references.keySet().toArray(results); } } @@ -1055,7 +1055,7 @@ public class StandardWrapper if( Globals.IS_SECURITY_ENABLED) { - Object[] args = new Object[]{((ServletConfig)facade)}; + Object[] args = new Object[]{(facade)}; SecurityUtil.doAsPrivilege("init", servlet, classType, @@ -1111,7 +1111,7 @@ public class StandardWrapper singleThreadModel = servlet instanceof SingleThreadModel; if (singleThreadModel) { if (instancePool == null) - instancePool = new Stack(); + instancePool = new Stack(); } fireContainerEvent("load", this); @@ -1262,7 +1262,7 @@ public class StandardWrapper try { Thread.sleep(delay); } catch (InterruptedException e) { - ; + // Ignore } nRetries++; } @@ -1325,7 +1325,7 @@ public class StandardWrapper if (singleThreadModel && (instancePool != null)) { try { while (!instancePool.isEmpty()) { - Servlet s = (Servlet) instancePool.pop(); + Servlet s = instancePool.pop(); if (Globals.IS_SECURITY_ENABLED) { SecurityUtil.doAsPrivilege("destroy", s); SecurityUtil.remove(instance); @@ -1378,10 +1378,10 @@ public class StandardWrapper * Return the set of initialization parameter names defined for this * servlet. If none are defined, an empty Enumeration is returned. */ - public Enumeration getInitParameterNames() { + public Enumeration getInitParameterNames() { synchronized (parameters) { - return (new Enumerator(parameters.keySet())); + return (new Enumerator(parameters.keySet())); } } @@ -1484,7 +1484,7 @@ public class StandardWrapper */ protected void addDefaultMapper(String mapperClass) { - ; // No need for a default Mapper on a Wrapper + // No need for a default Mapper on a Wrapper } @@ -1502,7 +1502,7 @@ public class StandardWrapper return (true); } try { - Class clazz = + Class clazz = this.getClass().getClassLoader().loadClass(classname); return (ContainerServlet.class.isAssignableFrom(clazz)); } catch (Throwable t) { @@ -1512,7 +1512,7 @@ public class StandardWrapper } - protected Method[] getAllDeclaredMethods(Class c) { + protected Method[] getAllDeclaredMethods(Class c) { if (c.equals(javax.servlet.http.HttpServlet.class)) { return null; diff --git a/java/org/apache/catalina/core/StandardWrapperFacade.java b/java/org/apache/catalina/core/StandardWrapperFacade.java index c42e1d973..c36c8edbe 100644 --- a/java/org/apache/catalina/core/StandardWrapperFacade.java +++ b/java/org/apache/catalina/core/StandardWrapperFacade.java @@ -45,7 +45,7 @@ public final class StandardWrapperFacade public StandardWrapperFacade(StandardWrapper config) { super(); - this.config = (ServletConfig) config; + this.config = config; }