Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 82202 invoked from network); 26 Apr 2004 08:03:22 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 26 Apr 2004 08:03:22 -0000 Received: (qmail 42699 invoked by uid 500); 26 Apr 2004 08:02:48 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 42622 invoked by uid 500); 26 Apr 2004 08:02:48 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 42543 invoked from network); 26 Apr 2004 08:02:47 -0000 Received: from unknown (HELO mysza.ekom.net.pl) (217.153.51.186) by daedalus.apache.org with SMTP; 26 Apr 2004 08:02:47 -0000 Received: from ouzo by mysza.ekom.net.pl with local (Exim 4.24) id 1BI14t-0008GK-U7 for dev@cocoon.apache.org; Mon, 26 Apr 2004 10:02:59 +0200 Date: Mon, 26 Apr 2004 10:02:59 +0200 From: Leszek Gawron To: dev@cocoon.apache.org Subject: Re: processToStream and ConcurrentModificationException Message-ID: <20040426080259.GC30956@wlkp.org> References: <20040425211857.GA26833@wlkp.org> <408CBC26.1050105@apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <408CBC26.1050105@apache.org> User-Agent: Mutt/1.4.1i X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 = > > "ZXCVXZ-ZXCZXC-#@$-ZXCVZX1abcabcdabce"; > > 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 // \\ \_\\ //_/ ouzo@wlkp.org _\\()//_ .'/()\'. Phone: +48(501)720812 / // \\ \ \\ // recursive: adj; see recursive | \__/ |