On 8/9/07, James Zhang <[EMAIL PROTECTED]> wrote: > James.Strachan wrote: > > > > On 8/8/07, James Zhang <[EMAIL PROTECTED]> wrote: > >> hi: > >> I should modify the "org.apache.camel.processor.Pipeline" to make the > >> example finally works. > >> > >> protected Exchange createNextExchange(Processor producer, Exchange > >> previousExchange) { > >> Exchange answer = copyExchangeStrategy(previousExchange); > >> > >> //-----JamesZhang ADD BEGIN > >> Object input = previousExchange.getIn().getBody(); > >> if (input != null) { > >> answer.getIn().setBody(input); > >> } > >> //-----JamesZhang ADD END > >> > >> // now lets set the input of the next exchange to the output of > >> the > >> // previous message if it is not null > >> Object output = previousExchange.getOut().getBody(); > >> if (output != null) { > >> answer.getIn().setBody(output); > >> } > >> return answer; > >> } > >> > >> If I do not do that,the body of copy FileExchange is null;and the router > > > > FWIW this bug indicates a real bug elsewhere - that an Exchange > > implementation does not implement copy() properly. I've patched the > > code to do as you ask, and have added a big warning to note which > > Exchange implementations do not properly copy across the in-body so we > > can fix them as we see the warning. > > > > BTW any idea what the exchange implementation was that caused this > > issue? FWIW I've added extra checks to the FileExchangeTest to ensure > > its not the FileExchange. > > > > It'd be good to add a test case to reproduce this bug you're seeing - > > to be sure we've fixed it etc. > > > Maybe it's wrong what I wrote last night. > The "getIn().getBody()"method of the copy fileExchange will return a > instance of FileInputStream,not null. > But It should return a instance of PersonDeocument. > > I will write the testcase tonight. > And I will add a testcase when I produce a bug aftertime.Thanks.
Ah I get it now :). A FileExchange has had its body changed, but when its copyied, the body is not copied as well. DOH! It turned out to be my mistake - I overloaded the wrong method (copy() instead of newInstance()) - I've added a test case to FileExchangeTest for this and patched it in trunk Incidentlaly for CAMEL-90 I fixed the FileExchange.in.body being a FileInputStream; its now a File, so you can re-parse it many times etc. -- James ------- http://macstrac.blogspot.com/