tBufferOutput reset when runjob is finished

One Star

tBufferOutput reset when runjob is finished

Hello all,
I have a main job which calls many child jobs. For each child job which ended normally, I add a line to a tBufferOutput to tell which one went OK.
The Talend job class is loaded with Spring in a Map, as a singleton bean (one process can call many jobs, listed in that Map). So, each time I run the job, it is the same instance (not the child jobs as the parent job instantiates them when needed).
My problem is that form the second time I call the job, it also returns the entries I added during the previous call(s) in the tBufferOutput.
I think this is 'normal' as I use it as a singleton, but it is well a bug for me.
Here is the runjob method when a tBufferOutput is added to the job :
	public final java.util.List<String[]> globalBuffer = new java.util.ArrayList<String[]>();
...
...
public String[][] runJob(String[] args) {
int exitCode = runJobInTOS(args);
String[][] bufferValue = (String[][]) globalBuffer.toArray(new String[]);
return bufferValue;
}

The cleanest way would be to clear the globalBuffer as soon as it is copied to 'bufferValue'.
What do you think?
Cheers,
One Star

Re: tBufferOutput reset when runjob is finished

I noticed this problem a little time ago, and created a component to solve it :
http://www.talendforge.org/exchange/tos/extension_view.php?eid=152
This component is a fork of "tBufferOutput" with an option to clear the buffer before using it.
One Star

Re: tBufferOutput reset when runjob is finished

Maybe it's a little too late to answer but it could help other people which came on the forum.
to clear the buffer you can place a tJava on your job and write into "globalBuffer.clear()".
It could more easy to use than importing developed componant. Smiley Happy
Community Manager

Re: tBufferOutput reset when runjob is finished

Maybe it's a little too late to answer but it could help other people which came on the forum.
to clear the buffer you can place a tJava on your job and write into "globalBuffer.clear()".
It could more easy to use than importing developed componant. Smiley Happy

Hi
Good tip! Thank you~
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tBufferOutput reset when runjob is finished

Maybe it's a little too late to answer but it could help other people which came on the forum.
to clear the buffer you can place a tJava on your job and write into "globalBuffer.clear()".
It could more easy to use than importing developed componant. Smiley Happy

Thanks. That has really helped.
One Star

Re: tBufferOutput reset when runjob is finished

Maybe it's a little too late to answer but it could help other people which came on the forum.
to clear the buffer you can place a tJava on your job and write into "globalBuffer.clear()".
It could more easy to use than importing developed componant. Smiley Happy

Thanks! Thats really helpfull Smiley Happy You could also use tHashOutputs like this if you were planning on linking more than one tBufferOutput to a tBufferInput:
---> tHashOutput1 (append off) ---> tHashInput1 \
--> tUnite1 --> rest of job
---> tHashOutput2 (append off) ---> tHashInput2 /
Although theres no need to do this if you use Dolans suggestion Smiley Happy