DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22932>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22932 StackOverflow while service A of ServiceSelector references service B of same ServiceSelector Summary: StackOverflow while service A of ServiceSelector references service B of same ServiceSelector Product: Avalon Version: unspecified Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Excalibur AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Hi guys, I've found that ExcaliburComponentSelector causes StackOverflowError when some of the services he is holding tries to select another service he is holding. But ONLY if the second service implements ThreadSafe! I'll give you some sample code: ----------------------------------------------------------------- A) Client: package component; import java.io.ByteArrayInputStream; import org.apache.avalon.excalibur.component.ExcaliburComponentManagerCreator; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.ServiceSelector; public class TestServiceSelector { public static final String ROLE_CONFIG = "<role-list>" + "\n <role shorthand='selector' name='component.Service' default-class='org.apache.avalon.excalibur.component. ExcaliburComponentSelector'>" + "\n <hint shorthand='i1' class='component.impl.Service1'/>" + "\n <hint shorthand='i2' class='component.impl.Service2'/>" + "\n </role>" + "\n</role-list>"; public static final String COMPONENT_CONFIG = "<test>" + "\n <selector>" + "\n <i1 name='select1'/>" + "\n <i2 name='select2'/>" + "\n </selector>" + "\n</test>"; public static final String LOG_CONFIG = "<logkit>" + "\n <factories>" + "\n <factory type='sysout' class='org.apache.avalon.excalibur. logger.factory.StreamTargetFactory'/>" + "\n </factories>" + "\n <targets>" + "\n <sysout id='root'>" + "\n <stream>System.out</stream>" + "\n <format type='pattern'>%6.6{priority} %19.19{time: yyyy-MM-dd HH:mm:ss}: %{message}\n%{throwable}</format>" + "\n </sysout>" + "\n </targets>" + "\n <categories>" + "\n <category name='system' log-level='DEBUG'>" + "\n <log-target id-ref='root'/>" + "\n </category>" + "\n </categories>" + "\n</logkit>"; public TestServiceSelector() { super(); } public static final void main(String[] args) { System.out.println("ROLE:\n" + ROLE_CONFIG); System.out.println("COMPONENT:\n" + COMPONENT_CONFIG); ExcaliburComponentManagerCreator creator = null; try { creator = new ExcaliburComponentManagerCreator( null, new ByteArrayInputStream(LOG_CONFIG.getBytes()), new ByteArrayInputStream(ROLE_CONFIG.getBytes()), new ByteArrayInputStream(COMPONENT_CONFIG.getBytes()), null); ServiceManager manager = creator.getServiceManager(); ServiceSelector selector = (ServiceSelector) manager. lookup("component.Service"); Service select1 = (Service) selector.select("select1"); System.out.println("Got instance of: " + select1); selector.release(select1); Service select2 = (Service) selector.select("select2"); System.out.println("Got instance of: " + select2); selector.release(select2); manager.release(selector); } catch (Throwable e) { e.printStackTrace(); } finally { creator.dispose(); } } } ----------------------------------------------------------------- B) Service interface (as simple as possible): package component; public interface Service { public static final String ROLE = Service.class.getName(); } ----------------------------------------------------------------- C) First implementation of Service: package component.impl; import org.apache.avalon.framework.thread.ThreadSafe; import component.Service; public class Service1 implements Service, ThreadSafe { public Service1() { super(); } public String toString() { return this.getClass().getName(); } } ----------------------------------------------------------------- D) Second implementation of Service: package component.impl; import component.Service; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.ServiceSelector; import org.apache.avalon.framework.service.Serviceable; import org.apache.avalon.framework.thread.ThreadSafe; public class Service2 implements Service, Serviceable, ThreadSafe { public Service2() { super(); } public String toString() { return this.getClass().getName(); } public void service(ServiceManager serviceManager) throws ServiceException { ServiceSelector selector = (ServiceSelector) serviceManager. lookup(Service.ROLE); System.out.println("Within service method got service selector: " + selector.getClass()); Service service = (Service) selector.select("select1"); System.out.println("Within service method got service: " + service. getClass()); } } ----------------------------------------------------------------- Running the client results in nearly endless logging output and the following stack trace after about 10 seconds of 100% CPU usage: > Logging Error: Unknown error writing event.java.lang.StackOverflowError > java.lang.NullPointerException > at component.TestServiceSelector.main(TestServiceSelector.java:73) BUT when class Service2 (Code D)) does NOT implement ThreadSafe, everything works well! I'm working with following versions of Avalon/Excalibur JAR files: - avalon-framework-4.1.4.jar - excalibur-component-1.1.jar - excalibur-i18n-1.0.jar - excalibur-instrument-1.0.jar - excalibur-logger-1.0.1.jar - excalibur-pool-1.2.jar - logkit-1.2.jar - commons-collections.jar - commons-lang-2.0.jar Greetings Christian --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]