This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b7442d  Remove bad looking fields access
7b7442d is described below

commit 7b7442d87e08f0bd1134e7872e7cd15bf3509b64
Author: remm <r...@apache.org>
AuthorDate: Wed May 15 19:51:48 2019 +0200

    Remove bad looking fields access
    
    getSelectorPool public -> protected, since it's only used in the socket
    wrapper. Move NIO socket wrapper init to setSocketOptions since the
    poller is now known.
---
 java/org/apache/tomcat/util/net/Nio2Endpoint.java |  7 ++++-
 java/org/apache/tomcat/util/net/NioEndpoint.java  | 35 ++++++++++++++---------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index ee6a9a1..613f057 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -349,6 +349,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel,AsynchronousS
     }
 
 
+    protected SynchronizedStack<Nio2Channel> getNioChannels() {
+        return nioChannels;
+    }
+
+
     @Override
     protected NetworkChannel getServerSocket() {
         return serverSock;
@@ -555,7 +560,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel,AsynchronousS
 
         public Nio2SocketWrapper(Nio2Channel channel, final Nio2Endpoint 
endpoint) {
             super(channel, endpoint);
-            nioChannels = endpoint.nioChannels;
+            nioChannels = endpoint.getNioChannels();
             socketBufferHandler = channel.getBufHandler();
 
             this.readCompletionHandler = new CompletionHandler<Integer, 
ByteBuffer>() {
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index f31a508..5633c92 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -358,11 +358,21 @@ public class NioEndpoint extends 
AbstractJsseEndpoint<NioChannel,SocketChannel>
 
     // ------------------------------------------------------ Protected Methods
 
-    public NioSelectorPool getSelectorPool() {
+    protected NioSelectorPool getSelectorPool() {
         return selectorPool;
     }
 
 
+    protected SynchronizedStack<NioChannel> getNioChannels() {
+        return nioChannels;
+    }
+
+
+    protected Poller getPoller() {
+        return poller;
+    }
+
+
     protected CountDownLatch getStopLatch() {
         return stopLatch;
     }
@@ -407,7 +417,13 @@ public class NioEndpoint extends 
AbstractJsseEndpoint<NioChannel,SocketChannel>
                 channel.setIOChannel(socket);
                 channel.reset();
             }
-            poller.register(channel);
+            NioSocketWrapper socketWrapper = new NioSocketWrapper(channel, 
this);
+            channel.setSocketWrapper(socketWrapper);
+            socketWrapper.setReadTimeout(getConnectionTimeout());
+            socketWrapper.setWriteTimeout(getConnectionTimeout());
+            
socketWrapper.setKeepAliveLeft(NioEndpoint.this.getMaxKeepAliveRequests());
+            socketWrapper.setSecure(isSSLEnabled());
+            poller.register(channel, socketWrapper);
         } catch (Throwable t) {
             ExceptionUtils.handleThrowable(t);
             try {
@@ -636,14 +652,7 @@ public class NioEndpoint extends 
AbstractJsseEndpoint<NioChannel,SocketChannel>
          *
          * @param socket    The newly created socket
          */
-        public void register(final NioChannel socket) {
-            NioSocketWrapper socketWrapper = new NioSocketWrapper(socket, 
NioEndpoint.this);
-            socket.setSocketWrapper(socketWrapper);
-            socketWrapper.setPoller(this);
-            socketWrapper.setReadTimeout(getConnectionTimeout());
-            socketWrapper.setWriteTimeout(getConnectionTimeout());
-            
socketWrapper.setKeepAliveLeft(NioEndpoint.this.getMaxKeepAliveRequests());
-            socketWrapper.setSecure(isSSLEnabled());
+        public void register(final NioChannel socket, final NioSocketWrapper 
socketWrapper) {
             socketWrapper.interestOps(SelectionKey.OP_READ);//this is what 
OP_REGISTER turns into.
             PollerEvent r = null;
             if (eventCache != null) {
@@ -1016,8 +1025,8 @@ public class NioEndpoint extends 
AbstractJsseEndpoint<NioChannel,SocketChannel>
 
         private final NioSelectorPool pool;
         private final SynchronizedStack<NioChannel> nioChannels;
+        private final Poller poller;
 
-        private Poller poller = null;
         private int interestOps = 0;
         private CountDownLatch readLatch = null;
         private CountDownLatch writeLatch = null;
@@ -1028,12 +1037,12 @@ public class NioEndpoint extends 
AbstractJsseEndpoint<NioChannel,SocketChannel>
         public NioSocketWrapper(NioChannel channel, NioEndpoint endpoint) {
             super(channel, endpoint);
             pool = endpoint.getSelectorPool();
+            nioChannels = endpoint.getNioChannels();
+            poller = endpoint.getPoller();
             socketBufferHandler = channel.getBufHandler();
-            nioChannels = endpoint.nioChannels;
         }
 
         public Poller getPoller() { return poller; }
-        public void setPoller(Poller poller) { this.poller = poller; }
         public int interestOps() { return interestOps; }
         public int interestOps(int ops) { this.interestOps  = ops; return ops; 
}
         public CountDownLatch getReadLatch() { return readLatch; }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to