onami-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1430258 - /incubator/onami/trunk/lifecycle/src/main/java/org/apache/onami/lifecycle/Disposer.java
Date Tue, 08 Jan 2013 12:45:06 GMT
Author: simonetripodi
Date: Tue Jan  8 12:45:06 2013
New Revision: 1430258

URL: http://svn.apache.org/viewvc?rev=1430258&view=rev
Log:
[ONAMI-44] Disposables should be processed in reverse order to their registration - patch
submitted by Mikhail Mazursky

Modified:
    incubator/onami/trunk/lifecycle/src/main/java/org/apache/onami/lifecycle/Disposer.java

Modified: incubator/onami/trunk/lifecycle/src/main/java/org/apache/onami/lifecycle/Disposer.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/lifecycle/src/main/java/org/apache/onami/lifecycle/Disposer.java?rev=1430258&r1=1430257&r2=1430258&view=diff
==============================================================================
--- incubator/onami/trunk/lifecycle/src/main/java/org/apache/onami/lifecycle/Disposer.java
(original)
+++ incubator/onami/trunk/lifecycle/src/main/java/org/apache/onami/lifecycle/Disposer.java
Tue Jan  8 12:45:06 2013
@@ -21,8 +21,7 @@ package org.apache.onami.lifecycle;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.Stack;
 
 /**
  * A Disposer is a mini-container that releases resources
@@ -34,7 +33,7 @@ public final class Disposer
     /**
      * List of elements have to be disposed.
      */
-    private final List<Disposable> disposables = new LinkedList<Disposable>();
+    private final Stack<Disposable> disposables = new Stack<Disposable>();
 
     /**
      * Register an injectee and its related method to release resources.
@@ -44,7 +43,7 @@ public final class Disposer
      */
     <I> void register( Method disposeMethod, I injectee )
     {
-        disposables.add( new Disposable( disposeMethod, injectee ) );
+        disposables.push( new Disposable( disposeMethod, injectee ) );
     }
 
     /**
@@ -68,10 +67,9 @@ public final class Disposer
         {
             disposeHandler = new NoOpDisposeHandler();
         }
-
-        for ( Disposable disposable : disposables )
+        while ( !disposables.isEmpty() )
         {
-            disposable.dispose( disposeHandler );
+            disposables.pop().dispose( disposeHandler );
         }
     }
 



Mime
View raw message