ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject Re: Telnet task to MS Telnet server
Date Wed, 11 Feb 2004 12:04:23 GMT
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


Mime
View raw message