This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
org.netbeans.core.execution.OutputStreamWriter.write(OutputStreamWriter.java:117) copies the String into an array of characters and sends it to the print stream. But in the majority of cases off == 0 and len == str.length(). Then the copy just hurts performance and memory and the String can be printed directly. Discovered during the evaluation of issue #197600.
Fixed by changeset: 194841:d20ba1cae859 and merged into release701 branch as changeset: 199558:ec996ddc406
(In reply to comment #1) > Fixed by changeset: 194841:d20ba1cae859 > and merged into release701 branch as changeset: 199558:ec996ddc406 I think this change introduces a bug. I guess the idea with the copy is to funnel all the output through one queue method; With this change, if you execute: System.err.println("SYSTEM ERR OUTPUT"); System.err.print("Char array to stderr.\n".toCharArray()); the output is not necessarily in the correct order, since the two statements do not go through the same queueing mechanism. Of course the queue/flush problem in bug #197600 needs to get fixed.
I'm sorry, I did not get your point. What "queueing mechanism" are you talking about? Both methods call write() on the underlying writer and under a synchronization on a lock. But looking into the code is always beneficent, I've found out that there's a missing synchronization in OutputStreamWriter.write(String str, int off, int len) method. Jesse, as the original author, please correct me if I'm wrong.
> I did not get your point. What "queueing mechanism" Since I didn't look at any code, I could be totally wrong. According to Yarda, if things are working correctly there could be up to a 5 second delay. Before the change, all the output was stalled. Now you say some data gets output and some doesn't. That makes me think that after the other bug is fixed, some output would happen right away and some would be delayed by up to 5 seconds. My point is that all the data should be treated the same.
The code seems to be really not finished, I'll add the synchronization and a check for closed stream. ensureOpen() method is not called anywhere... I have no idea where the 5 second delay is implemented. I do not see any more issues in the OutputStreamWriter class.
Integrated into 'main-golden', will be available in build *201105310954* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/d20ba1cae859 User: mentlicher@netbeans.org Log: #199001 Performance improved by not copying the output characters when not necessary.
(In reply to comment #3) > I've found out that there's a > missing synchronization in OutputStreamWriter.write(String str, int off, int > len) method. It rather seems to me that write(char[],int,int) does _not_ need synchronization - PrintStream.print does its own synch, and 'synchronized (lock) {...}' in OSW seems to be used just to guard whether 'out' is null ~ closed or not. > Jesse, as the original author, please correct me if I'm wrong. I do not think I am the original author, though I do not know who is.
Integrated into 'main-golden', will be available in build *201106010401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/d20ba1cae859 User: mentlicher@netbeans.org Log: #199001 Performance improved by not copying the output characters when not necessary.
Hmm, I'd rather leave the synchronization there, changes like this go actually beyond what I wanted to do. If I remove the synchronization, then out.print() can be called on a closed print stream, which will result in a silent failure. We can check for the failure by out.checkError(), but this method flushes the output. I prefer not to do changes like this. http://hg.netbeans.org/main/rev/7bf3ac9904d3 http://hg.netbeans.org/releases/rev/3431fda7e99c
Assuming bug #197600 gets fixed, I hope there's no funny interactions.
There should not be. This class just delegates to a PrintStream, nothing more. As a side-effect, it will fix your issue (#197600) with writing Strings to messages.log file. Printing arrays of characters will not call flush, therefore it could not be seen until a flush is called (e.g. by printing a String). :-)
> it will fix your issue (#197600) I know (and I thank you for that). I must admit I'm quite curious as to what's going on and why this change partially fixes the other problem. I guess I'm not curious enough to dig through code...
Integrated into 'main-golden', will be available in build *201106021001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/d20ba1cae859 User: mentlicher@netbeans.org Log: #199001 Performance improved by not copying the output characters when not necessary.