Code clean up o.a.t.util.net.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 27 Apr 2008 16:14:06 +0000 (16:14 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 27 Apr 2008 16:14:06 +0000 (16:14 +0000)
Generics and unused code.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@651976 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/NioBlockingSelector.java
java/org/apache/tomcat/util/net/NioEndpoint.java
java/org/apache/tomcat/util/net/NioSelectorPool.java
java/org/apache/tomcat/util/net/PoolTcpEndpoint.java
java/org/apache/tomcat/util/net/SSLImplementation.java
java/org/apache/tomcat/util/net/ServerSocketFactory.java
java/org/apache/tomcat/util/net/jsse/JSSESupport.java

index ce2f6c9..27117e3 100644 (file)
@@ -193,7 +193,8 @@ public class NioBlockingSelector {
     protected class BlockPoller extends Thread {
         protected boolean run = true;
         protected Selector selector = null;
-        protected ConcurrentLinkedQueue events = new ConcurrentLinkedQueue();
+        protected ConcurrentLinkedQueue<Runnable> events =
+            new ConcurrentLinkedQueue<Runnable>();
         public void disable() { run = false; selector.wakeup();}
         protected AtomicInteger wakeupCounter = new AtomicInteger(0);
         public void cancelKey(final NioChannel socket, final SelectionKey key) {
@@ -284,7 +285,7 @@ public class NioBlockingSelector {
             boolean result = false;
             Runnable r = null;
             result = (events.size() > 0);
-            while ( (r = (Runnable)events.poll()) != null ) {
+            while ( (r = events.poll()) != null ) {
                 r.run();
                 result = true;
             }
@@ -320,12 +321,13 @@ public class NioBlockingSelector {
                         continue;
                     }
 
-                    Iterator iterator = keyCount > 0 ? selector.selectedKeys().iterator() : null;
+                    Iterator<SelectionKey> iterator =
+                        keyCount > 0 ? selector.selectedKeys().iterator() : null;
 
                     // Walk through the collection of ready keys and dispatch
                     // any active event.
                     while (run && iterator != null && iterator.hasNext()) {
-                        SelectionKey sk = (SelectionKey) iterator.next();
+                        SelectionKey sk = iterator.next();
                         KeyAttachment attachment = (KeyAttachment)sk.attachment();
                         try {
                             attachment.access();
index 55eee32..80d0936 100644 (file)
@@ -1383,7 +1383,7 @@ public class NioEndpoint {
             //synchronized (events) {
                 Runnable r = null;
                 result = (events.size() > 0);
-                while ( (r = (Runnable)events.poll()) != null ) {
+                while ( (r = events.poll()) != null ) {
                     try {
                         r.run();
                         if ( r instanceof PollerEvent ) {
@@ -1497,11 +1497,12 @@ public class NioEndpoint {
                     //either we timed out or we woke up, process events first
                     if ( keyCount == 0 ) hasEvents = (hasEvents | events());
 
-                    Iterator iterator = keyCount > 0 ? selector.selectedKeys().iterator() : null;
+                    Iterator<SelectionKey> iterator =
+                        keyCount > 0 ? selector.selectedKeys().iterator() : null;
                     // Walk through the collection of ready keys and dispatch
                     // any active event.
                     while (iterator != null && iterator.hasNext()) {
-                        SelectionKey sk = (SelectionKey) iterator.next();
+                        SelectionKey sk = iterator.next();
                         KeyAttachment attachment = (KeyAttachment)sk.attachment();
                         attachment.access();
                         iterator.remove();
index aa61ffd..edb5598 100644 (file)
@@ -60,7 +60,8 @@ public class NioSelectorPool {
     protected boolean enabled = true;
     protected AtomicInteger active = new AtomicInteger(0);
     protected AtomicInteger spare = new AtomicInteger(0);
-    protected ConcurrentLinkedQueue<Selector> selectors = new ConcurrentLinkedQueue<Selector>();
+    protected ConcurrentLinkedQueue<Selector> selectors =
+        new ConcurrentLinkedQueue<Selector>();
 
     protected Selector getSharedSelector() throws IOException {
         if (SHARED && SHARED_SELECTOR == null) {
@@ -293,7 +294,7 @@ public class NioSelectorPool {
         return sharedSelectorTimeout;
     }
 
-    public ConcurrentLinkedQueue getSelectors() {
+    public ConcurrentLinkedQueue<Selector> getSelectors() {
         return selectors;
     }
 
index c356b5b..0b33793 100644 (file)
@@ -103,11 +103,13 @@ public class PoolTcpEndpoint implements Runnable { // implements Endpoint {
     /* The background thread. */
     private Thread thread = null;
     /* Available processors. */
-    private Stack workerThreads = new Stack();
+    private Stack<MasterSlaveWorkerThread> workerThreads =
+        new Stack<MasterSlaveWorkerThread>();
     private int curThreads = 0;
     private int maxThreads = 20;
     /* All processors which have been created. */
-    private Vector created = new Vector();
+    private Vector<MasterSlaveWorkerThread> created =
+        new Vector<MasterSlaveWorkerThread>();
 
     
     public PoolTcpEndpoint() {
@@ -569,7 +571,7 @@ public class PoolTcpEndpoint implements Runnable { // implements Endpoint {
 
         synchronized (workerThreads) {
             if (workerThreads.size() > 0) {
-                return ((MasterSlaveWorkerThread) workerThreads.pop());
+                return (workerThreads.pop());
             }
             if ((maxThreads > 0) && (curThreads < maxThreads)) {
                 return (newWorkerThread());
index 262d1e7..6cc6fa6 100644 (file)
@@ -67,7 +67,7 @@ abstract public class SSLImplementation {
            if( JSSEImplementationClass.equals(className) ) {
                return new org.apache.tomcat.util.net.jsse.JSSEImplementation();
            }
-           Class clazz=Class.forName(className);
+           Class<?> clazz=Class.forName(className);
            return (SSLImplementation)clazz.newInstance();
        } catch (Exception e){
            if(logger.isDebugEnabled())
index 00392a5..7cc03be 100644 (file)
@@ -55,7 +55,8 @@ public abstract class ServerSocketFactory implements Cloneable {
     //
 
     private static ServerSocketFactory theFactory;
-    protected Hashtable attributes=new Hashtable();
+    protected Hashtable<String, Object> attributes =
+        new Hashtable<String, Object>();
 
     /**
      * Constructor is used only by subclasses.
index 0663a70..11510f2 100644 (file)
@@ -159,7 +159,7 @@ class JSSESupport implements SSLSupport {
         if(log.isTraceEnabled())
             log.trace("Reading for try #" +i);
             try {
-                int x = in.read(b);
+                in.read(b);
             } catch(SSLException sslex) {
                 log.info("SSL Error getting client Certs",sslex);
                 throw sslex;
@@ -213,7 +213,7 @@ class JSSESupport implements SSLSupport {
             return null;
         StringBuffer buf=new StringBuffer("");
         for(int x=0; x<ssl_session.length; x++) {
-            String digit=Integer.toHexString((int)ssl_session[x]);
+            String digit=Integer.toHexString(ssl_session[x]);
             if (digit.length()<2) buf.append('0');
             if (digit.length()>2) digit=digit.substring(digit.length()-2);
             buf.append(digit);