I am using below code to write user token to a file in Beanshell Post Proccessor. Below code work fine with no issues. But when we execute the script from master -> 3 slaves(3 Slaves execute JMX file in parallel)
Few empty lines and some truncated tokens are written to the file. Appreciate if any one help on this. We need to have actual tokens written to the file with out any truncations and empty lines
import java.io.File;
import org.apache.jmeter.services.FileServer;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.Writer;
File file = new File("/tmp/token.csv");
FileWriter fstream = new FileWriter(file, true);
BufferedWriter out = new BufferedWriter(fstream);
String accesstoken = vars.get("UserTOKEN");
out.write(accesstoken);
out.write("\n");
out.close();
fstream.close();