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

ready() in BufferedReader results inconsistent between signed and unsigned jar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_nt



      Name: nt126004 Date: 01/17/2002


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

      FULL OPERATING SYSTEM VERSION :
      Windows NT Version 4.0



      A DESCRIPTION OF THE PROBLEM :
      The problem appears when testing the BufferedReader for
      ready -- normally (from the command line or from an
      unsigned JAR) this returns a false flag when all records
      have been read. However, when running this inside of a
      signed JAR, it appears to always return true even when all
      lines have been read.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the source below and jar it up with a small test file
      2. run Test -- it works (prints out the file)
      3. Now sign the jar
      4. Run Test -- it keeps reading

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Test should stop reading the file at the end (ready()
      should return false)
      When run inside a signe jard, ready() always returns true

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import java.io.*;
      import java.net.*;
      import java.util.*;
      import javax.swing.*;

      public class JarTest {


      public static void main(String args[]) {

      Test t = new Test();
      // System.out.println("Hello from ESPRESSO");

      t.readInfo();
      System.exit(0);

          }

            public void readInfo() {

            String configFile = "Files/data1.txt";
            int byteCount;
            int nullCount = 0;
            String s;

      try {
      ClassLoader cl = this.getClass().getClassLoader();
      URL fileURL = cl.getResource(configFile);
      InputStreamReader in = new InputStreamReader(fileURL.openStream());
      BufferedReader br = new BufferedReader(in);
      while (br.ready() && nullCount < 5)
      {
      s = br.readLine();
      System.out.println(s);
      if (s == null)
      {
      nullCount++;
      }
      else
      {
      nullCount = 0;
      }

      }
      in.close();
      }
      catch (Exception e)
      { System.out.println(e.toString()); }
      }


      }
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      stop after repeated null lines
      (Review ID: 137897)
      ======================================================================

            Unassigned Unassigned
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: