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.
Sylvain
-- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
