JDK-6621632 : JTextPane freezes after pasting text to replace selected text
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-10-25
  • Updated: 2011-01-19
  • Resolved: 2008-05-22
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Windows XP Professional Version 2002 Service Pack 2

A DESCRIPTION OF THE PROBLEM :
When pasting a string of text with the last one being the carrriage return to replace a segment of selected text without the carriage return at the end in a JTextPane, the whole application freezes.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(1) Open Stylepad.jar in the $JAVA_HOME\demo\jfc\Stylepad.
(2) Open a text editor such as Notepad on Windows.
(3) Type "java" and then hit the RETURN key.
(4) Select  and copy all the text in the editor. Make sure that the carriage return is selected as the last one (this is important to reproduce this bug).
(5) Now go to Stylepad and select "Lewis".
(6) Paste the previous selected text from Notepad.
(7) The application freezes and CPU shoots up more than 50% for a duo-core processor.
(8) This is reproduciable 100%.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The selected text inside the JTextPane should have been replaced by the pasted text, with a new line created by the carriage return.
ACTUAL -
The entire application freezes up.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
None since the application locks up.

REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION This is a good one, I reporduced it and observed 100% cpu usage assigned to the text team
25-10-2007