JDK-4028327 : bufferedReader bug
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_95
  • CPU: x86
  • Submitted: 1997-01-28
  • 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
Relates :  
Description
From: Laurence Vanhelsuwe <###@###.###>
This does not look like form output to me.


Hi, (sorry my left shift key is dead so capitalizaation will be poor0

i think i found a bug in the xxxReader classes (java.io)

in an attempt to write 1.1 "clean" pograms for an upcoming book on
Java beans, i wanted to convert a standard datainputstream.readline()
to the new bufferedreader(new inputstreamreader(somestream))) variant.

If i do this, then compiler stops complaining (clean compile0, but
the program doesn#t work anymore.

the program is very simple. it just takes a JAR file as argument and
prints a summary of the MANIFEST file in the file.

I  include the complete source (2 classes), incl.  the commented lines with
the original datainputstream objects (which worked fine).

the prgram hangs in printmanifestsummary...


  laurence


ps. FEEDBACK much appreciated.

-----------------------------------------------------------------------------

import java.io.*;

public class Manifest {

//-------------------------------------------------------------------
// main entry point. Check command line args. Find manifest file in
// JAR file and produce summary report of its contents.
//-------------------------------------------------------------------
protected void go(String[] args) throws IOException {
//DataInputStream manifestFile;
BufferedReader manifestFile;
String filename;

        if ( args.length != 1 ) {
                System.out.println("Usage: Manifest <jarfile>");
                System.exit(10);
        }

        filename = args[0];

        // go find the MANIFEST.MF file in the ZIP file.
        manifestFile = ZipLocate.zipLocate(filename, "META-INF/MANIFEST.MF");

        if ( manifestFile == null ) {
                System.out.println(
                        "Could not locate MANIFEST.MF entry in " + filename);
                System.exit(10);
        }

        System.out.println(
                "MANIFEST file for JAR file '"+ filename +"' contains:");
        PrintManifestSummary(manifestFile);
}
//-------------------------------------------------------------------
// PrintManifestSummary
//-------------------------------------------------------------------
//protected void PrintManifestSummary(DataInputStream manifestFile)
protected void PrintManifestSummary(BufferedReader manifestFile)
                                                                                                        throws IOException {
String line = "";

        while( (line = manifestFile.readLine()) != null) {
                if ( line.startsWith("Name:") ) {
                        System.out.println(line);
                }
        }
}
//-------------------------------------------------------------------
// static main delegates work to object
//-------------------------------------------------------------------
public static void main (String[] args) {
        try {
                new Manifest().go(args);
        } catch (IOException IOerror) {
                System.out.println("An I/O error occurred: " + IOerror);
        }
}
} // End of Class Manifest



import java.util.zip.*;
import java.io.*;

public class ZipLocate {

//-------------------------------------------------------------------
// static utility method to locate and return a handle to a ZIP entry
//-------------------------------------------------------------------
//public static DataInputStream zipLocate(
public static BufferedReader zipLocate(
                                                                String filename, String zipEntryName)
                                                                        throws ZipException, IOException {
FileInputStream fin;
ZipInputStream in;
ZipEntry entry;
int entrySize;

        fin = new FileInputStream(filename);
        in      = new ZipInputStream(fin);

        entry = in.getNextEntry();
        while ( entry != null ) {
                if ( entry.getName().equals(zipEntryName) ) {
                        break;
                }
                entry = in.getNextEntry();
        }
        if ( ! entry.getName().equals(zipEntryName) ) {
                in.close();
                return null;
        }
//      return new DataInputStream(in);
        return new BufferedReader(new InputStreamReader(in));
}
//-------------------------------------------------------------------
// static main contains self-test code.
//-------------------------------------------------------------------
public static void main(String[] args) {
boolean OK;

        try {
                OK = ( zipLocate("test.jar", "META-INF/MANIFEST.MF") != null);
        } catch (ZipException zipProblem) {
                System.out.println(zipProblem);
                OK = false;
        } catch (IOException IOfailed) {
                System.out.println(IOfailed);
                OK = false;
        }

        String report = OK ? "OK" : "failed";
        System.out.println("ZipLocate test: " + report);
}
} // End of Class ZipLocate


    |                     Laurence Vanhelsuwe                        |
    |                                                                |
    |         E-Mail...:        ###@###.###             |
    |         WWW......: http://www.telework.demon.co.uk/            |

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 A bug in both ZipInputStream and InputStreamReader.
11-06-2004

PUBLIC COMMENTS An InputStreamReader object's read method will loop if the available() method of the underlying InputStream returns a nonzero value after EOF has been reached. To work around this bug, create an InputStream class whose available method always returns 0.
10-06-2004