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.

Bug 232370 - Wrong output in the output window
Summary: Wrong output in the output window
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on: 166379
Blocks:
  Show dependency tree
 
Reported: 2013-07-08 09:58 UTC by ccoffeecup
Modified: 2013-08-06 11:01 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ccoffeecup 2013-07-08 09:58:21 UTC
package exceptiontest;

I get a strange output in the IDE with this code, where I wanted to test some exceptions:

import java.io.IOException;

public class ExceptionTest {

    public static void main(String[] args) throws IOException, InterruptedException {
     
        int i;
        int[] zahlen = new int[5];
        System.out.println();
        
        try{
            for(i = 0; i <= 5; i++){
                System.out.println(" i hat den Wert " + i + "\n");
                zahlen[i] = i;
            }
        }
        catch(ArrayIndexOutOfBoundsException e){
            System.err.println(" Ein illegaler Zugriff! \n");
            
        }
    }
    
}

The output should be "Ein illegaler Zugriff" after the 5th cycle but what I get in the IDE output window is: 

run:
 Ein illegaler Zugriff! 


 i hat den Wert 0

 i hat den Wert 1

 i hat den Wert 2

 i hat den Wert 3

 i hat den Wert 4

 i hat den Wert 5

BUILD SUCCESSFUL (total time: 1 second)


It reports the error in the first line. Sometimes second or third. When I use breakpoints, everything works fine.

Tried Eclipse IDE and to run the .jar everything works like it should. Just the output window if netbeans seems to handle the output a little different.

I think, that is a very serious problem, when finding a bug that you try to handle with some exceptions.
Comment 1 Jiri Prox 2013-07-08 13:13:49 UTC
The problem is probably in synchronization between standard and error output
Comment 2 Tomas Zezula 2013-07-09 16:28:20 UTC
The problem is caused by mixing System.out and System.err.
The output from the wrong order comes from ForkedJavaOverride which needs to drain from stderr and stdout in parallel so there is no ordering. Unfortunately Ant does not support something like ProcessBuilder. setRedirectErrorStream().
For Compile On Save execution the fix of enhancement #166379 may solve the problem, but for non Compile On Save execution (run by Ant) there is no way how to resolve this issue.
Comment 3 Martin Kozeny 2013-08-06 11:01:51 UTC
According to Tomas Zezula's interpretation...