You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Peter Reilly <pe...@corvil.com> on 2004/02/11 13:04:23 UTC

Re: Telnet task to MS Telnet server

Lyndon Samson wrote:

>Further to my previous post
>
>I've started writting a logger to do regexp's on its messages.
>
>I'm going to use properties for the patterns/substitution values,
>however I'm getting a wierd exception.
>
>        public void messageLogged(BuildEvent event) {
>                this.out.println(event.getMessage());
>                Project p = event.getProject();
>                try { 
>                        String propVal = "<unset>";
>                        propVal = p.getProperty("src");
>                        this.out.println("PROP:"+propVal);
>                } catch ( Exception e ) {
>                        this.err.println("(ERR)"+e.getMessage());
>                }
>        }
>
>Results in the following output
>
>Buildfile: build.xml
>Adding reference: ant.PropertyHelper
>(ERR)Listener attempted to access System.out - infinite loop terminated
>Detected Java version: 1.4 in: C:\java\jdk\j2sdk1.4.2_01\jre
>PROP:null
>Detected OS: Windows 2000
>PROP:null
>
>It seems the p.getProperty(... causes the exception. Why?
>
>  
>
The problem here is that p.getProperty() triggers the PropertyHelper to
be placed in a reference (the first call of getProperty() does this).
In Project#addReference() there is  a log message for the fact
that the PropertyHelper reference has been added.
This would cause "messageLogged()" to be called again - hence the 
"infinite loop" detected
and terminated...

The System.out in the error message is invalid - the code assumes that 
it is System.out
if the priority of the message is not ERR, but this is up to the logger 
itself to decide.

The error could be fixed by removing the log() in 
Project#addReference(),  (so that project.getProperty()
can work in a logger) - but this is not a general solution.
Or by silently suppressing the log if a log message is called from 
within a Logger#printMessage -
but this could cause loss of information.

Peter


>I realised this ML is for users, however I'm not subscribed to the DEV
>ML and know plenty of ANT gurus read this list!!!
>
>thx
>
>lyndon
>
>
>        
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>  
>


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