directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nik...@apache.org
Subject svn commit: r383671 - /directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java
Date Mon, 06 Mar 2006 21:09:00 GMT
Author: niklas
Date: Mon Mar  6 13:08:57 2006
New Revision: 383671

URL: http://svn.apache.org/viewcvs?rev=383671&view=rev
Log:
Reverted back to the version before the first attempt for a fix for DIRMINA-169.

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java?rev=383671&r1=383670&r2=383671&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java
Mon Mar  6 13:08:57 2006
@@ -47,23 +47,13 @@
     {
     }
     
-    public void callInitIfNecessary( IoFilter filter )
+    public synchronized void callInitIfNecessary( IoFilter filter )
     {
-        boolean callInit = false;
-        
-        synchronized( this )
-        {
-            ReferenceCount count = ( ReferenceCount ) counts.get( filter );
-            if( count == null )
-            {
-                count = new ReferenceCount();
-                counts.put( filter, count );
-                callInit = true;
-            }
-        }
-        
-        if( callInit )
+        ReferenceCount count = ( ReferenceCount ) counts.get( filter );
+        if( count == null )
         {
+            count = new ReferenceCount();
+            counts.put( filter, count );
             try
             {
                 filter.init();
@@ -76,19 +66,16 @@
         }
     }
     
-    public void callOnPreAdd( IoFilterChain chain, String name, IoFilter filter, NextFilter
nextFilter )
+    public synchronized void callOnPreAdd( IoFilterChain chain, String name, IoFilter filter,
NextFilter nextFilter )
     {
-        synchronized( this )
+        ReferenceCount count = ( ReferenceCount ) counts.get( filter );
+        if( count == null )
         {
-            ReferenceCount count = ( ReferenceCount ) counts.get( filter );
-            if( count == null )
-            {
-                throw new IllegalStateException();
-            }
-            
-            count.increase();
+            throw new IllegalStateException();
         }
         
+        count.increase();
+
         try
         {
             filter.onPreAdd( chain, name, nextFilter );
@@ -101,20 +88,17 @@
         }
     }
 
-    public void callOnPreRemove( IoFilterChain chain, String name, IoFilter filter, NextFilter
nextFilter )
+    public synchronized void callOnPreRemove( IoFilterChain chain, String name, IoFilter
filter, NextFilter nextFilter )
     {
-        synchronized( this )
+        ReferenceCount count = ( ReferenceCount ) counts.get( filter );
+        if( count == null || count.get() == 0 )
         {
-            ReferenceCount count = ( ReferenceCount ) counts.get( filter );
-            if( count == null || count.get() == 0 )
-            {
-                return;
-            }
+            return;
         }
 
         try
         {
-            filter.onPreRemove( chain, name, nextFilter );
+            filter.onPreRemove( chain, name, nextFilter);
         }
         catch( Throwable t )
         {
@@ -124,15 +108,12 @@
         }
     }
     
-    public void callOnPostAdd( IoFilterChain chain, String name, IoFilter filter, NextFilter
nextFilter )
+    public synchronized void callOnPostAdd( IoFilterChain chain, String name, IoFilter filter,
NextFilter nextFilter )
     {
-        synchronized( this )
+        ReferenceCount count = ( ReferenceCount ) counts.get( filter );
+        if( count == null )
         {
-            ReferenceCount count = ( ReferenceCount ) counts.get( filter );
-            if( count == null )
-            {
-                throw new IllegalStateException();
-            }
+            throw new IllegalStateException();
         }
         
         try
@@ -142,7 +123,7 @@
         catch( Throwable t )
         {
             // Revert back the reference count.
-            decreaseCountSafely( filter );
+            count.decrease();
 
             throw new IoFilterLifeCycleException(
                     "onPostAdd(): " + name + ':' + filter + " in " +
@@ -150,15 +131,12 @@
         }
     }
 
-    public void callOnPostRemove( IoFilterChain chain, String name, IoFilter filter, NextFilter
nextFilter )
+    public synchronized void callOnPostRemove( IoFilterChain chain, String name, IoFilter
filter, NextFilter nextFilter )
     {
-        synchronized( this )
+        ReferenceCount count = ( ReferenceCount ) counts.get( filter );
+        if( count == null || count.get() == 0 )
         {
-            ReferenceCount count = ( ReferenceCount ) counts.get( filter );
-            if( count == null || count.get() == 0 )
-            {
-                return;
-            }
+            return;
         }
 
         try
@@ -173,42 +151,21 @@
         }
         finally
         {
-            decreaseCountSafely( filter );
+            count.decrease();
         }
     }
 
-    private synchronized void decreaseCountSafely( IoFilter filter )
+    public synchronized void callDestroyIfNecessary( IoFilter filter )
     {
         ReferenceCount count = ( ReferenceCount ) counts.get( filter );
         if( count == null )
         {
-            throw new IllegalStateException();
+            return;
         }
         
-        count.decrease();
-    }
-
-    public void callDestroyIfNecessary( IoFilter filter )
-    {
-        boolean callDestroy = false;
-        
-        synchronized( this )
-        {
-            ReferenceCount count = ( ReferenceCount ) counts.get( filter );
-            if( count == null )
-            {
-                return;
-            }
-            
-            if( count.get() == 0 )
-            {
-                counts.remove( filter );
-                callDestroy = true;
-            }
-        }
-
-        if( callDestroy )
+        if( count.get() == 0 )
         {
+            counts.remove( filter );
             try
             {
                 filter.destroy();



Mime
View raw message