On Mon, Apr 26, 2004 at 09:37:10AM +0200, Sylvain Wallez wrote:
> Leszek Gawron wrote:
>
> >Could anybody explain why I get ConcurrentModificationException with this
> >code:
> >function test() {
> > var str =
> > "<root><guid>[EMAIL
> > PROTECTED]</guid><contractor>1</contractor><positions><position>abc</position><position>abcd</position><position>abce</position></positions></root>";
> > var buffer = new Packages.com.mobilebox.test.OrderSaxBuffer();
> > stringToSAX( str, buffer, "true" );
> >
> > var resolver = null;
> > var source = null;
> > var pipelineUtil = null;
> > try {
> > resolver = cocoon.getComponent( SourceResolver.ROLE );
> > source = resolver.resolveURI( "context://test.xml" );
> >
> > //var s = new java.io.FileOutputStream( "abc.xml" );
> >
> > pipelineUtil = cocoon.createObject(
> > Packages.org.apache.cocoon.components.flow.util.PipelineUtil
> > );
> > pipelineUtil.processToStream( "view/test.jx", { buffer:
> > buffer }, source.outputStream );
> > source.outputStream.close();
> >
> >
>
> The above lines open the ouputStream *two* times. The first time (in the
> processToStream call), it runs ok, and a temp file is created until the
> outputstream is closed.
>
> The line "source.outputStream.close()" tries to *open* an outputStream
> again, and fails because the temp file is present.
>
> So what you should do is close the stream you write to:
> var out = source.outputStream;
> pipelineUtil.processToStream(..., out);
> out.close();
>
> You should even enclose the processToStream() with a try/finally to
> ensure the stream is always properly closed.
Ha, I knew I messed up somewhere. These are my first day fighting sources.
Must say it's fun. Thank you for help.
lg
--
__
| / \ | Leszek Gawron // \\
\_\\ //_/ [EMAIL PROTECTED] _\\()//_
.'/()\'. Phone: +48(501)720812 / // \\ \
\\ // recursive: adj; see recursive | \__/ |