Author: markt Date: Thu Aug 16 20:15:28 2012 New Revision: 1374032 URL: http://svn.apache.org/viewvc?rev=1374032&view=rev Log: Code clean-up - Java 7 <> - UCDetector use of final - Make use of unused fields where appropriate
Modified: tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java tomcat/trunk/java/org/apache/coyote/LocalStrings.properties tomcat/trunk/java/org/apache/coyote/Request.java tomcat/trunk/java/org/apache/coyote/RequestGroupInfo.java tomcat/trunk/java/org/apache/coyote/RequestInfo.java Modified: tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java?rev=1374032&r1=1374031&r2=1374032&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java Thu Aug 16 20:15:28 2012 @@ -32,10 +32,10 @@ import org.apache.tomcat.util.net.Socket public abstract class AbstractProcessor<S> implements ActionHook, Processor<S> { protected Adapter adapter; - protected AsyncStateMachine<S> asyncStateMachine; - protected AbstractEndpoint endpoint; - protected Request request; - protected Response response; + protected final AsyncStateMachine<S> asyncStateMachine; + protected final AbstractEndpoint endpoint; + protected final Request request; + protected final Response response; /** @@ -43,12 +43,15 @@ public abstract class AbstractProcessor< * initialise the request, response, etc. */ protected AbstractProcessor() { - // NOOP + asyncStateMachine = null; + endpoint = null; + request = null; + response = null; } public AbstractProcessor(AbstractEndpoint endpoint) { this.endpoint = endpoint; - asyncStateMachine = new AsyncStateMachine<S>(this); + asyncStateMachine = new AsyncStateMachine<>(this); request = new Request(); Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1374032&r1=1374031&r2=1374032&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Thu Aug 16 20:15:28 2012 @@ -24,7 +24,9 @@ import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import javax.management.InstanceNotFoundException; import javax.management.MBeanRegistration; +import javax.management.MBeanRegistrationException; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -508,7 +510,19 @@ public abstract class AbstractProtocol i } if (oname != null) { - Registry.getRegistry(null, null).unregisterComponent(oname); + if (mserver == null) { + Registry.getRegistry(null, null).unregisterComponent(oname); + } else { + // Possibly registered with a different MBeanServer + try { + mserver.unregisterMBean(oname); + } catch (MBeanRegistrationException | + InstanceNotFoundException e) { + getLog().info(sm.getString( + "abstractProtocol.mbeanDeregistrationFailed", + oname, mserver)); + } + } } if (tpOname != null) @@ -525,14 +539,14 @@ public abstract class AbstractProtocol i protected abstract Log getLog(); - protected RequestGroupInfo global = new RequestGroupInfo(); - protected AtomicLong registerCount = new AtomicLong(0); + protected final RequestGroupInfo global = new RequestGroupInfo(); + protected final AtomicLong registerCount = new AtomicLong(0); - protected ConcurrentHashMap<S,Processor<S>> connections = - new ConcurrentHashMap<S,Processor<S>>(); + protected final ConcurrentHashMap<S,Processor<S>> connections = + new ConcurrentHashMap<>(); - protected RecycledProcessors<P,S> recycledProcessors = - new RecycledProcessors<P,S>(this); + protected final RecycledProcessors<P,S> recycledProcessors = + new RecycledProcessors<>(this); protected abstract AbstractProtocol getProtocol(); @@ -721,8 +735,8 @@ public abstract class AbstractProtocol i extends ConcurrentLinkedQueue<Processor<S>> { private static final long serialVersionUID = 1L; - private transient AbstractConnectionHandler<S,P> handler; - protected AtomicInteger size = new AtomicInteger(0); + private final transient AbstractConnectionHandler<S,P> handler; + protected final AtomicInteger size = new AtomicInteger(0); public RecycledProcessors(AbstractConnectionHandler<S,P> handler) { this.handler = handler; Modified: tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java?rev=1374032&r1=1374031&r2=1374032&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java (original) +++ tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java Thu Aug 16 20:15:28 2012 @@ -137,7 +137,7 @@ public class AsyncStateMachine<S> { private volatile AsyncState state = AsyncState.DISPATCHED; // Need this to fire listener on complete private AsyncContextCallback asyncCtxt = null; - private Processor<S> processor; + private final Processor<S> processor; public AsyncStateMachine(Processor<S> processor) { Modified: tomcat/trunk/java/org/apache/coyote/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/LocalStrings.properties?rev=1374032&r1=1374031&r2=1374032&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/coyote/LocalStrings.properties Thu Aug 16 20:15:28 2012 @@ -16,6 +16,8 @@ abstractConnectionHandler.error=Error re abstractConnectionHandler.ioexception.debug=IOExceptions are normal, ignored abstractConnectionHandler.socketexception.debug=SocketExceptions are normal, ignored +abstractProtocol.mbeanDeregistrationFailed=Failed to deregister MBean named [{0}] from MBean server [{1}] + abstractProtocolHandler.getAttribute=Get attribute [{0}] with value [{1}] abstractProtocolHandler.setAttribute=Set attribute [{0}] with value [{1}] abstractProtocolHandler.init=Initializing ProtocolHandler [{0}] Modified: tomcat/trunk/java/org/apache/coyote/Request.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Request.java?rev=1374032&r1=1374031&r2=1374032&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/Request.java (original) +++ tomcat/trunk/java/org/apache/coyote/Request.java Thu Aug 16 20:15:28 2012 @@ -128,7 +128,7 @@ public final class Request { private final MessageBytes remoteUser=MessageBytes.newInstance(); private final MessageBytes authType=MessageBytes.newInstance(); - private final HashMap<String,Object> attributes=new HashMap<String,Object>(); + private final HashMap<String,Object> attributes=new HashMap<>(); private Response response; private ActionHook hook; Modified: tomcat/trunk/java/org/apache/coyote/RequestGroupInfo.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/RequestGroupInfo.java?rev=1374032&r1=1374031&r2=1374032&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/RequestGroupInfo.java (original) +++ tomcat/trunk/java/org/apache/coyote/RequestGroupInfo.java Thu Aug 16 20:15:28 2012 @@ -24,7 +24,7 @@ import java.util.ArrayList; * collected from each RequestProcessor thread. */ public class RequestGroupInfo { - ArrayList<RequestInfo> processors=new ArrayList<RequestInfo>(); + private final ArrayList<RequestInfo> processors = new ArrayList<>(); private long deadMaxTime = 0; private long deadProcessingTime = 0; private int deadRequestCount = 0; Modified: tomcat/trunk/java/org/apache/coyote/RequestInfo.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/RequestInfo.java?rev=1374032&r1=1374031&r2=1374032&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/RequestInfo.java (original) +++ tomcat/trunk/java/org/apache/coyote/RequestInfo.java Thu Aug 16 20:15:28 2012 @@ -35,7 +35,7 @@ import javax.management.ObjectName; * @author Costin Manolache */ public class RequestInfo { - RequestGroupInfo global=null; + private RequestGroupInfo global=null; // ----------------------------------------------------------- Constructors @@ -61,10 +61,10 @@ public class RequestInfo { // ----------------------------------------------------- Instance Variables - Request req; - int stage = Constants.STAGE_NEW; - String workerThreadName; - ObjectName rpName; + private final Request req; + private int stage = Constants.STAGE_NEW; + private String workerThreadName; + private ObjectName rpName; // -------------------- Information about the current request ----------- // This is useful for long-running requests only --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org