JDK-4697796 : REGRESSION: TextField.append breaks with printlns from Standard output on Win2k.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-06-05
  • Updated: 2002-09-06
  • Resolved: 2002-09-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Related Reports
Relates :  
Description

Name: gm110360			Date: 06/05/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :Microsoft Windows 2000
[Version 5.00.2195]


A DESCRIPTION OF THE PROBLEM :
In Windows 2000, I have an AWT TextField which takes the
redirected Standard output.  However, Printlns show up
strangely in it (They are inserted earlier than would be
expected).  This behavior is not seen in JDK 1.3.1_02 on the
same machine.

REGRESSION.  Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Run the sample application.
2.Press the button in it.
3.Press again.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Would expect to see the following result:
Test println
Test println2
Test println
Test println2

However, in JDK 1.4.0 on Win2k, the second (and subsequent)
button presses insert rather than append the text, resulting
in the following result:

Test println
Test printlnTest println
Test println2
2

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class TestPipe extends Frame implements WindowListener, ActionListener,
Runnable {

	java.awt.TextArea outBox = new java.awt.TextArea();
	Button print = new Button("Print to stdout");
	private transient Thread outThread = new Thread(this,"Java Console Thread");
	PrintStream stdout = System.out;
	PipedInputStream out = new PipedInputStream();

	public TestPipe() {
		super("Java Console");
		setLayout(new BorderLayout());
		addWindowListener(this);

		add("Center",outBox);
		add("South",print);
		print.addActionListener(this);

		pack();
		show();

		try {
			System.setOut(new PrintStream(new PipedOutputStream(out),true));
			outThread.start();
		} catch ( Exception e ) { e.printStackTrace(); }
	}
	
	public void actionPerformed(ActionEvent e) {
	     System.out.println("Test println");
	     System.out.println("Test println2");
	}

	public void dispose() {
		try {
			System.setOut(stdout);
			outThread.stop();
		} catch ( Exception e ) { e.printStackTrace(); }
	}

	public void run() {
		if ( Thread.currentThread() == outThread ) {
			byte[] buf = new byte[4096];
			int n = 0;
			while ( n != -1 ) {
				try {
					n = out.read(buf,0,4096);
					outBox.append(new String(buf,0,n));
				} catch ( Exception e ) { e.printStackTrace(); }
			}
		}
	}

	public void windowActivated(WindowEvent evt) {}
	public void windowClosed(WindowEvent evt) {}
	public void windowClosing(WindowEvent evt) {
              this.dispose();
              System.exit(0);
	}
	public void windowDeactivated(WindowEvent evt) {}
	public void windowDeiconified(WindowEvent evt) {}
	public void windowIconified(WindowEvent evt) {}
	public void windowOpened(WindowEvent evt) {}

	public static void main(String args[]) {
		TestPipe console = new TestPipe();
	}

	public void finalize() {
		try { outThread.stop(); } catch ( Exception e ) {}
	}
}


---------- END SOURCE ----------

Release Regression From : 1.3.1_03
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 143759) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis
14-06-2004

SUGGESTED FIX Name: dkR10074 Date: 08/01/2002 Please see a suggested fix for 4701398. ###@###.### 2002-08-01 ======================================================================
01-08-2002

EVALUATION Probably related to 4652358. ###@###.### 2002-06-05 Name: dkR10074 Date: 08/01/2002 Please see an evaluation for 4701398. ###@###.### 2002-08-01 ======================================================================
05-06-2002