[jboss-cvs] JBossAS SVN: r93279 - projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/jbcl114.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 8 11:28:31 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-09-08 11:28:31 -0400 (Tue, 08 Sep 2009)
New Revision: 93279

Modified:
   projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/jbcl114/BlockingClassLoaderDomain.java
Log:
This javadoc works just as well, you know.

Modified: projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/jbcl114/BlockingClassLoaderDomain.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/jbcl114/BlockingClassLoaderDomain.java	2009-09-08 15:12:24 UTC (rev 93278)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/jbcl114/BlockingClassLoaderDomain.java	2009-09-08 15:28:31 UTC (rev 93279)
@@ -27,26 +27,14 @@
 import org.jboss.classloader.spi.base.BaseClassLoader;
 
 /**
- * This classloader domain really does nothing useful.  Its purpose is to avoid lock contention, but ironically, it
- * uses a condition variable instead which has the same effect: serial access.  So it gets rid of the apparent lock
- * contention but suffers from the exact same contention problem.  In addition, it does a bunch of other silly stuff as
- * well.  On the upside, Carlo is implicitly volunteering to maintain this mess for the next 7 years!  Thanks Carlo!
+ * Don't panic!  This scary, bizarre code is ONLY FOR TESTING!
  *
  * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
  * @version $Revision: $
  */
 public class BlockingClassLoaderDomain extends ClassLoaderDomain
 {
-
-   /**
-    * This field is protected by {@code this}.  However, that doesn't stop us from accessing it without any sort
-    * of protection down below!  Bet that's gonna blow up in somebody's face sometime.
-    */
    private boolean block = true;
-   /**
-    * We use this lock, which we lock one time and never unlock, to ensure that only one thread ever accesses this
-    * object.  Why don't we keep a Thread reference directly?  Your guess is as good as mine.
-    */
    private ReentrantLock lock = new ReentrantLock();
    
    protected BlockingClassLoaderDomain(String name)
@@ -57,33 +45,16 @@
    @Override
    protected Class<?> loadClass(BaseClassLoader classLoader, String name, boolean allExports) throws ClassNotFoundException
    {
-      /*
-       * Block waiting for this to be unblocked.  See, it doesn't count as lock contention because we use a condition
-       * variable.  Clever, eh?  Sadly, it still means that access is serial.
-       */
       try
       {
          waitForIt();
       }
       catch(InterruptedException e)
       {
-         /*
-          * Handle interruption incorrectly.  First, we rethrow another exception without resetting the interrupt status
-          * which ensures that the cancel semantics of the current thread will get screwed up.  Then we nest the
-          * interrupted exception just to make 100% sure that someone can get shot in the foot later.
-          */
          throw new ClassNotFoundException("interrupted", e);
       }
-      /*
-       * Use the above "technique" to ensure that the first thread which calls this method is the only one allowed to
-       * call henceforth.  What happens when you hit the maximum number of repeated lock invocations?  Who knows, but I
-       * bet it's going to be AWESOME.
-       */
       // there can be only 1
       boolean locked = lock.tryLock();
-      /*
-       * It's a good thing we do this check *after* waiting around.
-       */
       if(!locked)
          throw new IllegalStateException("only one thread is allowed to use this class loader domain");
       return super.loadClass(classLoader, name, allExports);
@@ -91,9 +62,6 @@
    
    public void unblock()
    {
-      /*
-       * Be sure to notify all waiters, even though only one will be able to make progress.
-       */
       synchronized (this)
       {
          block = false;
@@ -103,10 +71,6 @@
    
    private void waitForIt() throws InterruptedException
    {
-      /*
-       * Double-checked locking.  Guess we didn't get the memo about that from 5 years ago.  But it's OK as the rest
-       * of this class is kinda f--ked anyway.
-       */
       if(!block) return;
       synchronized (this)
       {




More information about the jboss-cvs-commits mailing list