ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <co...@cortexebusiness.com.au>
Subject Re: Integrating own BuildLogger
Date Thu, 02 Sep 2004 07:53:48 GMT
Robert Virkus wrote:
> Hi everyone,
> 
> I am trying to substitute the original build logger in my task with Ant 1.6.1. 
> I have written a wrapper-class which just forwards the events to the original 
> build logger, which works fine as long as I don't try to modify the build 
> events. When I change a build event, however, Ant is stopping the execution 
> with the message "BUILD FAILED
> Listener attempted to access System.out - infinite loop terminated"
> 

This is an interesting problem. Nothing you're doing sounds like a 
problem but somewhere something in your message handling is attempting 
to output a message. i.e. before one message has been delivered to the 
listeners something is attempting to send another. The message above 
gives the most common cause but it is in fact not the only possibility 
as I found when trying to sort out your problem.

Since your logger is loaded by an AntClassLoader it is susceptible to 
any logging done by that classloader. In fact I reproduced your problem 
and here is the stack trace

Listener attempted to access System.out - infinite loop terminated
         at 
org.apache.tools.ant.Project.fireMessageLoggedEvent(Project.java:1991)
         at 
org.apache.tools.ant.Project.fireMessageLogged(Project.java:2020)
         at org.apache.tools.ant.Project.log(Project.java:387)
         at org.apache.tools.ant.AntClassLoader.log(AntClassLoader.java:394)
         at 
org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:974)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:236)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:303)
         at PolishLogger.messageLogged(PolishLogger.java:32)

So the deferred classloading that is triggered in your messageLogged 
method causes the AntClassLoader to log a message (a class being loaded).

The workaround is to trigger the class loading earlier. I changed the 
PolishLogger constructor as follows:

     public PolishLogger(BuildLogger realLogger, Project project)
     {
         this.logger = realLogger;
         BuildEvent event = new BuildEvent(project);
         String s = new String();
         StringBuffer sb = new StringBuffer();
     }


Note that it is not easy to ensure you have got all the classes loaded. 
A better solution might be to not load the PolishLogger through the 
AntClassLoader.

Conor



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message