commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nico...@apache.org
Subject svn commit: r893112 - in /commons/sandbox/monitoring/trunk/core/src: main/java/org/apache/commons/monitoring/repositories/HOMTRepositoryDecorator.java test/java/org/apache/commons/monitoring/repositories/HistoryOfMyThreadTest.java
Date Tue, 22 Dec 2009 08:22:49 GMT
Author: nicolas
Date: Tue Dec 22 08:22:46 2009
New Revision: 893112

URL: http://svn.apache.org/viewvc?rev=893112&view=rev
Log:
HOMT decorator test improvement

Modified:
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/HOMTRepositoryDecorator.java
    commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/repositories/HistoryOfMyThreadTest.java

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/HOMTRepositoryDecorator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/HOMTRepositoryDecorator.java?rev=893112&r1=893111&r2=893112&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/HOMTRepositoryDecorator.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/HOMTRepositoryDecorator.java
Tue Dec 22 08:22:46 2009
@@ -25,10 +25,8 @@
 import org.apache.commons.monitoring.StopWatch;
 import org.apache.commons.monitoring.stopwatches.HistoryOfMyThread;
 
-
 /**
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
- *
  */
 public class HOMTRepositoryDecorator
     extends RepositoryDecorator
@@ -70,7 +68,7 @@
 
     public HistoryOfMyThread getThreadHistory()
     {
-        HistoryOfMyThread myThread = history.get();
+        HistoryOfMyThread myThread = getCurrentThreadHistory();
         if ( myThread == null )
         {
             myThread = new HistoryOfMyThread( listeners );
@@ -79,6 +77,15 @@
         return myThread;
     }
 
+    public HistoryOfMyThread getCurrentThreadHistory()
+    {
+        return history.get();
+    }
+
+    /**
+     * Cleanup the ThreadLocal {@link #history} when the active Thread history ends, so that
the Thread can go back to
+     * thread pool
+     */
     public void onHistoryEnd( HistoryOfMyThread myThread, long elapsedTime )
     {
         history.remove();

Modified: commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/repositories/HistoryOfMyThreadTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/repositories/HistoryOfMyThreadTest.java?rev=893112&r1=893111&r2=893112&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/repositories/HistoryOfMyThreadTest.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/test/java/org/apache/commons/monitoring/repositories/HistoryOfMyThreadTest.java
Tue Dec 22 08:22:46 2009
@@ -49,8 +49,11 @@
         repository.addListener( this );
 
         run( repository );
+        assertNull( repository.getCurrentThreadHistory() );
         run( repository );
+        assertNull( repository.getCurrentThreadHistory() );
         run( repository );
+        assertNull( repository.getCurrentThreadHistory() );
     }
 
     private void run( Repository repository )



Mime
View raw message