mixing system.out and system.err

i cannot believe this: IDEA seems to mix system.out and system.err even
in the most basic cases!!! (in the run message window)

I mean not multithreading or something like that..........

I maybe wrong, but I think that a normal console is getting this right.

9 comments
Comment actions Permalink

with "mixes" I mean, IDEA does not write the output in corret order.
can be really confusing if you expect that some red line chronologically fits to the black lines around it.

0
Comment actions Permalink

Michael Damberger wrote:

with "mixes" I mean, IDEA does not write the output in corret order.
can be really confusing if you expect that some red line chronologically fits to the black lines around it.


Is there any way to know this? They are separate streams after all.
Maybe IDEA should only read one line at a time from each, and compare
time stamps or something?

0
Comment actions Permalink

Michael Damberger wrote:

with "mixes" I mean, IDEA does not write the output in corret order.
can be really confusing if you expect that some red line chronologically fits to the black lines around it.


I don't know if that is the case here, but STDOUT is often buffered and
STDERR is often not buffered. Maybe that's what you're seeing?

Kreiger



Attachment(s):
signature.asc
0
Comment actions Permalink

Maybe IDEA should only read one line at a time from each, and compare
time stamps or something?


sounds good.

I think that it is a MUST to have the output in the run message window
in the order of the program flow, in other words, if the code reaches a
System.out at timestamp 17 and then a System.err in timestamp 18, then you should see the output from 17 before the one from 18 in the output - Jetbrainers agree??!

(and if this should be a problem when there are multiple threads - including AWT event queue, then please have the right order at least when coming from the same thread!! - which is not the case now!!!)

0
Comment actions Permalink

Michael Damberger wrote:

I think that it is a MUST to have the output in the run message window
in the order of the program flow, in other words, if the code reaches a
System.out at timestamp 17 and then a System.err in timestamp 18, then

> you should see the output from 17 before the one from 18 in the output

This isn't guaranteed since System.out and System.err are two different
output streams. If this is the behaviour you want then you should do
something stupid like System.setErr(System.out), or just always write to
one stream.

> Jetbrainers agree??!

I hope not :P
R

0
Comment actions Permalink

Michael Damberger wrote:
>> Maybe IDEA should only read one line at a time from each, and compare
>> time stamps or something?


sounds good.

I think that it is a MUST to have the output in the run message window
in the order of the program flow, in other words, if the code reaches a
System.out at timestamp 17 and then a System.err in timestamp 18, then you should see the output from 17 before the one from 18 in the output - Jetbrainers agree??!

(and if this should be a problem when there are multiple threads - including AWT event queue, then please have the right order at least when coming from the same thread!! - which is not the case now!!!)


As Robert said, I believe this is a problem because System.out and
System.err must be read from different threads, and there is no way to
guarantee correct ordering.

0
Comment actions Permalink

i = 0
i = 0
i = 1
i = 1
i = 2
i = 2
etc.
is what you see from this code
for (int i = 0; i < 9; i++)
{
System.out.println("out = " + i);
System.err.println("err = " + i);
}

on a console.

this is what IDEA spits out:
out = 0
err = 0
out = 1
out = 2
out = 3
out = 4
out = 5
out = 6
err = 1
err = 2
err = 3
...

do not try to tell this is normal.
I know that you have to collect sout and serr from different threads when using exec,
but I cannot, from a users perspective, accept the above.

Thanks ;)

0
Comment actions Permalink

well, of course the console does this:

out = 0
err = 0
out = 1
err = 1
out = 2
err = 2
out = 3
err = 3
out = 4
err = 4
out = 5
err = 5
out = 6
err = 6
out = 7
err = 7
out = 8
err = 8

but I guess you got the idea ;)

0
Comment actions Permalink

Hmmm, I would have guessed that this helps:

for (int i = 0; i < 9; i++) {
System.out.println("out = " + i);
System.out.flush();
System.err.println("err = " + i);
System.err.flush();
}

...but it does not on XP.

Peter

0

Please sign in to leave a comment.