Automated merge with main-silver
authorffjre@netbeans.org
Sat, 08 Aug 2009 02:56:02 +0400
changeset 932d6fcec6024c6
parent 931 b54957c3a3fe
parent 812 733e538823ff
child 933 90b133c9fb62
Automated merge with main-silver
     1.1 --- a/openide.util/src/org/openide/util/lookup/MetaInfServicesLookup.java	Thu Aug 06 02:56:03 2009 +0400
     1.2 +++ b/openide.util/src/org/openide/util/lookup/MetaInfServicesLookup.java	Sat Aug 08 02:56:02 2009 +0400
     1.3 @@ -60,6 +60,7 @@
     1.4  import java.util.logging.Level;
     1.5  import java.util.logging.Logger;
     1.6  import org.openide.util.Lookup;
     1.7 +import org.openide.util.RequestProcessor;
     1.8  
     1.9  /**
    1.10   * @author Jaroslav Tulach, Jesse Glick
    1.11 @@ -69,6 +70,7 @@
    1.12  final class MetaInfServicesLookup extends AbstractLookup {
    1.13  
    1.14      private static final Logger LOGGER = Logger.getLogger(MetaInfServicesLookup.class.getName());
    1.15 +    static final RequestProcessor RP = new RequestProcessor(MetaInfServicesLookup.class.getName(), 1);
    1.16      private static int knownInstancesCount;
    1.17      private static final List<Reference<Object>> knownInstances;
    1.18      static {
    1.19 @@ -111,27 +113,17 @@
    1.20      protected final void beforeLookup(Lookup.Template t) {
    1.21          Class c = t.getType();
    1.22  
    1.23 -        HashSet<AbstractLookup.R> listeners;
    1.24 -
    1.25          synchronized (this) {
    1.26              if (classes.put(c, "") == null) { // NOI18N
    1.27                  // Added new class, search for it.
    1.28                  LinkedHashSet<AbstractLookup.Pair<?>> arr = getPairsAsLHS();
    1.29                  search(c, arr);
    1.30 -
    1.31 -                // listeners are notified under while holding lock on class c, 
    1.32 -                // let say it is acceptable now
    1.33 -                listeners = setPairsAndCollectListeners(arr);
    1.34 +                setPairs(arr, RP);
    1.35              } else {
    1.36                  // ok, nothing needs to be done
    1.37                  return;
    1.38              }
    1.39          }
    1.40 -
    1.41 -        NotifyListeners notify = new NotifyListeners(listeners);
    1.42 -        if (notify.shallRun()) {
    1.43 -            notify.run();
    1.44 -        }
    1.45      }
    1.46  
    1.47      /** Finds all pairs and adds them to the collection.
     2.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/MetaInfServicesLookupTest.java	Thu Aug 06 02:56:03 2009 +0400
     2.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/MetaInfServicesLookupTest.java	Sat Aug 08 02:56:02 2009 +0400
     2.3 @@ -62,8 +62,7 @@
     2.4  import java.util.Set;
     2.5  import java.util.TreeSet;
     2.6  import java.util.WeakHashMap;
     2.7 -import java.util.concurrent.Executors;
     2.8 -import java.util.concurrent.TimeUnit;
     2.9 +import java.util.concurrent.atomic.AtomicBoolean;
    2.10  import java.util.jar.JarEntry;
    2.11  import java.util.jar.JarOutputStream;
    2.12  import java.util.logging.Level;
    2.13 @@ -389,39 +388,26 @@
    2.14          assertGC("Class can be garbage collected", ref);
    2.15      }
    2.16  
    2.17 -    public void testListenersAreNotifiedWithoutHoldingALockIssue36035() throws Exception {
    2.18 -        final Lookup l = getTestedLookup(c2);
    2.19 -        final Class xface = c1.loadClass("org.foo.Interface");
    2.20 -        final Lookup.Result res = l.lookup(new Lookup.Template(Object.class));
    2.21 -
    2.22 -        class L implements LookupListener, Runnable {
    2.23 -            private Thread toInterrupt;
    2.24 -
    2.25 -            public void run() {
    2.26 -                assertNotNull("Possible to query lookup", l.lookup(xface));
    2.27 -                assertEquals("and there are two items", 2, res.allInstances().size());
    2.28 -                toInterrupt.interrupt();
    2.29 -            }
    2.30 -
    2.31 -            public synchronized void resultChanged(LookupEvent ev) {
    2.32 -                toInterrupt = Thread.currentThread();
    2.33 -                Executors.newSingleThreadScheduledExecutor().schedule(this, 0, TimeUnit.MICROSECONDS);
    2.34 -                try {
    2.35 -                    wait(3000);
    2.36 -                    fail("Should be interrupted - means it was not possible to finish query in run() method");
    2.37 -                } catch (InterruptedException ex) {
    2.38 -                    // this is what we want
    2.39 +    public void testSuperTypes() throws Exception {
    2.40 +        doTestSuperTypes(createLookup(c2));
    2.41 +        doTestSuperTypes(new ProxyLookup(createLookup(c2)));
    2.42 +    }
    2.43 +    private void doTestSuperTypes(Lookup l) throws Exception {
    2.44 +        final Class<?> xface = c1.loadClass("org.foo.Interface");
    2.45 +        final Lookup.Result<Object> res = l.lookupResult(Object.class);
    2.46 +        assertEquals("Nothing yet", 0, res.allInstances().size());
    2.47 +        final AtomicBoolean event = new AtomicBoolean();
    2.48 +        final Thread here = Thread.currentThread();
    2.49 +        res.addLookupListener(new LookupListener() {
    2.50 +            public void resultChanged(LookupEvent ev) {
    2.51 +                if (Thread.currentThread() == here) {
    2.52 +                    event.set(true);
    2.53                  }
    2.54              }
    2.55 -        }
    2.56 -        L listener = new L();
    2.57 -
    2.58 -        res.addLookupListener(listener);
    2.59 -        assertEquals("Nothing yet", 0, res.allInstances().size());
    2.60 -
    2.61 +        });
    2.62          assertNotNull("Interface found", l.lookup(xface));
    2.63 -        assertNotNull("Listener notified", listener.toInterrupt);
    2.64 -
    2.65 +        assertFalse(event.get());
    2.66 +        MetaInfServicesLookup.RP.post(new Runnable() {public void run() {}}).waitFinished();
    2.67          assertEquals("Now two", 2, res.allInstances().size());
    2.68      }
    2.69      
     3.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/NamedServicesLookupTest.java	Thu Aug 06 02:56:03 2009 +0400
     3.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/NamedServicesLookupTest.java	Sat Aug 08 02:56:02 2009 +0400
     3.3 @@ -74,25 +74,12 @@
     3.4      // anyway, but the infrastructure to generate the JAR files is useful
     3.5      //
     3.6      
     3.7 -    public void testLoaderSkew() throws Exception {
     3.8 -    }
     3.9 -
    3.10 -    public void testStability() throws Exception {
    3.11 -    }
    3.12 -
    3.13 -    public void testMaskingOfResources() throws Exception {
    3.14 -    }
    3.15 -
    3.16 -    public void testOrdering() throws Exception {
    3.17 -    }
    3.18 -
    3.19 -    public void testNoCallToGetResourceForObjectIssue65124() throws Exception {
    3.20 -    }
    3.21 -
    3.22 -    public void testListenersAreNotifiedWithoutHoldingALockIssue36035() throws Exception {
    3.23 -    }
    3.24 -    
    3.25 -    public void testWrongOrderAsInIssue100320() throws Exception {
    3.26 -    }    
    3.27 +    public @Override void testLoaderSkew() {}
    3.28 +    public @Override void testStability() throws Exception {}
    3.29 +    public @Override void testMaskingOfResources() throws Exception {}
    3.30 +    public @Override void testOrdering() throws Exception {}
    3.31 +    public @Override void testNoCallToGetResourceForObjectIssue65124() throws Exception {}
    3.32 +    public @Override void testSuperTypes() throws Exception {}
    3.33 +    public @Override void testWrongOrderAsInIssue100320() throws Exception {}
    3.34      
    3.35  }