JDK-4018515 : java.io.RandomAccessFile.writeUTF never throws UTFDataFormatError
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.0.2,1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.4,solaris_2.5
  • CPU: sparc
  • Submitted: 1996-12-10
  • Updated: 1997-10-23
  • Resolved: 1997-10-23
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.1.1 1.1.1Fixed
Related Reports
Duplicate :  
Description
==== Here is the minimized test demonstrating the bug ====
import java.io.*;
public class java_io_RandomAccessFile_writeUTF {
  public static void main( String argv[] ) {
    RandomAccessFile f;
    String s="\uffff";
    for (int i=0; i<16; i++) 
      s+=s;
    System.out.println("String length= "+s.length());

    try {
      f=new RandomAccessFile("new_file","rw");

      try {
        f.writeUTF(s);
      }
      catch (Error e) {
        System.out.println(e);
      }
      System.out.println("File length now: "+f.length());

    }
    catch (IOException e) {
      System.out.println(e);
    }
  }
 
}
==== Here is the output of the test ====
String length= 65536
File length now: 196610

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

EVALUATION Coding error.
11-06-2004

SUGGESTED FIX Fix writeUTF to check the length of the string to be written.
11-06-2004