https://issues.apache.org/bugzilla/show_bug.cgi?id=54777
--- Comment #5 from Mikhail Epikhin <[email protected]> --- (In reply to comment #4) > (In reply to comment #3) > > (In reply to comment #2) > > > Thanks for the suggested patch. I'm not clear why the code should be > > > better > > > than PrintWriter.println() - this ought to be explained in the Javadoc. > > > > 1. Because real write is "async" opertation by Sampler, which running it in > > my code. > > > > With simple autoFlush=true, everytime when you use println(), you alse call > > flush-ethod. > > OK, then this needs to be documented in the code. > > Since the only function of the thread seems to be to run flush every so > often, I wonder if a separate thread is really needed? > > Perhaps a simple decorator would suffice. > That would solve the issue of how to start the thread safely. My generic idea is writeback module. Yeah, decorator it's good idea. But one of the samplers would doing flush-method, and his will be wait response from kernel. But maybe it doesn't matter? > > > There are some problems with the code as it stands: > > > > > > The field lineSeparator cannot be fixed as '\n', as that is not portable. > > > > > > > Sorry, i look at PrintWriter.lineSeparator by OpenJDK and did it as well > > http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7- > > b147/java/io/PrintWriter.java#PrintWriter.0lineSeparator > > No, it does not. > > It does not fix lineSeparator as the single char '\n'. > > > Any solutions for portable? > > Use the value of the property "line.separator" which is a String (e.g. it > might be \r\n") Okey, but it not good pratice. > > > > Constructors should not start threads - there is no guarantee that the > > > class > > > will have been fully constructed before the thread tries accessing it. > > > > If fluhs-thread not started, real buffer in super() will be constructured > > and another threads make println() operations, but in real, without flush, > > while flush-thread not started. > > Yes, but the ctor still must not start a thread. > You need to find a way to start the thread after construction. Okey, lets play with decorator:) -- You are receiving this mail because: You are the assignee for the bug.
