From: markt Date: Sun, 27 Apr 2008 16:14:06 +0000 (+0000) Subject: Code clean up o.a.t.util.net. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4d74271e65850b5b801c17229a118fd043839dee;p=tomcat7.0 Code clean up o.a.t.util.net. Generics and unused code. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@651976 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/net/NioBlockingSelector.java b/java/org/apache/tomcat/util/net/NioBlockingSelector.java index ce2f6c907..27117e3f4 100644 --- a/java/org/apache/tomcat/util/net/NioBlockingSelector.java +++ b/java/org/apache/tomcat/util/net/NioBlockingSelector.java @@ -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 events = + new ConcurrentLinkedQueue(); 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 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(); diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 55eee32e4..80d09365f 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -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 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(); diff --git a/java/org/apache/tomcat/util/net/NioSelectorPool.java b/java/org/apache/tomcat/util/net/NioSelectorPool.java index aa61ffd96..edb55985d 100644 --- a/java/org/apache/tomcat/util/net/NioSelectorPool.java +++ b/java/org/apache/tomcat/util/net/NioSelectorPool.java @@ -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 selectors = new ConcurrentLinkedQueue(); + protected ConcurrentLinkedQueue selectors = + new ConcurrentLinkedQueue(); protected Selector getSharedSelector() throws IOException { if (SHARED && SHARED_SELECTOR == null) { @@ -293,7 +294,7 @@ public class NioSelectorPool { return sharedSelectorTimeout; } - public ConcurrentLinkedQueue getSelectors() { + public ConcurrentLinkedQueue getSelectors() { return selectors; } diff --git a/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java b/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java index c356b5bc9..0b3379388 100644 --- a/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java +++ b/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java @@ -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 workerThreads = + new Stack(); private int curThreads = 0; private int maxThreads = 20; /* All processors which have been created. */ - private Vector created = new Vector(); + private Vector created = + new Vector(); 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()); diff --git a/java/org/apache/tomcat/util/net/SSLImplementation.java b/java/org/apache/tomcat/util/net/SSLImplementation.java index 262d1e74a..6cc6fa6a9 100644 --- a/java/org/apache/tomcat/util/net/SSLImplementation.java +++ b/java/org/apache/tomcat/util/net/SSLImplementation.java @@ -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()) diff --git a/java/org/apache/tomcat/util/net/ServerSocketFactory.java b/java/org/apache/tomcat/util/net/ServerSocketFactory.java index 00392a58e..7cc03bed9 100644 --- a/java/org/apache/tomcat/util/net/ServerSocketFactory.java +++ b/java/org/apache/tomcat/util/net/ServerSocketFactory.java @@ -55,7 +55,8 @@ public abstract class ServerSocketFactory implements Cloneable { // private static ServerSocketFactory theFactory; - protected Hashtable attributes=new Hashtable(); + protected Hashtable attributes = + new Hashtable(); /** * Constructor is used only by subclasses. diff --git a/java/org/apache/tomcat/util/net/jsse/JSSESupport.java b/java/org/apache/tomcat/util/net/jsse/JSSESupport.java index 0663a70cb..11510f2a9 100644 --- a/java/org/apache/tomcat/util/net/jsse/JSSESupport.java +++ b/java/org/apache/tomcat/util/net/jsse/JSSESupport.java @@ -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; x2) digit=digit.substring(digit.length()-2); buf.append(digit);