Re: [picocontainer-dev] bug on pico start

Paul Hammant <[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
Erik,

I've been thru the patch and manually applied the bits that were  
changed / new :

     public static class StartableClazz implements Startable {
         private MutablePicoContainer _pico;
         public void start() {
             List<SimpleTouchable> cps = _pico
                 .getComponents(SimpleTouchable.class);
             assertNotNull(cps);
         }
         public void stop() {
         }
     }

     public void testListComponentsOnStart() {
         DefaultPicoContainer dpc = new DefaultPicoContainer();
         dpc.addComponent(SimpleTouchable.class);
         StartableClazz cl = new StartableClazz();
         cl._pico = dpc;
         dpc.addComponent(cl);
         dpc.start();
     }

The test class is handed a ref to the container that is about to  
contain it.  No wonder it barfs with  
java.util.ConcurrentModificationException. Its a basic violation of  
Inversion of Control.

Better would be :

     public static class StartableClazz implements Startable {
         private SimpleTouchable simpleTouchable;
         public StartableClazz(SimpleTouchable st) {
             this. simpleTouchable = st;
         }
         public void start() {
             // do what you need with simpleTouchable here.
         }
         public void stop() {
         }
     }

You're mostly likely trying to shw us something from your own  
codebase, but using our (supid) test classes. Can you tell us more  
about your need ? :-)

- Paul

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.