]> WPIA git - gigi.git/blobdiff - lib/jetty/org/eclipse/jetty/io/AbstractConnection.java
updating jetty to jetty-9.2.16.v2016040
[gigi.git] / lib / jetty / org / eclipse / jetty / io / AbstractConnection.java
index 7f8e9f81ca023bc595d0656838ebf35513756c2f..28c7082f6135f5f16595649b0550149b06c1ff5a 100644 (file)
@@ -1,6 +1,6 @@
 //
 //  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
+//  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
 //  ------------------------------------------------------------------------
 //  All rights reserved. This program and the accompanying materials
 //  are made available under the terms of the Eclipse Public License v1.0
@@ -40,7 +40,7 @@ import org.eclipse.jetty.util.thread.NonBlockingThread;
 public abstract class AbstractConnection implements Connection
 {
     private static final Logger LOG = Log.getLogger(AbstractConnection.class);
-    
+
     public static final boolean EXECUTE_ONFILLABLE=true;
 
     private final List<Listener> listeners = new CopyOnWriteArrayList<>();
@@ -56,7 +56,7 @@ public abstract class AbstractConnection implements Connection
     {
         this(endp,executor,EXECUTE_ONFILLABLE);
     }
-    
+
     protected AbstractConnection(EndPoint endp, Executor executor, final boolean executeOnfillable)
     {
         if (executor == null)
@@ -88,7 +88,7 @@ public abstract class AbstractConnection implements Connection
     {
         return _executor;
     }
-    
+
     protected void failedCallback(final Callback callback, final Throwable x)
     {
         if (NonBlockingThread.isNonBlockingThread())
@@ -115,7 +115,7 @@ public abstract class AbstractConnection implements Connection
             callback.failed(x);
         }
     }
-    
+
     /**
      * <p>Utility method to be called to register read interest.</p>
      * <p>After a call to this method, {@link #onFillable()} or {@link #onFillInterestedFailed(Throwable)}
@@ -124,8 +124,9 @@ public abstract class AbstractConnection implements Connection
      */
     public void fillInterested()
     {
-        LOG.debug("fillInterested {}",this);           
-        
+        if (LOG.isDebugEnabled())
+            LOG.debug("fillInterested {}",this);
+
         while(true)
         {
             State state=_state.get();
@@ -133,10 +134,11 @@ public abstract class AbstractConnection implements Connection
                 break;
         }
     }
-    
+
     public void fillInterested(Callback callback)
     {
-        LOG.debug("fillInterested {}",this);
+        if (LOG.isDebugEnabled())
+            LOG.debug("fillInterested {}",this);
 
         while(true)
         {
@@ -149,7 +151,7 @@ public abstract class AbstractConnection implements Connection
                 break;
         }
     }
-    
+
     /**
      * <p>Callback method invoked when the endpoint is ready to be read.</p>
      * @see #fillInterested()
@@ -162,7 +164,8 @@ public abstract class AbstractConnection implements Connection
      */
     protected void onFillInterestedFailed(Throwable cause)
     {
-        LOG.debug("{} onFillInterestedFailed {}", this, cause);
+        if (LOG.isDebugEnabled())
+            LOG.debug("{} onFillInterestedFailed {}", this, cause);
         if (_endPoint.isOpen())
         {
             boolean close = true;
@@ -178,7 +181,7 @@ public abstract class AbstractConnection implements Connection
         }
 
         if (_endPoint.isOpen())
-            fillInterested();        
+            fillInterested();
     }
 
     /**
@@ -193,7 +196,8 @@ public abstract class AbstractConnection implements Connection
     @Override
     public void onOpen()
     {
-        LOG.debug("onOpen {}", this);
+        if (LOG.isDebugEnabled())
+            LOG.debug("onOpen {}", this);
 
         for (Listener listener : listeners)
             listener.onOpened(this);
@@ -202,7 +206,8 @@ public abstract class AbstractConnection implements Connection
     @Override
     public void onClose()
     {
-        LOG.debug("onClose {}",this);
+        if (LOG.isDebugEnabled())
+            LOG.debug("onClose {}",this);
 
         for (Listener listener : listeners)
             listener.onClosed(this);
@@ -253,23 +258,28 @@ public abstract class AbstractConnection implements Connection
     @Override
     public String toString()
     {
-        return String.format("%s@%x{%s}", getClass().getSimpleName(), hashCode(), _state.get());
+        return String.format("%s@%x[%s,%s]",
+                getClass().getSimpleName(),
+                hashCode(),
+                _state.get(),
+                _endPoint);
     }
-    
+
     public boolean next(State state, State next)
     {
         if (next==null)
             return true;
         if(_state.compareAndSet(state,next))
         {
-            LOG.debug("{}-->{} {}",state,next,this);
+            if (LOG.isDebugEnabled())
+                LOG.debug("{}-->{} {}",state,next,this);
             if (next!=state)
                 next.onEnter(AbstractConnection.this);
             return true;
         }
         return false;
     }
-    
+
     private static final class IdleState extends State
     {
         private IdleState()
@@ -402,11 +412,11 @@ public abstract class AbstractConnection implements Connection
         {
             return _name;
         }
-        
+
         void onEnter(AbstractConnection connection)
         {
         }
-        
+
         State fillInterested()
         {
             throw new IllegalStateException(this.toString());
@@ -421,28 +431,28 @@ public abstract class AbstractConnection implements Connection
         {
             throw new IllegalStateException(this.toString());
         }
-        
+
         State onFailed()
         {
             throw new IllegalStateException(this.toString());
         }
     }
-    
+
 
     public static final State IDLE=new IdleState();
-    
+
     public static final State FILL_INTERESTED=new FillInterestedState();
-    
+
     public static final State FILLING=new FillingState();
-    
+
     public static final State REFILLING=new RefillingState();
 
     public static final State FILLING_FILL_INTERESTED=new FillingFillInterestedState("FILLING_FILL_INTERESTED");
-    
+
     public class NestedState extends State
     {
         private final State _nested;
-        
+
         NestedState(State nested)
         {
             super("NESTED("+nested+")");
@@ -465,19 +475,19 @@ public abstract class AbstractConnection implements Connection
         {
             return new NestedState(_nested.onFillable());
         }
-        
+
         @Override
         State onFilled()
         {
             return new NestedState(_nested.onFilled());
         }
     }
-    
-    
+
+
     public class FillingInterestedCallback extends NestedState
     {
         private final Callback _callback;
-        
+
         FillingInterestedCallback(Callback callback,State nested)
         {
             super("FILLING_INTERESTED_CALLBACK",nested==FILLING?REFILLING:nested);
@@ -517,13 +527,13 @@ public abstract class AbstractConnection implements Connection
                             break;
                     }
                     _callback.failed(x);
-                }  
+                }
             };
-            
+
             connection.getEndPoint().fillInterested(callback);
         }
     }
-    
+
     private final Runnable _runOnFillable = new Runnable()
     {
         @Override
@@ -544,10 +554,10 @@ public abstract class AbstractConnection implements Connection
             }
         }
     };
-    
-    
+
+
     private class ReadCallback implements Callback
-    {   
+    {
         @Override
         public void succeeded()
         {
@@ -577,7 +587,7 @@ public abstract class AbstractConnection implements Connection
                 }
             });
         }
-        
+
         @Override
         public String toString()
         {