From 6f288133c49c44bfc8d5ed589784c52315c5201a Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 30 Nov 2008 15:59:48 +0000 Subject: [PATCH] Generics for o.a.coyote git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@721835 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/coyote/ProtocolHandler.java | 2 +- java/org/apache/coyote/Request.java | 4 ++-- java/org/apache/coyote/RequestGroupInfo.java | 26 +++++++++++----------- java/org/apache/coyote/ajp/AjpAprProcessor.java | 4 ++-- java/org/apache/coyote/ajp/AjpAprProtocol.java | 7 +++--- java/org/apache/coyote/ajp/AjpProcessor.java | 4 ++-- java/org/apache/coyote/ajp/AjpProtocol.java | 7 +++--- .../apache/coyote/http11/Http11AprProtocol.java | 10 ++++----- .../apache/coyote/http11/Http11NioProtocol.java | 9 ++++---- java/org/apache/coyote/http11/Http11Protocol.java | 4 ++-- .../apache/coyote/http11/InternalOutputBuffer.java | 10 ++++----- .../coyote/memory/MemoryProtocolHandler.java | 2 +- 12 files changed, 46 insertions(+), 43 deletions(-) diff --git a/java/org/apache/coyote/ProtocolHandler.java b/java/org/apache/coyote/ProtocolHandler.java index 0e8113599..d2b392c5b 100644 --- a/java/org/apache/coyote/ProtocolHandler.java +++ b/java/org/apache/coyote/ProtocolHandler.java @@ -42,7 +42,7 @@ public interface ProtocolHandler { public Object getAttribute(String name); - public Iterator getAttributeNames(); + public Iterator getAttributeNames(); /** * The adapter, used to call the connector. diff --git a/java/org/apache/coyote/Request.java b/java/org/apache/coyote/Request.java index 6c8897373..8390d387c 100644 --- a/java/org/apache/coyote/Request.java +++ b/java/org/apache/coyote/Request.java @@ -135,7 +135,7 @@ public final class Request { private MessageBytes remoteUser=MessageBytes.newInstance(); private MessageBytes authType=MessageBytes.newInstance(); - private HashMap attributes=new HashMap(); + private HashMap attributes=new HashMap(); private Response response; private ActionHook hook; @@ -377,7 +377,7 @@ public final class Request { attributes.put( name, o ); } - public HashMap getAttributes() { + public HashMap getAttributes() { return attributes; } diff --git a/java/org/apache/coyote/RequestGroupInfo.java b/java/org/apache/coyote/RequestGroupInfo.java index 41fa3fefc..f0625e29f 100644 --- a/java/org/apache/coyote/RequestGroupInfo.java +++ b/java/org/apache/coyote/RequestGroupInfo.java @@ -24,7 +24,7 @@ import java.util.ArrayList; * collected from each RequestProcessor thread. */ public class RequestGroupInfo { - ArrayList processors=new ArrayList(); + ArrayList processors=new ArrayList(); private long deadMaxTime = 0; private long deadProcessingTime = 0; private int deadRequestCount = 0; @@ -53,7 +53,7 @@ public class RequestGroupInfo { public synchronized long getMaxTime() { long maxTime=deadMaxTime; for( int i=0; i colonPos; i--) { - int charValue = HexUtils.DEC[(int) valueB[i + valueS]]; + int charValue = HexUtils.DEC[valueB[i + valueS]]; if (charValue == -1) { // Invalid character error = true; diff --git a/java/org/apache/coyote/ajp/AjpAprProtocol.java b/java/org/apache/coyote/ajp/AjpAprProtocol.java index a51bb1520..3160a773d 100644 --- a/java/org/apache/coyote/ajp/AjpAprProtocol.java +++ b/java/org/apache/coyote/ajp/AjpAprProtocol.java @@ -95,7 +95,8 @@ public class AjpAprProtocol /** * Configuration attributes. */ - protected Hashtable attributes = new Hashtable(); + protected Hashtable attributes = + new Hashtable(); /** @@ -131,7 +132,7 @@ public class AjpAprProtocol } - public Iterator getAttributeNames() { + public Iterator getAttributeNames() { return attributes.keySet().iterator(); } @@ -447,7 +448,7 @@ public class AjpAprProtocol try { RequestInfo rp = processor.getRequest().getRequestProcessor(); rp.setGlobalProcessor(null); - ObjectName rpName = (ObjectName) rp.getRpName(); + ObjectName rpName = rp.getRpName(); if (log.isDebugEnabled()) { log.debug("Unregister " + rpName); } diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java b/java/org/apache/coyote/ajp/AjpProcessor.java index 5c6eab90b..ae07711db 100644 --- a/java/org/apache/coyote/ajp/AjpProcessor.java +++ b/java/org/apache/coyote/ajp/AjpProcessor.java @@ -640,7 +640,7 @@ public class AjpProcessor implements ActionHook { // Translate the HTTP method code to a String. byte methodCode = requestHeaderMessage.getByte(); if (methodCode != Constants.SC_M_JK_STORED) { - String methodName = Constants.methodTransArray[(int)methodCode - 1]; + String methodName = Constants.methodTransArray[methodCode - 1]; request.method().setString(methodName); } @@ -900,7 +900,7 @@ public class AjpProcessor implements ActionHook { int port = 0; int mult = 1; for (int i = valueL - 1; i > colonPos; i--) { - int charValue = HexUtils.DEC[(int) valueB[i + valueS]]; + int charValue = HexUtils.DEC[valueB[i + valueS]]; if (charValue == -1) { // Invalid character error = true; diff --git a/java/org/apache/coyote/ajp/AjpProtocol.java b/java/org/apache/coyote/ajp/AjpProtocol.java index 1ff288170..0d1663251 100644 --- a/java/org/apache/coyote/ajp/AjpProtocol.java +++ b/java/org/apache/coyote/ajp/AjpProtocol.java @@ -95,7 +95,8 @@ public class AjpProtocol /** * Configuration attributes. */ - protected Hashtable attributes = new Hashtable(); + protected Hashtable attributes = + new Hashtable(); /** @@ -131,7 +132,7 @@ public class AjpProtocol } - public Iterator getAttributeNames() { + public Iterator getAttributeNames() { return attributes.keySet().iterator(); } @@ -433,7 +434,7 @@ public class AjpProtocol try { RequestInfo rp = processor.getRequest().getRequestProcessor(); rp.setGlobalProcessor(null); - ObjectName rpName = (ObjectName) rp.getRpName(); + ObjectName rpName = rp.getRpName(); if (log.isDebugEnabled()) { log.debug("Unregister " + rpName); } diff --git a/java/org/apache/coyote/http11/Http11AprProtocol.java b/java/org/apache/coyote/http11/Http11AprProtocol.java index c7c6c7d9c..0b4aeabdf 100644 --- a/java/org/apache/coyote/http11/Http11AprProtocol.java +++ b/java/org/apache/coyote/http11/Http11AprProtocol.java @@ -85,7 +85,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration { return attributes.get(key); } - public Iterator getAttributeNames() { + public Iterator getAttributeNames() { return attributes.keySet().iterator(); } @@ -518,7 +518,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration { } public SocketState event(long socket, SocketStatus status) { - Http11AprProcessor result = connections.get(socket); + Http11AprProcessor result = connections.get(Long.valueOf(socket)); SocketState state = SocketState.CLOSED; if (result != null) { @@ -547,7 +547,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration { (sm.getString("http11protocol.proto.error"), e); } finally { if (state != SocketState.LONG) { - connections.remove(socket); + connections.remove(Long.valueOf(socket)); recycledProcessors.offer(result); if (state == SocketState.OPEN) { proto.endpoint.getPoller().add(socket); @@ -576,7 +576,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration { // Associate the connection with the processor. The next request // processed by this thread will use either a new or a recycled // processor. - connections.put(socket, processor); + connections.put(Long.valueOf(socket), processor); proto.endpoint.getCometPoller().add(socket); } else { recycledProcessors.offer(processor); @@ -655,7 +655,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration { try { RequestInfo rp = processor.getRequest().getRequestProcessor(); rp.setGlobalProcessor(null); - ObjectName rpName = (ObjectName) rp.getRpName(); + ObjectName rpName = rp.getRpName(); if (log.isDebugEnabled()) { log.debug("Unregister " + rpName); } diff --git a/java/org/apache/coyote/http11/Http11NioProtocol.java b/java/org/apache/coyote/http11/Http11NioProtocol.java index b30ceef0f..e765eb66d 100644 --- a/java/org/apache/coyote/http11/Http11NioProtocol.java +++ b/java/org/apache/coyote/http11/Http11NioProtocol.java @@ -91,7 +91,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration return attributes.get(key); } - public Iterator getAttributeNames() { + public Iterator getAttributeNames() { return attributes.keySet().iterator(); } @@ -209,7 +209,8 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration protected NioEndpoint ep=new NioEndpoint(); protected boolean secure = false; - protected Hashtable attributes = new Hashtable(); + protected Hashtable attributes = + new Hashtable(); private int maxKeepAliveRequests=100; // as in Apache HTTPD server private int timeout = 300000; // 5 minutes as in Apache HTTPD server @@ -534,7 +535,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration public void setOomParachute(int oomParachute) { ep.setOomParachute(oomParachute); - setAttribute("oomParachute",oomParachute); + setAttribute("oomParachute", Integer.valueOf(oomParachute)); } // -------------------- SSL related properties -------------------- @@ -812,7 +813,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration if (log.isDebugEnabled()) log.debug("Deregister ["+processor+"] count="+registerCount.get()); RequestInfo rp = processor.getRequest().getRequestProcessor(); rp.setGlobalProcessor(null); - ObjectName rpName = (ObjectName) rp.getRpName(); + ObjectName rpName = rp.getRpName(); Registry.getRegistry(null, null).unregisterComponent(rpName); rp.setRpName(null); } catch (Exception e) { diff --git a/java/org/apache/coyote/http11/Http11Protocol.java b/java/org/apache/coyote/http11/Http11Protocol.java index b4740d44d..784597a8b 100644 --- a/java/org/apache/coyote/http11/Http11Protocol.java +++ b/java/org/apache/coyote/http11/Http11Protocol.java @@ -116,7 +116,7 @@ public class Http11Protocol return attributes.get(key); } - public Iterator getAttributeNames() { + public Iterator getAttributeNames() { return attributes.keySet().iterator(); } @@ -667,7 +667,7 @@ public class Http11Protocol try { RequestInfo rp = processor.getRequest().getRequestProcessor(); rp.setGlobalProcessor(null); - ObjectName rpName = (ObjectName) rp.getRpName(); + ObjectName rpName = rp.getRpName(); if (log.isDebugEnabled()) { log.debug("Unregister " + rpName); } diff --git a/java/org/apache/coyote/http11/InternalOutputBuffer.java b/java/org/apache/coyote/http11/InternalOutputBuffer.java index efbfef81c..0de094cdd 100644 --- a/java/org/apache/coyote/http11/InternalOutputBuffer.java +++ b/java/org/apache/coyote/http11/InternalOutputBuffer.java @@ -451,8 +451,8 @@ public class InternalOutputBuffer // End the response status line if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){ AccessController.doPrivileged( - new PrivilegedAction(){ - public Object run(){ + new PrivilegedAction(){ + public Void run(){ buf[pos++] = Constants.CR; buf[pos++] = Constants.LF; return null; @@ -468,9 +468,9 @@ public class InternalOutputBuffer private String getMessage(final int message){ if (org.apache.coyote.Constants.IS_SECURITY_ENABLED){ - return (String)AccessController.doPrivileged( - new PrivilegedAction(){ - public Object run(){ + return AccessController.doPrivileged( + new PrivilegedAction(){ + public String run(){ return HttpMessages.getMessage(message); } } diff --git a/java/org/apache/coyote/memory/MemoryProtocolHandler.java b/java/org/apache/coyote/memory/MemoryProtocolHandler.java index bbb8fe910..b7da7ee31 100644 --- a/java/org/apache/coyote/memory/MemoryProtocolHandler.java +++ b/java/org/apache/coyote/memory/MemoryProtocolHandler.java @@ -53,7 +53,7 @@ public class MemoryProtocolHandler return null; } - public Iterator getAttributeNames() { return null ; } + public Iterator getAttributeNames() { return null ; } /** * Associated adapter. */ -- 2.11.0