Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4657074

InputStreamReader loops forever when decoding more than 8192 bytes in UTF-16

XMLWordPrintable

    • 02
    • x86
    • linux, windows_nt, windows_2000


        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 :
                  Windows NT Version 4.0
                  4.00.1381
                  IE 5.5.50.4807.2300

                  A DESCRIPTION OF THE PROBLEM :
                  Copying a large blob on text into a JTextArea causes the
                  JVM to enter an infinite loop.

                  REGRESSION. Last worked in version 1.3.1

                  STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
                  1. Compile & run the following code snippet
                  2. Copy 70k of text to the system clipboard
                  3. Paste the text into the window via Ctrl-V


                  EXPECTED VERSUS ACTUAL BEHAVIOR :
                  This works fine in 1.3.1, but loops in 1.4.0

                  This bug can be reproduced always.

                  ---------- BEGIN SOURCE ----------
                  import javax.swing.*;

                  public class PasteTest
                  {
                      public static void main(String[] argv)
                      {
                          JFrame frame = new JFrame("Paste Test");
                          frame.setContentPane(new JTextArea());
                          frame.setSize(800,600);
                          frame.setVisible(true);
                      }
                  }
                  ---------- END SOURCE ----------
        -----------------------
        This problem is reproducible without swing usage.
        Steps to reproduce.
        1. Copy 70k text to the system clipboard
        2. compile & run following code

        -- PasteTest.java --
        import java.awt.*;
        import java.awt.datatransfer.*;
        import java.io.*;

        public class PasteTest
        {
            public static void main(String[] argv)
            {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable transferable = clipboard.getContents(null);
        DataFlavor[] flavors = transferable.getTransferDataFlavors();
        int i;
        for (i = 0; i < flavors.length; i++) {
        System.out.println(flavors[i]);
        if (flavors[i].getMimeType().startsWith("text/plain")) {
        break;
        }
        }
        if (i < flavors.length) { //let's do some text/plain reading
        Reader r = null;
        try {
        r = flavors[i].getReaderForText(transferable);
        while(r.read() > 0) {
        ;
        }
        } catch (Exception e) {
        e.printStackTrace();
        }
        }
            }
        }
        ###@###.### 2002-03-23

              mr Mark Reinhold
              cprasadsunw Ck Prasad (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: