cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Chicchiriccò <francesco.chicchiri...@tirasa.net>
Subject Re: [c3] Log*Transformer
Date Fri, 18 Feb 2011 20:58:07 GMT
On 18/feb/2011, at 20.28, Reinhard Pötz wrote:

> I had to comment the usage of the Log*Transformers in the sample sitemap because they
break the integration tests (run it.sh or it.bat from C3's root directory). The problem is
that the logfile is written to the file system which doesn't work in a multi-module build
(<map:parameter name="logfile" value="target/logasxml.log" /> -> there is no target
directory at the base directory).
> 
> IMO the best idea would be changing the transformer configurations to use System.out
but the current implementations close the output stream in their finish methods. That's of
course useful for FileOutputStreams but mustn't happen for System.out.
> 
> IMO the best solution would be wrapping the usage of System.out with Commons IO's CloseShieldOutputStream
(http://s.apache.org/commons-io-close-shield-outputstream). However, this would introduce
a dependency of cocoon-sax on commons-io which should be avoided for a minor use case like
this.
> 
> I see two possible solutions:
> 
> a) move the Log*Transformers to cocoon-optional and wrap the usage
>   of System.out with the CloseShieldOutputStream
> 
> b) implement the CloseShield functionality ourselves and leave them
>   where they are.
> 
> I would prefer option a) because it's the simpler solution and leads to less code.
> 
> WDYT?

What if we choose a third option, like changing

                this.outputStream.close();

to

                if (System.out.equals(this.outputStream)) {
                    this.outputStream.flush();
                } else {
                    this.outputStream.close();
                }

in the finish() body, for both transformers?

I made these simple modifications (in the attached patch) and, at least on my machine, the
integration tests are running successfully.

Let me know if this solution is acceptable, thanks.

Regards.


Mime
View raw message