ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: custom task calls classes with logging = NPE
Date Mon, 30 Aug 2004 05:28:20 GMT
> I understand that Ant is closing the System.out and 
> System.err streams and I can kinda appreciate
> why it's doing that, but it's proving to be a problem for me, 
> since my task calls various classes
> that are not aware of ant and those classes use logging and 
> possibly even direct references to to
> System.out causing my task to fail with a NullPointerException.

I´m not aware that Ant _closes_ these streams ...
Ant uses its own streams:

Main.java:0621: System.setIn(new DemuxInputStream(project));
Main.java:0622: System.setOut(new PrintStream(new DemuxOutputStream(project,
false)));
Main.java:0623: System.setErr(new PrintStream(new DemuxOutputStream(project,
true)));

DemuxOutputStream:
"Logs content written by a thread and forwards the buffers onto the
project object which will forward the content to the appropriate task."



> In short, I'd like to know how one deals with that.

The usual way for logging is invoking the tasks log() method ...
For your external classes: <java> supports a <redirector>. Maybe you can do
something
with that (its early in the morning - maybe thats not the best idea...)


Jan

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message